Skip to content

Commit

Permalink
Gallery Block: Use wp_enqueue_block_support_styles() (#43859)
Browse files Browse the repository at this point in the history
  • Loading branch information
ockham authored Sep 6, 2022
1 parent 8c87431 commit 5be0ec4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/block-library/src/gallery/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ 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 );
wp_enqueue_block_support_styles( $style, 11 );
return $content;
}
/**
Expand Down
11 changes: 9 additions & 2 deletions tools/webpack/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ const blockViewRegex = new RegExp(
* but have been declared elsewhere. This way we can call Gutenberg override functions, but
* the block will still call the core function when updates are back ported.
*/
const prefixFunctions = [ 'build_query_vars_from_query_block' ];
const prefixFunctions = [
'build_query_vars_from_query_block',
'wp_enqueue_block_support_styles',
];

/**
* Escapes the RegExp special characters.
Expand Down Expand Up @@ -140,7 +143,11 @@ module.exports = {
// block will still call the core function when updates are back ported.
content = content.replace(
new RegExp( prefixFunctions.join( '|' ), 'g' ),
( match ) => `${ prefix }${ match }`
( match ) =>
`${ prefix }${ match.replace(
/^wp_/,
''
) }`
);

// Within content, search for any function definitions. For
Expand Down

0 comments on commit 5be0ec4

Please sign in to comment.