Changeset 53422 for branches/6.0/src/wp-includes/block-supports/layout.php
- Timestamp:
- 05/20/2022 03:49:09 PM (3 years ago)
- Location:
- branches/6.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/6.0
- Property svn:mergeinfo changed
/trunk merged: 53419-53421
- Property svn:mergeinfo changed
-
branches/6.0/src/wp-includes/block-supports/layout.php
r53085 r53422 42 42 * @param string $gap_value The block gap value to apply. 43 43 * @param boolean $should_skip_gap_serialization Whether to skip applying the user-defined value set in the editor. 44 * @param string $fallback_gap_value The custom fallback value for block gap. 44 45 * @return string CSS style. 45 46 */ 46 function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false ) {47 function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null, $should_skip_gap_serialization = false, $fallback_gap_value = '0.5em' ) { 47 48 $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default'; 48 49 … … 103 104 if ( $has_block_gap_support ) { 104 105 if ( is_array( $gap_value ) ) { 105 $gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : '0.5em';106 $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : '0.5em';106 $gap_row = isset( $gap_value['top'] ) ? $gap_value['top'] : $fallback_gap_value; 107 $gap_column = isset( $gap_value['left'] ) ? $gap_value['left'] : $fallback_gap_value; 107 108 $gap_value = $gap_row === $gap_column ? $gap_row : $gap_row . ' ' . $gap_column; 108 109 } 109 $gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : 'var( --wp--style--block-gap, 0.5em )';110 $gap_style = $gap_value && ! $should_skip_gap_serialization ? $gap_value : "var( --wp--style--block-gap, $fallback_gap_value )"; 110 111 $style .= "gap: $gap_style;"; 111 112 } else { 112 $style .= 'gap: 0.5em;';113 $style .= "gap: $fallback_gap_value;"; 113 114 } 114 115 … … 183 184 } 184 185 186 $fallback_gap_value = _wp_array_get( $block_type->supports, array( 'spacing', 'blockGap', '__experimentalDefault' ), '0.5em' ); 187 185 188 // If a block's block.json skips serialization for spacing or spacing.blockGap, 186 189 // don't apply the user-defined value to the styles. 187 190 $should_skip_gap_serialization = wp_should_skip_block_supports_serialization( $block_type, 'spacing', 'blockGap' ); 188 $style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization );191 $style = wp_get_layout_style( ".$class_name", $used_layout, $has_block_gap_support, $gap_value, $should_skip_gap_serialization, $fallback_gap_value ); 189 192 // This assumes the hook only applies to blocks with a single wrapper. 190 193 // I think this is a reasonable limitation for that particular hook.
Note: See TracChangeset
for help on using the changeset viewer.