PluginProbe
Event Post / 6.0.0
Event Post v6.0.0
6.1.1 6.1.0 6.0.1 6.0.0 5.12.0 trunk 3.9 4.0 4.2 4.3 4.4 4.5 5.0 5.1 5.10.0 5.10.1 5.10.2 5.10.3 5.10.4 5.11.0 5.11.1 5.2 5.5 5.6 5.6.1 All 46 releases
event-post / inc / blocks / eventsmap.php

eventsmap.php in Event Post 6.0.0, at inc/blocks/eventsmap.php

36 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Functions to register client-side assets (scripts and stylesheets) for the Gutenberg block.
4 *
5 * @package event-post
6 * @version 6.0.0
7 * @since 5.2
8 * @see https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/#enqueuing-block-scripts
9 */
10
11 if ( ! defined( 'ABSPATH' ) ) exit;
12
13 /**
14 * Registers eventpost/map block
15 */
16
17 function eventsmap_block_init() {
18 $dir = dirname( __DIR__ );
19 $dir_path = EventPost()->plugin_path;
20 $block_js = 'build/map/index.js';
21
22 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" ));
23 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');
24
25 wp_register_style('event-post-map', plugins_url('/build/map/event-map.css', $dir), []);
26 wp_register_script('event-post-map', plugins_url( '/build/map/event-map.js', $dir ), ['jquery'], false, true);
27
28 \register_block_type( $dir_path . '/build/map', array(
29 'editor_script' => 'eventpost-map-editor-script',
30 'script' => 'event-post-map',
31 'style' => 'event-post-map',
32 'render_callback' => array(EventPost()->Shortcodes, 'shortcode_map'),
33 ));
34 }
35 add_action( 'wp_loaded', 'eventsmap_block_init' );
36