Changeset 52434 for trunk/src/wp-includes/block-supports/layout.php
- Timestamp:
- 01/04/2022 05:37:25 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-supports/layout.php
r52410 r52434 40 40 * the existence of default block layout. 41 41 * @param bool $has_block_gap_support Whether the theme has support for the block gap. 42 * @param string $gap_value The block gap value to apply. 42 43 * @return string CSS style. 43 44 */ 44 function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false ) {45 function wp_get_layout_style( $selector, $layout, $has_block_gap_support = false, $gap_value = null ) { 45 46 $layout_type = isset( $layout['type'] ) ? $layout['type'] : 'default'; 46 47 … … 73 74 $style .= "$selector .alignright { float: right; margin-left: 2em; }"; 74 75 if ( $has_block_gap_support ) { 75 $style .= "$selector > * { margin-top: 0; margin-bottom: 0; }"; 76 $style .= "$selector > * + * { margin-top: var( --wp--style--block-gap ); margin-bottom: 0; }"; 76 $gap_style = $gap_value ? $gap_value : 'var( --wp--style--block-gap )'; 77 $style .= "$selector > * { margin-top: 0; margin-bottom: 0; }"; 78 $style .= "$selector > * + * { margin-top: $gap_style; margin-bottom: 0; }"; 77 79 } 78 80 } elseif ( 'flex' === $layout_type ) { … … 97 99 $style .= 'display: flex;'; 98 100 if ( $has_block_gap_support ) { 99 $style .= 'gap: var( --wp--style--block-gap, 0.5em );'; 101 $gap_style = $gap_value ? $gap_value : 'var( --wp--style--block-gap, 0.5em )'; 102 $style .= "gap: $gap_style;"; 100 103 } else { 101 104 $style .= 'gap: 0.5em;'; … … 157 160 } 158 161 159 $id = uniqid(); 160 $style = wp_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support ); 162 $id = uniqid(); 163 $gap_value = _wp_array_get( $block, array( 'attrs', 'style', 'spacing', 'blockGap' ) ); 164 // Skip if gap value contains unsupported characters. 165 // Regex for CSS value borrowed from `safecss_filter_attr`, and used here 166 // because we only want to match against the value, not the CSS attribute. 167 $gap_value = preg_match( '%[\\\(&=}]|/\*%', $gap_value ) ? null : $gap_value; 168 $style = wp_get_layout_style( ".wp-container-$id", $used_layout, $has_block_gap_support, $gap_value ); 161 169 // This assumes the hook only applies to blocks with a single wrapper. 162 170 // I think this is a reasonable limitation for that particular hook.
Note: See TracChangeset
for help on using the changeset viewer.