-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathexample-block-settings.php
53 lines (47 loc) · 1.43 KB
/
example-block-settings.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
<?php
/**
* Plugin Name: Example Block Settings
* Description: Example block settings plugin.
* Requires at least: 6.1
* Requires PHP: 7.0
* Version: 0.1.0
* Author: Brian Coords
* Author URI: https://www.briancoords.com
* License: GPL-2.0-or-later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Text Domain: example-block-settings
*
* @package example-block-settings
*/
/**
* Enqueue editor specific modifications in the Post Editor.
*
* @return void
*/
function wp_dev_enqueue_editor_modifications() {
$asset_file = include plugin_dir_path( __FILE__ ) . 'build/index.asset.php';
wp_enqueue_script( 'example-block-settings', plugin_dir_url( __FILE__ ) . '/build/index.js', $asset_file['dependencies'], $asset_file['version'], true );
}
add_action( 'enqueue_block_editor_assets', 'wp_dev_enqueue_editor_modifications' );
/**
* Enqueue block specific styles.
*
* @return void
*/
function wp_dev_enqueue_block_assets() {
$blocks = array( 'core/group', 'core/column' );
foreach ( $blocks as $block ) {
$src = plugin_dir_url( __FILE__ ) . '/build/style-index.css';
if ( is_admin() ) {
$src = plugin_dir_url( __FILE__ ) . '/build/index.css';
}
wp_enqueue_block_style(
$block,
array(
'handle' => 'example-block-settings',
'src' => $src,
)
);
}
}
add_action( 'after_setup_theme', 'wp_dev_enqueue_block_assets' );