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:
<?php
function eventsmap_block_init() {
global $EventPost;
$dir = dirname( __DIR__ );
$dir_path = $EventPost->plugin_path;
$block_js = 'js/block-map.min.js';
wp_register_script(
'event-post-map-block-editor',
plugins_url( $block_js, $dir ),
array(
'wp-blocks',
'wp-i18n',
'wp-element',
),
filemtime( "$dir_path/$block_js" )
);
$editor_css = 'css/block-map.css';
wp_register_style(
'event-post-map-block-editor',
plugins_url( $editor_css, $dir ),
array(),
filemtime( "$dir_path/$editor_css" )
);
wp_localize_script('event-post-map-block-editor', 'eventpost_gut_params', array(
'maptiles' => $EventPost->maps,
'map_interactions'=>$EventPost->map_interactions,
));
}
add_action( 'admin_init', 'eventsmap_block_init' );
function eventsmap_block_front_init() {
global $EventPost;
register_block_type( 'eventpost/map', array(
'editor_script' => 'event-post-map-block-editor',
'editor_style' => 'event-post-map-block-editor',
'render_callback' => array($EventPost->Shortcodes, 'shortcode_map'),
) );
}
add_action( 'init', 'eventsmap_block_front_init' );