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: 60: 61:
<?php
function eventpost_list_block_init() {
global $EventPost;
$dir_path = $EventPost->plugin_path;
$dir = dirname( __DIR__ );
$block_js = 'js/block-list.min.js';
wp_register_script(
'eventpost-blocks',
plugins_url( $block_js, $dir ),
array(
'wp-blocks',
'wp-editor',
'wp-components',
'wp-i18n',
'wp-element',
),
filemtime( "$dir_path/$block_js" )
);
wp_enqueue_script('eventpost-blocks');
if ( function_exists('wp_set_script_translations') ) {
wp_set_script_translations( 'eventslist-block-editor', 'event-post' );
}
$block_css = 'css/block-list.css';
wp_register_style(
'eventslist-block-editor',
plugins_url( $block_css, __FILE__ ),
array(),
filemtime( "$dir_path/$block_css" )
);
}
add_action( 'admin_init', 'eventpost_list_block_init' );
function eventpost_list_block_front_init() {
global $EventPost;
register_block_type( 'eventpost/list', array(
'editor_script' => 'event-post-list-block-editor',
'editor_style' => 'event-post-list-block-editor',
'render_callback' => array($EventPost->Shortcodes, 'shortcode_list'),
) );
}
add_action( 'init', 'eventpost_list_block_front_init' );