Skip to content

Commit

Permalink
Load block editor assets in the navigation and widget editors (#30076)
Browse files Browse the repository at this point in the history
* Load editor assets by implementing should_load_block_editor_scripts_and_styles filter

* Add calls to do_action for enqueue_block_editor_assets

* Remove duplicate enqueue
  • Loading branch information
talldan authored Mar 22, 2021
1 parent 6759c19 commit b9e6f4d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion lib/navigation-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
1 change: 1 addition & 0 deletions lib/widgets-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );

Expand Down

0 comments on commit b9e6f4d

Please sign in to comment.