diff --git a/lib/navigation-page.php b/lib/navigation-page.php index d67e9bd13442b7..1837245544c530 100644 --- a/lib/navigation-page.php +++ b/lib/navigation-page.php @@ -51,8 +51,24 @@ function gutenberg_navigation_init( $hook ) { wp_enqueue_script( 'wp-edit-navigation' ); wp_enqueue_style( 'wp-edit-navigation' ); - wp_enqueue_style( 'wp-block-library' ); wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-format-library' ); + do_action( 'enqueue_block_editor_assets' ); } add_action( 'admin_enqueue_scripts', 'gutenberg_navigation_init' ); + +/** + * Tells the script loader to load the scripts and styles of custom block on navigation editor screen. + * + * @param bool $is_block_editor_screen Current decision about loading block assets. + * @return bool Filtered decision about loading block assets. + */ +function gutenberg_navigation_editor_load_block_editor_scripts_and_styles( $is_block_editor_screen ) { + if ( is_callable( 'get_current_screen' ) && 'gutenberg_page_gutenberg-navigation' === get_current_screen()->base ) { + return true; + } + + return $is_block_editor_screen; +} + +add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_navigation_editor_load_block_editor_scripts_and_styles' ); diff --git a/lib/widgets-page.php b/lib/widgets-page.php index 721f75a109b308..92c98a696c9c1f 100644 --- a/lib/widgets-page.php +++ b/lib/widgets-page.php @@ -70,6 +70,7 @@ function gutenberg_widgets_init( $hook ) { wp_enqueue_script( 'wp-format-library' ); wp_enqueue_style( 'wp-edit-widgets' ); wp_enqueue_style( 'wp-format-library' ); + do_action( 'enqueue_block_editor_assets' ); } add_action( 'admin_enqueue_scripts', 'gutenberg_widgets_init' );