From 6e92fd1e6507113ef24cf0dd87f2a06f488e6204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 17 Sep 2020 14:02:56 +0200 Subject: [PATCH 1/2] Remove the classic widgets panel only if the theme did not out of the new widgets editor --- lib/customizer.php | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/lib/customizer.php b/lib/customizer.php index d2f24010c84c67..694a42cde8f582 100644 --- a/lib/customizer.php +++ b/lib/customizer.php @@ -57,6 +57,8 @@ function gutenberg_customize_register( $wp_customize ) { ); if ( gutenberg_use_widgets_block_editor() ) { + // Removes the core 'Widgets' panel from the Customizer if block based widgets are enabled. + $wp_customize->remove_panel( 'widgets' ); $wp_customize->add_section( 'gutenberg_widget_blocks', array( 'title' => __( 'Widget Blocks', 'gutenberg' ) ) @@ -75,25 +77,6 @@ function gutenberg_customize_register( $wp_customize ) { } add_action( 'customize_register', 'gutenberg_customize_register' ); -/** - * Removes the core 'Widgets' panel from the Customizer if block based widgets are enabled. - * - * @param array $components Core Customizer components list. - * @return array (Maybe) modified components list. - */ -function gutenberg_remove_widgets_panel( $components ) { - if ( ! gutenberg_use_widgets_block_editor() ) { - return $components; - } - - $i = array_search( 'widgets', $components, true ); - if ( false !== $i ) { - unset( $components[ $i ] ); - } - return $components; -} -add_filter( 'customize_loaded_components', 'gutenberg_remove_widgets_panel' ); - /** * Filters the Customizer widget settings arguments. * This is needed because the Customizer registers settings for the raw registered widgets, without going through the `sidebars_widgets` filter. From 16f3207c578889c30545090b27f14ea679a4b396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Zieli=C5=84ski?= Date: Thu, 17 Sep 2020 14:22:15 +0200 Subject: [PATCH 2/2] Suppress the warning --- lib/customizer.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/customizer.php b/lib/customizer.php index 694a42cde8f582..589b307a70965c 100644 --- a/lib/customizer.php +++ b/lib/customizer.php @@ -58,7 +58,7 @@ function gutenberg_customize_register( $wp_customize ) { if ( gutenberg_use_widgets_block_editor() ) { // Removes the core 'Widgets' panel from the Customizer if block based widgets are enabled. - $wp_customize->remove_panel( 'widgets' ); + @$wp_customize->remove_panel( 'widgets' ); $wp_customize->add_section( 'gutenberg_widget_blocks', array( 'title' => __( 'Widget Blocks', 'gutenberg' ) )