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

Gallery block: replace gallery experimental setting with a check for use_balanceTags #34979

Merged
merged 4 commits into from
Oct 31, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
18 changes: 5 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,12 @@ 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 is resolved and a patch released.
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
// https://core.trac.wordpress.org/ticket/54130.
$balance_tags = get_option( 'use_balanceTags' );
$experiments_settings = array(
'__unstableGalleryWithImageBlocks' => isset( $experiments['gutenberg-gallery-refactor'] ),
'__unstableGalleryWithImageBlocks' => '1' !== $balance_tags,
glendaviesnz marked this conversation as resolved.
Show resolved Hide resolved
);
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