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.1
7: * @since 5.2
8: * @see https://wordpress.org/gutenberg/handbook/blocks/writing-your-first-block-type/#enqueuing-block-scripts
9: */
10:
11:
12: if ( ! defined( 'ABSPATH' ) ) exit;
13:
14: /**
15: * Registers eventpost/calendar block
16: */
17: function eventscalendar_block_init() {
18: $dir_path = EventPost()->plugin_path;
19: $dir = dirname( __DIR__ );
20:
21: $block_js = 'build/calendar/index.js';
22: wp_register_script('event-post-calendar-block-editor-script',plugins_url( $block_js, $dir ),array('wp-blocks','wp-editor','wp-components','wp-i18n','wp-element',),filemtime( "$dir_path/$block_js" ));
23:
24: wp_register_script('event-post-calendar-block-editor-script-front-end', plugins_url( '/build/calendar/event-calendar.js', $dir ), ['jquery'], false, true);
25: wp_set_script_translations( 'event-post-calendar-block-editor-script', 'event-post' );
26:
27: \register_block_type( $dir_path . '/build/calendar', array(
28: 'editor_script' => 'event-post-calendar-block-editor-script',
29: 'script' => 'event-post-calendar-block-editor-script-front-end',
30: 'render_callback' => array(EventPost()->Shortcodes, 'shortcode_cal'),
31: ));
32: }
33: add_action( 'wp_loaded', 'eventscalendar_block_init' );
34: