get_all_settings(); // show controls hook $show_controls = apply_filters('abcon/editor/show_controls', true); // Define hooks as an array and add $show_controls as a key $hooksData = array( 'show_controls' => $show_controls ); // Localize all settings for the editor script wp_localize_script('advanced_block_controls_js', 'AdvancedBlockControlsSettings', array ( "settings" => $all_settings, "hooksData" => $hooksData, "attributeName" => AttributesManager::ATTRIBUTE_KEY ) ); // Editor wp_enqueue_script( 'advanced_block_controls_js', plugin_dir_url(dirname(__FILE__)) . '/js/editor-scripts/index.js', array('wp-element'), ABCON_VERSION, true // Load script in footer ); } public function enqueue_admin_scripts($hook_suffix) { $block_registry = \WP_Block_Type_Registry::get_instance(); // Register Block Categories. $block_categories = []; if ( function_exists( 'get_block_categories' ) ) { $block_categories = get_block_categories( get_post() ); } wp_add_inline_script( 'wp-blocks', sprintf( 'wp.blocks.setCategories( %s );', wp_json_encode( $block_categories ) ), 'after' ); foreach ( $block_registry->get_all_registered() as $block_name => $block_type ) { // editor script. if ( ! empty( $block_type->editor_script ) ) { wp_enqueue_script( $block_type->editor_script ); } // Enqueue style also if ( ! empty( $block_type->editor_style ) ) { wp_enqueue_style( $block_type->editor_style ); } } // -> https://github.com/WordPress/gutenberg/issues/22812 wp_add_inline_script( 'wp-blocks', 'wp.blocks.unstable__bootstrapServerSideBlockDefinitions(' . wp_json_encode( get_block_editor_server_block_settings() ) . ');' ); // Settings Page if ($hook_suffix === 'toplevel_page_' . MenuManager::$menu_slug) { wp_enqueue_script( 'advanced_block_controls_settings_js', plugin_dir_url(dirname(__FILE__)) . '/js/settings-scripts/index.js', ['wp-blocks', 'wp-editor', 'wp-element', 'wp-components', 'wp-i18n', 'wp-edit-post', "wp-block-library"], ABCON_VERSION, true // Load script in footer ); wp_localize_script('advanced_block_controls_settings_js', 'wpApiSettings', array( 'nonce' => wp_create_nonce('wp_rest') )); } // Enqueue editor scripts do_action( 'enqueue_block_editor_assets' ); } }