From 87c9dfbeb61b41d8672f383edcafc9ccb32e96ac Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 3 Nov 2021 10:23:04 +0400 Subject: [PATCH 1/3] Always display Customizer menu item --- lib/full-site-editing/full-site-editing.php | 29 ++++----------------- 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/lib/full-site-editing/full-site-editing.php b/lib/full-site-editing/full-site-editing.php index 2a8075db99597f..50ef6c3210f8b9 100644 --- a/lib/full-site-editing/full-site-editing.php +++ b/lib/full-site-editing/full-site-editing.php @@ -35,10 +35,6 @@ function gutenberg_remove_legacy_pages() { if ( isset( $submenu['themes.php'] ) ) { $indexes_to_remove = array(); foreach ( $submenu['themes.php'] as $index => $menu_item ) { - if ( false !== strpos( $menu_item[2], 'customize.php' ) && ! gutenberg_site_requires_customizer() ) { - $indexes_to_remove[] = $index; - } - if ( false !== strpos( $menu_item[2], 'gutenberg-widgets' ) ) { $indexes_to_remove[] = $index; } @@ -64,13 +60,11 @@ function gutenberg_adminbar_items( $wp_admin_bar ) { return; } - // Remove customizer link, if this site does not rely on them for plugins or theme options. - if ( ! gutenberg_site_requires_customizer() ) { - $wp_admin_bar->remove_node( 'customize' ); - $wp_admin_bar->remove_node( 'customize-background' ); - $wp_admin_bar->remove_node( 'customize-header' ); - $wp_admin_bar->remove_node( 'widgets' ); - } + // Remove customizer links + $wp_admin_bar->remove_node( 'customize' ); + $wp_admin_bar->remove_node( 'customize-background' ); + $wp_admin_bar->remove_node( 'customize-header' ); + $wp_admin_bar->remove_node( 'widgets' ); // Add site-editor link. if ( ! is_admin() && current_user_can( 'edit_theme_options' ) ) { @@ -86,19 +80,6 @@ function gutenberg_adminbar_items( $wp_admin_bar ) { add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 ); -/** - * Check if any plugin, or theme features, are using the Customizer. - * - * @return bool A boolean value indicating if Customizer support is needed. - */ -function gutenberg_site_requires_customizer() { - if ( has_action( 'customize_register' ) ) { - return true; - } - - return false; -} - /** * Tells the script loader to load the scripts and styles of custom block on site editor screen. * From cb66bdd6dc095356a551be414a63d13763c8b6ed Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 3 Nov 2021 10:46:02 +0400 Subject: [PATCH 2/3] Inline comment full-stop --- lib/full-site-editing/full-site-editing.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/full-site-editing/full-site-editing.php b/lib/full-site-editing/full-site-editing.php index 50ef6c3210f8b9..16462fc9be57d7 100644 --- a/lib/full-site-editing/full-site-editing.php +++ b/lib/full-site-editing/full-site-editing.php @@ -60,7 +60,7 @@ function gutenberg_adminbar_items( $wp_admin_bar ) { return; } - // Remove customizer links + // Remove customizer links. $wp_admin_bar->remove_node( 'customize' ); $wp_admin_bar->remove_node( 'customize-background' ); $wp_admin_bar->remove_node( 'customize-header' ); From e31dc6709745fcedc9215a43d6cf610cb716f6b9 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 3 Nov 2021 11:07:10 +0400 Subject: [PATCH 3/3] Remove the "Menus" and "Additional CSS" panels --- lib/full-site-editing/full-site-editing.php | 34 +++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/lib/full-site-editing/full-site-editing.php b/lib/full-site-editing/full-site-editing.php index 16462fc9be57d7..f62661777f006f 100644 --- a/lib/full-site-editing/full-site-editing.php +++ b/lib/full-site-editing/full-site-editing.php @@ -80,6 +80,40 @@ function gutenberg_adminbar_items( $wp_admin_bar ) { add_action( 'admin_bar_menu', 'gutenberg_adminbar_items', 50 ); +/** + * Removes the legacy core components from the Customizer. + * + * @param array $components Core Customizer components list. + * @return array Modified components list. + */ +function gutenberg_remove_customizer_components( $components ) { + if ( ! gutenberg_is_fse_theme() ) { + return $components; + } + + $index = array_search( 'nav_menus', $components, true ); + if ( false !== $index ) { + unset( $components[ $index ] ); + } + + return $components; +} +add_filter( 'customize_loaded_components', 'gutenberg_remove_customizer_components' ); + +/** + * Removes lagecy Customizer sections for FSE themes. + * + * @param WP_Customize_Manager $wp_customize The customize manager instance. + */ +function gutenberg_remove_customizer_sections( $wp_customize ) { + if ( ! gutenberg_is_fse_theme() ) { + return; + } + + $wp_customize->remove_control( 'custom_css' ); +} +add_action( 'customize_register', 'gutenberg_remove_customizer_sections', 50 ); + /** * Tells the script loader to load the scripts and styles of custom block on site editor screen. *