This repository was archived by the owner on Jun 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgutenberg-map-block.php
More file actions
59 lines (52 loc) · 1.33 KB
/
gutenberg-map-block.php
File metadata and controls
59 lines (52 loc) · 1.33 KB
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
<?php
/**
* Plugin Name: Map Block
* Description: Add a map block to Gutenberg
* Version: 1.0.0
* Author: Clément Boirie
* Author URI: https://github.com/petitphp
*/
defined( 'ABSPATH' ) or die();
add_action( 'enqueue_block_assets', function () {
wp_enqueue_script(
'leaflet',
'https://unpkg.com/leaflet@1.2.0/dist/leaflet.js',
[],
'1.2.0'
);
wp_enqueue_style(
'leaflet',
'https://unpkg.com/leaflet@1.2.0/dist/leaflet.css',
[],
'1.2.0'
);
wp_enqueue_style(
'gutentest/block/style',
plugin_dir_url( __FILE__ ) . '/assets/css/style.css',
[],
filemtime( plugin_dir_path( __FILE__ ) . '/assets/css/style.css' )
);
if ( ! is_admin() ) {
wp_enqueue_script(
'gutentest/block/front',
plugin_dir_url( __FILE__ ) . '/assets/js/front.js',
[ 'leaflet' ],
filemtime( plugin_dir_path( __FILE__ ) . '/assets/js/front.js' ),
true
);
}
} );
add_action( 'enqueue_block_editor_assets', function () {
wp_enqueue_script(
'gutentest/block',
plugin_dir_url( __FILE__ ) . '/assets/js/block.build.js',
[ 'wp-blocks', 'wp-i18n', 'wp-element', 'leaflet' ],
filemtime( plugin_dir_path( __FILE__ ) . '/assets/js/block.build.js' )
);
wp_enqueue_style(
'gutentest/block',
plugin_dir_url( __FILE__ ) . '/assets/css/editor.css',
[],
filemtime( plugin_dir_path( __FILE__ ) . '/assets/css/editor.css' )
);
} );