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 Widgets Customizer experimental flag #31876

Merged
merged 2 commits into from
May 17, 2021
Merged
Show file tree
Hide file tree
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
11 changes: 0 additions & 11 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,6 @@ function gutenberg_initialize_experiments_settings() {
'id' => 'gutenberg-navigation',
)
);
add_settings_field(
'gutenberg-widgets-in-customizer',
__( 'Widgets', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Enable Widgets screen in Customizer', 'gutenberg' ),
'id' => 'gutenberg-widgets-in-customizer',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down
12 changes: 5 additions & 7 deletions lib/widgets-customize.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function gutenberg_widgets_customize_register( $manager ) {
* @param string $id Widget setting ID.
*/
function gutenberg_widgets_customize_add_unstable_instance( $args, $id ) {
if ( preg_match( '/^widget_(?P<id_base>.+?)(?:\[(?P<widget_number>\d+)\])?$/', $id, $matches ) ) {
if ( gutenberg_use_widgets_block_editor() && preg_match( '/^widget_(?P<id_base>.+?)(?:\[(?P<widget_number>\d+)\])?$/', $id, $matches ) ) {
$id_base = $matches['id_base'];

$args['sanitize_callback'] = function( $value ) use ( $id_base ) {
Expand Down Expand Up @@ -166,9 +166,7 @@ function gutenberg_widgets_customize_load_block_editor_scripts_and_styles( $is_b
return $is_block_editor_screen;
}

if ( gutenberg_is_experiment_enabled( 'gutenberg-widgets-in-customizer' ) ) {
add_action( 'customize_register', 'gutenberg_widgets_customize_register' );
add_filter( 'widget_customizer_setting_args', 'gutenberg_widgets_customize_add_unstable_instance', 10, 2 );
add_action( 'customize_controls_enqueue_scripts', 'gutenberg_customize_widgets_init' );
add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_widgets_customize_load_block_editor_scripts_and_styles' );
}
add_action( 'customize_register', 'gutenberg_widgets_customize_register' );
add_filter( 'widget_customizer_setting_args', 'gutenberg_widgets_customize_add_unstable_instance', 10, 2 );
add_action( 'customize_controls_enqueue_scripts', 'gutenberg_customize_widgets_init' );
add_filter( 'should_load_block_editor_scripts_and_styles', 'gutenberg_widgets_customize_load_block_editor_scripts_and_styles' );
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ describe( 'Widgets Customizer', () => {
await deactivatePlugin(
'gutenberg-test-plugin-disables-the-css-animations'
);
await setWidgetsCustomizerExperiment( true );
} );

afterAll( async () => {
await activatePlugin(
'gutenberg-test-plugin-disables-the-css-animations'
);
await activateTheme( 'twentytwentyone' );
await setWidgetsCustomizerExperiment( false );
} );

it( 'should add blocks', async () => {
Expand Down Expand Up @@ -500,28 +498,6 @@ describe( 'Widgets Customizer', () => {
} );
} );

async function setWidgetsCustomizerExperiment( enabled ) {
await visitAdminPage( 'admin.php', 'page=gutenberg-experiments' );

const checkbox = await find( {
role: 'checkbox',
name: 'Enable Widgets screen in Customizer',
} );

const snapshot = await page.accessibility.snapshot( { root: checkbox } );

if ( snapshot.checked !== enabled ) {
await checkbox.click();
}

const submitButton = await find( {
role: 'button',
name: 'Save Changes',
} );

await Promise.all( [ submitButton.click(), page.waitForNavigation() ] );
}

/**
* TODO: Deleting widgets in the new widgets screen seems to be unreliable.
* We visit the old widgets screen to delete them.
Expand Down