forked from liip/image-selector-example-wp-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
image-selector-example.php
48 lines (44 loc) · 1.1 KB
/
image-selector-example.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
<?php
/**
* Plugin Name: Block Image Selector Example
* Description: Example how to create an image selector for a Gutenberg block in WordPress.
* Author: Liip AG
* Author URI: https://liip.ch
* Version: 1.0.0
* License: GPL2+
* License URI: https://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: image-selector-example
* Domain Path: /languages/
*
* @package image-selector-example
*/
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
add_action( 'enqueue_block_editor_assets', 'image_selector_example_enqueue_block_editor_assets' );
function image_selector_example_enqueue_block_editor_assets() {
// Enqueue script
wp_enqueue_script(
'image-selector-example-js',
esc_url( plugins_url( '/dist/block.js', __FILE__ ) ),
array(
'wp-blocks',
'wp-i18n',
'wp-element',
'wp-editor',
'wp-components',
'wp-compose',
'wp-data',
),
'1.0.0',
true // Enqueue the script in the footer.
);
// Enqueue styles
wp_enqueue_style(
'image-selector-example-styles',
esc_url( plugins_url( '/dist/block.css', __FILE__ ) ),
array( 'wp-editor' ),
'1.0.0'
);
}