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 experimental setting for interactivity API and behaviors #52833

Merged
merged 3 commits into from
Jul 24, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/block-supports/behaviors.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand All @@ -63,7 +62,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;
}

Expand Down
3 changes: 0 additions & 3 deletions lib/experimental/editor-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
12 changes: 0 additions & 12 deletions lib/experiments-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <a href="https://github.com/WordPress/gutenberg/issues/50029">Behaviors UI</a> in the Image block.', 'gutenberg' ),
'id' => 'gutenberg-interactivity-api-core-blocks',
)
);

add_settings_field(
'gutenberg-no-tinymce',
__( 'Disable TinyMCE and Classic block', 'gutenberg' ),
Expand Down
4 changes: 1 addition & 3 deletions lib/load.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ export function __experimentalUseHasBehaviorsPanel(
name,
{ blockSupportOnly = false } = {}
) {
if ( ! settings?.behaviors || ! window?.__experimentalInteractivityAPI ) {
if ( ! settings?.behaviors ) {
return false;
}

Expand Down
12 changes: 5 additions & 7 deletions packages/block-editor/src/hooks/behaviors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
4 changes: 1 addition & 3 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'] ) ) {
Expand All @@ -50,8 +49,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;
}
Expand Down
29 changes: 2 additions & 27 deletions test/e2e/specs/editor/blocks/image.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
24 changes: 2 additions & 22 deletions test/e2e/specs/editor/various/behaviors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( {
Expand Down