Skip to content

Commit

Permalink
Gallery block: enable the new gallery block by default if running in …
Browse files Browse the repository at this point in the history
…core (#37134)

* Enable the new gallery block by default if running in core and not plugin

* Add explanatory comment

Co-authored-by: Glen Davies <glen.davies@a8c.com>
  • Loading branch information
glendaviesnz and Glen Davies authored Dec 6, 2021
1 parent 7edb0f0 commit ddc5d1e
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions packages/block-library/src/gallery/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,19 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
* can be removed when minimum supported WP version >=5.9.
*/
export function isGalleryV2Enabled() {
// We want to fail early here, at least during beta testing phase, to ensure
// there aren't instances where undefined values cause false negatives.
if ( ! window.wp || typeof window.wp.galleryBlockV2Enabled !== 'boolean' ) {
throw 'window.wp.galleryBlockV2Enabled is not defined';
// Only run the Gallery version compat check if the plugin is running, otherwise
// assume we are in 5.9 core and enable by default.
if ( process.env.GUTENBERG_PHASE === 2 ) {
// We want to fail early here, at least during beta testing phase, to ensure
// there aren't instances where undefined values cause false negatives.
if (
! window.wp ||
typeof window.wp.galleryBlockV2Enabled !== 'boolean'
) {
throw 'window.wp.galleryBlockV2Enabled is not defined';
}
return window.wp.galleryBlockV2Enabled;
}

return window.wp.galleryBlockV2Enabled;
return true;
}

0 comments on commit ddc5d1e

Please sign in to comment.