Skip to content
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
17 changes: 4 additions & 13 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-gallery-refactor',
__( 'Gallery block experiment', 'gutenberg' ),
'gutenberg_display_experiment_field',
'gutenberg-experiments',
'gutenberg_experiments_section',
array(
'label' => __( 'Test a new gallery block that uses nested image blocks (Warning: The new gallery is not compatible with WordPress mobile apps prior to version 18.2. If you use the mobile app, please update to the latest version to avoid content loss.)', 'gutenberg' ),
'id' => 'gutenberg-gallery-refactor',
)
);
register_setting(
'gutenberg-experiments',
'gutenberg-experiments'
Expand Down Expand Up @@ -108,9 +97,11 @@ function gutenberg_display_experiment_section() {
* @return array Filtered editor settings.
*/
function gutenberg_experiments_editor_settings( $settings ) {
$experiments = get_option( 'gutenberg-experiments' );
// The refactored gallery currently can't be run on sites with use_balanceTags option set.
// This bypass needs to remain in place until this is resolved and a patch released.
// https://core.trac.wordpress.org/ticket/54130.
$experiments_settings = array(
'__unstableGalleryWithImageBlocks' => isset( $experiments['gutenberg-gallery-refactor'] ),
'__unstableGalleryWithImageBlocks' => (int) get_option( 'use_balanceTags' ) !== 1,
);
return array_merge( $settings, $experiments_settings );
}
Expand Down
4 changes: 2 additions & 2 deletions packages/e2e-tests/specs/editor/blocks/gallery.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe( 'Gallery', () => {
const filename = await upload( '.wp-block-gallery input[type="file"]' );

const regex = new RegExp(
`<!-- wp:gallery {"ids":\\[\\d+\\],"linkTo":"none"} -->\\s*<figure class="wp-block-gallery columns-1 is-cropped"><ul class="blocks-gallery-grid"><li class="blocks-gallery-item"><figure><img src="[^"]+\\/${ filename }\\.png" alt="" data-id="\\d+" data-link=".+" class="wp-image-\\d+"\\/><\\/figure><\\/li><\\/ul><\\/figure>\\s*<!-- \\/wp:gallery -->`
`<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":\\d+,\\"sizeSlug\\":\\"full\\",\\"linkDestination\\":\\"none\\"} -->\\s*<figure class=\\"wp-block-image size-full\\"><img src=\\"[^"]+\/${ filename }\.png\\" alt=\\"\\" class=\\"wp-image-\\d+\\"\/><\/figure>\\s*<!-- \/wp:image --><\/figure>\\s*<!-- \/wp:gallery -->`
);
expect( await getEditedPostContent() ).toMatch( regex );
} );
Expand All @@ -71,7 +71,7 @@ describe( 'Gallery', () => {
await upload( '.wp-block-gallery input[type="file"]' );

const figureElement = await page.waitForSelector(
'.blocks-gallery-item figure'
'.wp-block-gallery .wp-block-image'
);

await figureElement.click();
Expand Down