From 17d37a60f26b80097fe928d683b19abfd0482dfa Mon Sep 17 00:00:00 2001 From: Kai Hao Date: Mon, 17 May 2021 18:40:13 +0800 Subject: [PATCH] Remove Widgets Customizer experimental flag (#31876) * Remove experimental flag * Remove in tests --- lib/experiments-page.php | 11 --------- lib/widgets-customize.php | 12 ++++------ .../experiments/customizing-widgets.test.js | 24 ------------------- 3 files changed, 5 insertions(+), 42 deletions(-) diff --git a/lib/experiments-page.php b/lib/experiments-page.php index 05be96ef6ec7d6..1d06f48e9ed808 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -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' diff --git a/lib/widgets-customize.php b/lib/widgets-customize.php index 3221d8b8e509c0..be8169487b79fe 100644 --- a/lib/widgets-customize.php +++ b/lib/widgets-customize.php @@ -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.+?)(?:\[(?P\d+)\])?$/', $id, $matches ) ) { + if ( gutenberg_use_widgets_block_editor() && preg_match( '/^widget_(?P.+?)(?:\[(?P\d+)\])?$/', $id, $matches ) ) { $id_base = $matches['id_base']; $args['sanitize_callback'] = function( $value ) use ( $id_base ) { @@ -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' ); diff --git a/packages/e2e-tests/specs/experiments/customizing-widgets.test.js b/packages/e2e-tests/specs/experiments/customizing-widgets.test.js index 4d5cd31e9c336e..6f9fb9784bb1dc 100644 --- a/packages/e2e-tests/specs/experiments/customizing-widgets.test.js +++ b/packages/e2e-tests/specs/experiments/customizing-widgets.test.js @@ -28,7 +28,6 @@ describe( 'Widgets Customizer', () => { await deactivatePlugin( 'gutenberg-test-plugin-disables-the-css-animations' ); - await setWidgetsCustomizerExperiment( true ); } ); afterAll( async () => { @@ -36,7 +35,6 @@ describe( 'Widgets Customizer', () => { 'gutenberg-test-plugin-disables-the-css-animations' ); await activateTheme( 'twentytwentyone' ); - await setWidgetsCustomizerExperiment( false ); } ); it( 'should add blocks', async () => { @@ -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.