From 5d9922202b4fc3ced22744446aa60215a265f627 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 9 Dec 2021 14:55:20 +0100 Subject: [PATCH] Move WP 5.9 wp-admin menus compatibility code to lib/compat folder --- .../wordpress-5.9/admin-menu.php} | 15 +-------------- lib/full-site-editing/edit-site-page.php | 13 +++++++++++++ lib/load.php | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) rename lib/{full-site-editing/full-site-editing.php => compat/wordpress-5.9/admin-menu.php} (77%) diff --git a/lib/full-site-editing/full-site-editing.php b/lib/compat/wordpress-5.9/admin-menu.php similarity index 77% rename from lib/full-site-editing/full-site-editing.php rename to lib/compat/wordpress-5.9/admin-menu.php index 51b57dbad997e9..f8c276daab3755 100644 --- a/lib/full-site-editing/full-site-editing.php +++ b/lib/compat/wordpress-5.9/admin-menu.php @@ -1,6 +1,6 @@ base ) - ? true - : $is_block_editor_screen; -} -add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_site_editor_load_block_editor_scripts_and_styles' ); diff --git a/lib/full-site-editing/edit-site-page.php b/lib/full-site-editing/edit-site-page.php index d8d62d34038097..9a57b25b3657fc 100644 --- a/lib/full-site-editing/edit-site-page.php +++ b/lib/full-site-editing/edit-site-page.php @@ -225,3 +225,16 @@ function register_site_editor_homepage_settings() { ); } add_action( 'init', 'register_site_editor_homepage_settings', 10 ); + +/** + * Tells the script loader to load the scripts and styles of custom block on site editor screen. + * + * @param bool $is_block_editor_screen Current decision about loading block assets. + * @return bool Filtered decision about loading block assets. + */ +function gutenberg_site_editor_load_block_editor_scripts_and_styles( $is_block_editor_screen ) { + return ( is_callable( 'get_current_screen' ) && get_current_screen() && 'appearance_page_gutenberg-edit-site' === get_current_screen()->base ) + ? true + : $is_block_editor_screen; +} +add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_site_editor_load_block_editor_scripts_and_styles' ); diff --git a/lib/load.php b/lib/load.php index dabd4b3530ad16..8349eb5c7739b1 100644 --- a/lib/load.php +++ b/lib/load.php @@ -109,7 +109,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/compat/wordpress-5.9/class-wp-theme-json-gutenberg.php'; require __DIR__ . '/compat/wordpress-5.9/class-wp-theme-json-resolver-gutenberg.php'; require __DIR__ . '/compat/wordpress-5.9/theme.php'; -require __DIR__ . '/full-site-editing/full-site-editing.php'; +require __DIR__ . '/compat/wordpress-5.9/admin-menu.php'; require __DIR__ . '/full-site-editing/edit-site-page.php'; require __DIR__ . '/compat/wordpress-5.9/block-template.php'; require __DIR__ . '/compat/wordpress-5.9/wp-theme-get-post-templates.php';