CANTO_FBC_URL, 'FBC_PATH' => CANTO_FBC_PATH, 'FBC_SITE' => get_bloginfo('wpurl'), 'app_api' => $app_api, 'subdomain' => get_option('fbc_flight_domain'), // 'subdomain' => "", 'token' => get_option('fbc_app_token'), 'expire_token' => get_option('fbc_app_expire_token'), 'wp_version' => get_bloginfo('version'), 'wp_editor' => 'gutenberg', //'action' => esc_attr( $form_action_url ), //'abspath' => urlencode(ABSPATH), 'abspath' => CANTO_WP_ABSPATH, //'postID' => $post_id, 'ajax_url' => admin_url('admin-ajax.php'), 'copy_media_nonce' => wp_create_nonce('canto_copy_media'), 'detail_nonce' => wp_create_nonce('canto_detail'), 'get_nonce' => wp_create_nonce('canto_get'), 'tree_nonce' => wp_create_nonce('canto_tree'), 'sizes_nonce' => wp_create_nonce('canto_sizes'), 'limit' => 30, 'start' => 0, // 'nonce' => $nonce, ); wp_register_script( 'canto', plugins_url('block.js', __FILE__), array('wp-blocks', 'wp-i18n', 'wp-element', 'wp-editor', 'wp-data', 'underscore'), filemtime(plugin_dir_path(__FILE__) . 'block.js') ); wp_localize_script('canto', 'args', $translation_array); register_block_type( 'canto/canto-block', array( 'editor_script' => 'canto', ) ); if (function_exists('wp_set_script_translations')) { /** * May be extended to wp_set_script_translations( 'my-handle', 'my-domain', * plugin_dir_path( MY_PLUGIN ) . 'languages' ) ). For details see * https://make.wordpress.org/core/2018/11/09/new-javascript-i18n-support-in-wordpress/ */ wp_set_script_translations('canto', 'canto'); } } add_action('init', 'canto_register_block'); function canto_enqueue_block_editor_assets() { // wp_enqueue_script( 'canto-block', FBC_URL . 'block/block.js', array( 'wp-blocks', 'wp-i18n', 'wp-element' ) ); wp_enqueue_style('canto-block-editor', CANTO_FBC_URL . 'assets/css/editor.css', array('wp-edit-blocks')); } add_action('enqueue_block_editor_assets', 'canto_enqueue_block_editor_assets');