Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the classic widgets panel only if the theme did not opt out of the new editor #25415

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions lib/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) )
Expand All @@ -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.
Expand Down