Skip to content

Commit

Permalink
Remove Widgets Customizer experimental flag (#31876)
Browse files Browse the repository at this point in the history
* Remove experimental flag

* Remove in tests
  • Loading branch information
kevin940726 authored May 17, 2021
1 parent 431adc1 commit 17d37a6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 42 deletions.
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' );
24 changes: 0 additions & 24 deletions packages/e2e-tests/specs/experiments/customizing-widgets.test.js
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

0 comments on commit 17d37a6

Please sign in to comment.