Customize: Avoid loading the widgets component if a block theme is activated.

This changeset adds a check to ensure the current theme is not a block theme before adding the `widgets` component to the Customizer manager. This avoids a PHP warning when previewing/customizing notification emails with a block theme in BuddyPress and potentially on other plugins.

See https://github.com/buddypress/buddypress/pull/215.

Props imath, mukesh27, faisal03, sumitbagthariya16, webcommsat.
Fixes #60236.




git-svn-id: https://develop.svn.wordpress.org/trunk@58376 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jb Audras 2024-06-10 22:10:03 +00:00
parent 8c859cdd91
commit ffacf9d585

View File

@ -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 @@ final class WP_Customize_Manager {
$args['messenger_channel'] = sanitize_key( wp_unslash( $_REQUEST['customize_messenger_channel'] ) );
}
// Do not load 'widgets' component if a block theme is activated.
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'];