Skip to content
Merged
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
12 changes: 11 additions & 1 deletion packages/block-library/src/gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,17 @@ function block_core_gallery_render( $attributes, $content ) {
// Set the CSS variable to the column value, and the `gap` property to the combined gap value.
$style = '.wp-block-gallery.' . $class . '{ --wp--style--unstable-gallery-gap: ' . $gap_column . '; gap: ' . $gap_value . '}';

gutenberg_enqueue_block_support_styles( $style, 11 );
// If we're on WordPress >= 6.1, we can use `wp_enqueue_block_support_styles`, as it supports
// `$priority` as its second argument. Otherwise, we have to fall back to using our
// `gutenberg_enqueue_block_support_styles` shim.
if (
function_exists( 'wp_enqueue_block_support_styles' ) &&
2 === count( ( new ReflectionFunction( 'wp_enqueue_block_support_styles' ) )->getParameters() )
) {
Comment on lines +110 to +113

@ockham ockham Sep 1, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be

Suggested change
if (
function_exists( 'wp_enqueue_block_support_styles' ) &&
2 === count( ( new ReflectionFunction( 'wp_enqueue_block_support_styles' ) )->getParameters() )
) {
if ( version_compare( get_bloginfo( 'version' ), '6.1', '>=' ) ) {

but I find that less semantic. It also is less accurate, e.g. during the 6.1 alpha phase (now): It would evaluate to false even once WordPress/wordpress-develop#3158 is merged (and used in a local install).

wp_enqueue_block_support_styles( $style, 11 );
} else {
gutenberg_enqueue_block_support_styles( $style, 11 );
}
return $content;
}
/**
Expand Down