1: | <?php |
2: | |
3: | |
4: | |
5: | |
6: | |
7: | |
8: | |
9: | |
10: | |
11: | |
12: | |
13: | |
14: | |
15: | function eventsmap_block_init() { |
16: | $dir = dirname( __DIR__ ); |
17: | $dir_path = EventPost()->plugin_path; |
18: | $block_js = 'build/map/index.js'; |
19: | |
20: | wp_register_script('eventpost-map-editor-script',plugins_url( $block_js, $dir ),array( 'wp-blocks', 'wp-i18n', 'wp-element', 'event-post-map'),filemtime( "$dir_path/$block_js" )); |
21: | wp_add_inline_script('eventpost-map-editor-script', 'var EventPost = EventPost || {}; EventPost.GutParams='.wp_json_encode(array('maptiles' => EventPost()->maps,'map_interactions'=>EventPost()->map_interactions,)), 'before'); |
22: | |
23: | wp_register_style('event-post-map', plugins_url('/build/map/event-map.css', $dir), []); |
24: | wp_register_script('event-post-map', plugins_url( '/build/map/event-map.js', $dir ), ['jquery'], false, true); |
25: | |
26: | \register_block_type( $dir_path . '/build/map', array( |
27: | 'editor_script' => 'eventpost-map-editor-script', |
28: | 'script' => 'event-post-map', |
29: | 'style' => 'event-post-map', |
30: | 'render_callback' => array(EventPost()->Shortcodes, 'shortcode_map'), |
31: | )); |
32: | } |
33: | add_action( 'wp_loaded', 'eventsmap_block_init' ); |
34: | |