From e6c785c65dac2fda11969a407d3cbbe2a5495237 Mon Sep 17 00:00:00 2001 From: imath Date: Fri, 12 Jan 2024 00:55:57 +0100 Subject: [PATCH 1/2] =?UTF-8?q?Only=20activate=20the=20Customizer=E2=80=99?= =?UTF-8?q?s=20widget=20component=20when=20the=20current=20theme=20is=20no?= =?UTF-8?q?t=20a=20block=20one?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/wp-includes/class-wp-customize-manager.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index d12eea0e5f326..00fca3617f5d8 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -100,7 +100,7 @@ final class WP_Customize_Manager { * @since 4.5.0 * @var array */ - protected $components = array( 'widgets', 'nav_menus' ); + protected $components = array( 'nav_menus' ); /** * Registered instances of WP_Customize_Section. @@ -286,6 +286,11 @@ public function __construct( $args = array() ) { $args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) ); } + // Only include 'widgets' component if usable. + if ( ! wp_is_block_theme() ) { + $this->components[] = 'widgets'; + } + $this->original_stylesheet = get_stylesheet(); $this->theme = wp_get_theme( 0 === validate_file( $args['theme'] ) ? $args['theme'] : null ); $this->messenger_channel = $args['messenger_channel']; From ef14b7b3889a537b2aff8ef23dc4341a49d19235 Mon Sep 17 00:00:00 2001 From: imath Date: Fri, 12 Jan 2024 19:56:46 +0100 Subject: [PATCH 2/2] Improve the inline comment about widgets component Co-authored-by: Mukesh Panchal --- src/wp-includes/class-wp-customize-manager.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index 00fca3617f5d8..b29d6a8bfc3c4 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -286,7 +286,7 @@ public function __construct( $args = array() ) { $args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) ); } - // Only include 'widgets' component if usable. + // Don't load 'widgets' component if a block theme is activated. if ( ! wp_is_block_theme() ) { $this->components[] = 'widgets'; }