-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathany-emoji-separator.php
71 lines (64 loc) · 1.8 KB
/
any-emoji-separator.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php
/**
* Plugin Name: Any Emoji Separator
* Description: Add any emoji to the core separator block.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: Cory Hughart
* Author URI: https://cr0ybot.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: any-emoji-separator
*
* @package any-emoji-separator
*/
namespace cr0ybot\AnyEmojiSeparator;
/**
* Enable loading separate stylesheets for blocks.
*/
add_filter( 'should_load_separate_core_block_assets', '__return_true' );
/**
* Enqueue front-end styles & scripts.
*/
function enqueue_assets() {
$asset = require \plugin_dir_path( __FILE__ ) . 'dist/index.asset.php';
/**
* Note: wp_enqueue_block_style() can be called directly outside of a hook, but it works fine here.
*/
\wp_enqueue_block_style(
'core/separator',
array(
'handle' => 'any-emoji-separator-block',
'src' => \plugin_dir_url( __FILE__ ) . 'dist/style.css',
'path' => \plugin_dir_path( __FILE__ ) . 'dist/style.css',
'ver' => $asset['version'],
),
);
}
add_action( 'init', __NAMESPACE__ . '\\enqueue_assets' );
/**
* Enqueue editor assets.
*/
function editor_assets() {
$asset = require \plugin_dir_path( __FILE__ ) . 'dist/index.asset.php';
/**
* Enqueue editor script.
*/
\wp_enqueue_script(
'any-emoji-separator',
\plugin_dir_url( __FILE__ ) . 'dist/index.js',
$asset['dependencies'],
$asset['version'],
);
/**
* Enqueue editor UI styles (separate from front-end block styles).
*/
\wp_enqueue_style(
'any-emoji-separator',
\plugin_dir_url( __FILE__ ) . 'dist/editor.css',
array(),
$asset['version'],
);
}
add_action( 'enqueue_block_editor_assets', __NAMESPACE__ . '\\editor_assets' );