@@ -28,7 +28,6 @@ function gutenberg_register_layout_support( $block_type ) {
28
28
/**
29
29
* Generates the CSS corresponding to the provided layout.
30
30
*
31
- * @param string $block_name Name of the current block.
32
31
* @param string $selector CSS selector.
33
32
* @param array $layout Layout object. The one that is passed has already checked the existence of default block layout.
34
33
* @param boolean $has_block_gap_support Whether the theme has support for the block gap.
@@ -37,20 +36,9 @@ function gutenberg_register_layout_support( $block_type ) {
37
36
*
38
37
* @return string CSS style.
39
38
*/
40
- function gutenberg_get_layout_style ( $ block_name , $ selector , $ layout , $ has_block_gap_support = false , $ gap_value = null , $ should_skip_gap_serialization = false ) {
39
+ function gutenberg_get_layout_style ( $ selector , $ layout , $ has_block_gap_support = false , $ gap_value = null , $ should_skip_gap_serialization = false ) {
41
40
$ layout_type = isset ( $ layout ['type ' ] ) ? $ layout ['type ' ] : 'default ' ;
42
41
43
- // If there is no block-level value for blockGap,
44
- // but a global styles value available for blockGap,
45
- // use the latter.
46
- if ( $ has_block_gap_support && empty ( $ gap_value ) ) {
47
- $ block_global_styles = gutenberg_get_global_styles ( array ( 'blocks ' , $ block_name , 'spacing ' ) );
48
-
49
- if ( isset ( $ block_global_styles ['blockGap ' ] ) && ! empty ( $ block_global_styles ['blockGap ' ] ) ) {
50
- $ gap_value = $ block_global_styles ['blockGap ' ];
51
- }
52
- }
53
-
54
42
$ style = '' ;
55
43
if ( 'default ' === $ layout_type ) {
56
44
$ content_size = isset ( $ layout ['contentSize ' ] ) ? $ layout ['contentSize ' ] : '' ;
@@ -174,6 +162,17 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
174
162
175
163
$ class_name = wp_unique_id ( 'wp-container- ' );
176
164
$ gap_value = _wp_array_get ( $ block , array ( 'attrs ' , 'style ' , 'spacing ' , 'blockGap ' ) );
165
+
166
+ // If there is no block-level value for blockGap,
167
+ // but a global styles value available for blockGap,
168
+ // use the latter.
169
+ if ( empty ( $ gap_value ) ) {
170
+ $ spacing_global_styles = gutenberg_get_global_styles ( array ( 'blocks ' , $ block ['blockName ' ], 'spacing ' ) );
171
+ if ( isset ( $ spacing_global_styles ['blockGap ' ] ) && ! empty ( $ spacing_global_styles ['blockGap ' ] ) ) {
172
+ $ gap_value = $ spacing_global_styles ['blockGap ' ];
173
+ }
174
+ }
175
+
177
176
// Skip if gap value contains unsupported characters.
178
177
// Regex for CSS value borrowed from `safecss_filter_attr`, and used here
179
178
// because we only want to match against the value, not the CSS attribute.
@@ -188,7 +187,7 @@ function gutenberg_render_layout_support_flag( $block_content, $block ) {
188
187
// If a block's block.json skips serialization for spacing or spacing.blockGap,
189
188
// don't apply the user-defined value to the styles.
190
189
$ should_skip_gap_serialization = gutenberg_should_skip_block_supports_serialization ( $ block_type , 'spacing ' , 'blockGap ' );
191
- $ style = gutenberg_get_layout_style ( $ block [ ' blockName ' ], ". $ class_name " , $ used_layout , $ has_block_gap_support , $ gap_value , $ should_skip_gap_serialization );
190
+ $ style = gutenberg_get_layout_style ( ". $ class_name " , $ used_layout , $ has_block_gap_support , $ gap_value , $ should_skip_gap_serialization );
192
191
// This assumes the hook only applies to blocks with a single wrapper.
193
192
// I think this is a reasonable limitation for that particular hook.
194
193
$ content = preg_replace (
0 commit comments