From bb516fbd011b5e9a80b42b6ac3dce961c5c5a073 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Fri, 21 Jul 2023 13:51:03 +0200 Subject: [PATCH 1/3] Remove experimental setting for interactivity API and behaviors --- lib/block-supports/behaviors.php | 2 +- lib/experimental/editor-settings.php | 3 -- lib/experiments-page.php | 12 -------- lib/load.php | 4 +-- .../src/components/global-styles/hooks.js | 2 +- packages/block-editor/src/hooks/behaviors.js | 12 ++++---- packages/block-library/src/image/index.php | 3 +- test/e2e/specs/editor/blocks/image.spec.js | 29 ++----------------- .../specs/editor/various/behaviors.spec.js | 24 ++------------- 9 files changed, 13 insertions(+), 78 deletions(-) diff --git a/lib/block-supports/behaviors.php b/lib/block-supports/behaviors.php index a18700a5884105..7883059e56ee75 100644 --- a/lib/block-supports/behaviors.php +++ b/lib/block-supports/behaviors.php @@ -63,7 +63,7 @@ function gutenberg_render_behaviors_support_lightbox( $block_content, $block ) { return $block_content; } - if ( ! $lightbox_settings || 'none' !== $link_destination || empty( $experiments['gutenberg-interactivity-api-core-blocks'] ) ) { + if ( ! $lightbox_settings || 'none' !== $link_destination ) { return $block_content; } diff --git a/lib/experimental/editor-settings.php b/lib/experimental/editor-settings.php index 15d964e2deec72..9c7f66a587a3aa 100644 --- a/lib/experimental/editor-settings.php +++ b/lib/experimental/editor-settings.php @@ -86,9 +86,6 @@ function gutenberg_enable_experiments() { if ( $gutenberg_experiments && array_key_exists( 'gutenberg-group-grid-variation', $gutenberg_experiments ) ) { wp_add_inline_script( 'wp-block-editor', 'window.__experimentalEnableGroupGridVariation = true', 'before' ); } - if ( $gutenberg_experiments && array_key_exists( 'gutenberg-interactivity-api-core-blocks', $gutenberg_experiments ) ) { - wp_add_inline_script( 'wp-block-editor', 'window.__experimentalInteractivityAPI = true', 'before' ); - } if ( gutenberg_is_experiment_enabled( 'gutenberg-no-tinymce' ) ) { wp_add_inline_script( 'wp-block-library', 'window.__experimentalDisableTinymce = true', 'before' ); diff --git a/lib/experiments-page.php b/lib/experiments-page.php index ea298784aec0c9..ce30242d20f81d 100644 --- a/lib/experiments-page.php +++ b/lib/experiments-page.php @@ -79,18 +79,6 @@ function gutenberg_initialize_experiments_settings() { ) ); - add_settings_field( - 'gutenberg-interactivity-api-core-blocks', - __( 'Interactivity API and Behaviors UI', 'gutenberg' ), - 'gutenberg_display_experiment_field', - 'gutenberg-experiments', - 'gutenberg_experiments_section', - array( - 'label' => __( 'Use the Interactivity API to enable the Behaviors UI in the Image block.', 'gutenberg' ), - 'id' => 'gutenberg-interactivity-api-core-blocks', - ) - ); - add_settings_field( 'gutenberg-no-tinymce', __( 'Disable TinyMCE and Classic block', 'gutenberg' ), diff --git a/lib/load.php b/lib/load.php index 3ffd026a8a444a..28074f11b2cc58 100644 --- a/lib/load.php +++ b/lib/load.php @@ -117,9 +117,7 @@ function gutenberg_is_experiment_enabled( $name ) { require __DIR__ . '/experimental/disable-tinymce.php'; } -if ( gutenberg_is_experiment_enabled( 'gutenberg-interactivity-api-core-blocks' ) ) { - require __DIR__ . '/experimental/interactivity-api/blocks.php'; -} +require __DIR__ . '/experimental/interactivity-api/blocks.php'; require __DIR__ . '/experimental/interactivity-api/class-wp-interactivity-store.php'; require __DIR__ . '/experimental/interactivity-api/store.php'; require __DIR__ . '/experimental/interactivity-api/scripts.php'; diff --git a/packages/block-editor/src/components/global-styles/hooks.js b/packages/block-editor/src/components/global-styles/hooks.js index 96be5779124d74..9347afe54298e1 100644 --- a/packages/block-editor/src/components/global-styles/hooks.js +++ b/packages/block-editor/src/components/global-styles/hooks.js @@ -551,7 +551,7 @@ export function __experimentalUseHasBehaviorsPanel( name, { blockSupportOnly = false } = {} ) { - if ( ! settings?.behaviors || ! window?.__experimentalInteractivityAPI ) { + if ( ! settings?.behaviors ) { return false; } diff --git a/packages/block-editor/src/hooks/behaviors.js b/packages/block-editor/src/hooks/behaviors.js index 27ef5b7afbfe93..ab44edbfa8fd86 100644 --- a/packages/block-editor/src/hooks/behaviors.js +++ b/packages/block-editor/src/hooks/behaviors.js @@ -199,10 +199,8 @@ export const withBehaviors = createHigherOrderComponent( ( BlockEdit ) => { }; }, 'withBehaviors' ); -if ( window?.__experimentalInteractivityAPI ) { - addFilter( - 'editor.BlockEdit', - 'core/behaviors/with-inspector-control', - withBehaviors - ); -} +addFilter( + 'editor.BlockEdit', + 'core/behaviors/with-inspector-control', + withBehaviors +); diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index 9c8f66b7ffe185..ba09f270205005 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -50,8 +50,7 @@ function render_block_core_image( $attributes, $content, $block ) { // If the lightbox is enabled, the image is not linked, and the Interactivity API is enabled, load the view script. if ( isset( $lightbox_settings['enabled'] ) && true === $lightbox_settings['enabled'] && - 'none' === $link_destination && - ! empty( $experiments['gutenberg-interactivity-api-core-blocks'] ) + 'none' === $link_destination ) { $should_load_view_script = true; } diff --git a/test/e2e/specs/editor/blocks/image.spec.js b/test/e2e/specs/editor/blocks/image.spec.js index a2c4399fcac7ae..ac05284248d55a 100644 --- a/test/e2e/specs/editor/blocks/image.spec.js +++ b/test/e2e/specs/editor/blocks/image.spec.js @@ -737,38 +737,13 @@ test.describe( 'Image - interactivity', () => { await requestUtils.deleteAllMedia(); } ); - test.beforeEach( async ( { admin, page, editor } ) => { - await admin.visitAdminPage( - '/admin.php', - 'page=gutenberg-experiments' - ); - - await page - .locator( `#gutenberg-interactivity-api-core-blocks` ) - .setChecked( true ); - - await page.locator( `input[name="submit"]` ).click(); - await page.waitForLoadState(); - + test.beforeEach( async ( { admin, editor } ) => { await admin.createNewPost(); await editor.insertBlock( { name: 'core/image' } ); } ); - test.afterEach( async ( { requestUtils, admin, page } ) => { + test.afterEach( async ( { requestUtils } ) => { await requestUtils.deleteAllMedia(); - - await admin.visitAdminPage( - '/admin.php', - 'page=gutenberg-experiments' - ); - - await page - .locator( `#gutenberg-interactivity-api-core-blocks` ) - .setChecked( false ); - - await page.locator( `input[name="submit"]` ).click(); - - await page.waitForLoadState(); } ); test.describe( 'tests using uploaded image', () => { diff --git a/test/e2e/specs/editor/various/behaviors.spec.js b/test/e2e/specs/editor/various/behaviors.spec.js index a1b76d6c6105af..438eca45e876dd 100644 --- a/test/e2e/specs/editor/various/behaviors.spec.js +++ b/test/e2e/specs/editor/various/behaviors.spec.js @@ -21,32 +21,12 @@ test.describe( 'Testing behaviors functionality', () => { await requestUtils.activateTheme( 'twentytwentyone' ); await requestUtils.deleteAllPosts(); } ); - test.beforeEach( async ( { admin, page, requestUtils } ) => { + test.beforeEach( async ( { requestUtils } ) => { await requestUtils.deleteAllMedia(); - await admin.visitAdminPage( - '/admin.php', - 'page=gutenberg-experiments' - ); - - await page - .locator( `#gutenberg-interactivity-api-core-blocks` ) - .setChecked( true ); - await page.locator( `input[name="submit"]` ).click(); - await page.waitForLoadState(); } ); - test.afterEach( async ( { admin, page, requestUtils } ) => { + test.afterEach( async ( { requestUtils } ) => { await requestUtils.deleteAllMedia(); - await admin.visitAdminPage( - '/admin.php', - 'page=gutenberg-experiments' - ); - - await page - .locator( `#gutenberg-interactivity-api-core-blocks` ) - .setChecked( false ); - await page.locator( `input[name="submit"]` ).click(); - await page.waitForLoadState(); } ); test( 'Behaviors UI can be disabled in the `theme.json`', async ( { From 53c09955d884f5a2dbb74eed2b38474e307cb214 Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Fri, 21 Jul 2023 14:02:33 +0200 Subject: [PATCH 2/3] Remove unused vars --- lib/block-supports/behaviors.php | 1 - packages/block-library/src/image/index.php | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/block-supports/behaviors.php b/lib/block-supports/behaviors.php index 7883059e56ee75..95639178c2de41 100644 --- a/lib/block-supports/behaviors.php +++ b/lib/block-supports/behaviors.php @@ -44,7 +44,6 @@ function gutenberg_register_behaviors_support( $block_type ) { * @return string Filtered block content. */ function gutenberg_render_behaviors_support_lightbox( $block_content, $block ) { - $experiments = get_option( 'gutenberg-experiments' ); $link_destination = isset( $block['attrs']['linkDestination'] ) ? $block['attrs']['linkDestination'] : 'none'; // Get the lightbox setting from the block attributes. if ( isset( $block['attrs']['behaviors']['lightbox'] ) ) { diff --git a/packages/block-library/src/image/index.php b/packages/block-library/src/image/index.php index ba09f270205005..b9bcf461dcf602 100644 --- a/packages/block-library/src/image/index.php +++ b/packages/block-library/src/image/index.php @@ -32,7 +32,6 @@ function render_block_core_image( $attributes, $content, $block ) { } $should_load_view_script = false; - $experiments = get_option( 'gutenberg-experiments' ); $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none'; // Get the lightbox setting from the block attributes. if ( isset( $attributes['behaviors']['lightbox'] ) ) { From 9430b441f5ecae771e764eb3a32a9ed5bbb3a89d Mon Sep 17 00:00:00 2001 From: Carlos Bravo Date: Mon, 24 Jul 2023 13:34:35 +0200 Subject: [PATCH 3/3] Use interactivity for image all times --- lib/experimental/interactivity-api/blocks.php | 27 ------------------- lib/load.php | 1 - packages/block-library/src/image/block.json | 3 ++- 3 files changed, 2 insertions(+), 29 deletions(-) delete mode 100644 lib/experimental/interactivity-api/blocks.php diff --git a/lib/experimental/interactivity-api/blocks.php b/lib/experimental/interactivity-api/blocks.php deleted file mode 100644 index 6997f2695c9d68..00000000000000 --- a/lib/experimental/interactivity-api/blocks.php +++ /dev/null @@ -1,27 +0,0 @@ -