Changeset 58123 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 05/09/2024 04:07:53 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r58030 r58123 38 38 */ 39 39 protected static $blocks_metadata = array(); 40 41 /** 42 * The CSS selector for the top-level preset settings. 43 * 44 * @since 6.6.0 45 * @var string 46 */ 47 const ROOT_CSS_PROPERTIES_SELECTOR = ':root'; 40 48 41 49 /** … … 1709 1717 * @since 5.8.0 1710 1718 * @since 5.9.0 Added the `$origins` parameter. 1719 * @since 6.6.0 Added check for root CSS properties selector. 1711 1720 * 1712 1721 * @param array $settings Settings to process. … … 1716 1725 */ 1717 1726 protected static function compute_preset_classes( $settings, $selector, $origins ) { 1718 if ( static::ROOT_BLOCK_SELECTOR === $selector ) {1727 if ( static::ROOT_BLOCK_SELECTOR === $selector || static::ROOT_CSS_PROPERTIES_SELECTOR === $selector ) { 1719 1728 /* 1720 1729 * Classes at the global level do not need any CSS prefixed, … … 2234 2243 $nodes[] = array( 2235 2244 'path' => array( 'settings' ), 2236 'selector' => static::ROOT_ BLOCK_SELECTOR,2245 'selector' => static::ROOT_CSS_PROPERTIES_SELECTOR, 2237 2246 ); 2238 2247 … … 2615 2624 * 2616 2625 * @since 6.1.0 2626 * @since 6.6.0 Use `ROOT_CSS_PROPERTIES_SELECTOR` for CSS custom properties. 2617 2627 * 2618 2628 * @param string $selector The root node selector. … … 2624 2634 $settings = isset( $this->theme_json['settings'] ) ? $this->theme_json['settings'] : array(); 2625 2635 $use_root_padding = isset( $this->theme_json['settings']['useRootPaddingAwareAlignments'] ) && true === $this->theme_json['settings']['useRootPaddingAwareAlignments']; 2626 2627 /*2628 * Reset default browser margin on the root body element.2629 * This is set on the root selector **before** generating the ruleset2630 * from the `theme.json`. This is to ensure that if the `theme.json` declares2631 * `margin` in its `spacing` declaration for the `body` element then these2632 * user-generated values take precedence in the CSS cascade.2633 * @link https://github.com/WordPress/gutenberg/issues/36147.2634 */2635 $css .= 'body { margin: 0;';2636 2636 2637 2637 /* … … 2644 2644 $wide_size = isset( $settings['layout']['wideSize'] ) ? $settings['layout']['wideSize'] : $settings['layout']['contentSize']; 2645 2645 $wide_size = static::is_safe_css_declaration( 'max-width', $wide_size ) ? $wide_size : 'initial'; 2646 $css .= '--wp--style--global--content-size: ' . $content_size . ';'; 2647 $css .= '--wp--style--global--wide-size: ' . $wide_size . ';'; 2648 } 2649 2650 $css .= ' }'; 2646 $css .= static::ROOT_CSS_PROPERTIES_SELECTOR . ' { --wp--style--global--content-size: ' . $content_size . ';'; 2647 $css .= '--wp--style--global--wide-size: ' . $wide_size . '; }'; 2648 } 2649 2650 /* 2651 * Reset default browser margin on the body element. 2652 * This is set on the body selector **before** generating the ruleset 2653 * from the `theme.json`. This is to ensure that if the `theme.json` declares 2654 * `margin` in its `spacing` declaration for the `body` element then these 2655 * user-generated values take precedence in the CSS cascade. 2656 * @link https://github.com/WordPress/gutenberg/issues/36147. 2657 */ 2658 $css .= 'body { margin: 0; }'; 2651 2659 2652 2660 if ( $use_root_padding ) { … … 2671 2679 $css .= '.wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }'; 2672 2680 2673 $block_gap_value = isset( $this->theme_json['styles']['spacing']['blockGap'] ) ? $this->theme_json['styles']['spacing']['blockGap'] : '0.5em'; 2674 $has_block_gap_support = isset( $this->theme_json['settings']['spacing']['blockGap'] ); 2675 if ( $has_block_gap_support ) { 2681 // Block gap styles will be output unless explicitly set to `null`. See static::PROTECTED_PROPERTIES. 2682 if ( isset( $this->theme_json['settings']['spacing']['blockGap'] ) ) { 2676 2683 $block_gap_value = static::get_property_value( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ) ); 2677 2684 $css .= ":where(.wp-site-blocks) > * { margin-block-start: $block_gap_value; margin-block-end: 0; }"; … … 2680 2687 2681 2688 // For backwards compatibility, ensure the legacy block gap CSS variable is still available. 2682 $css .= "$selector{ --wp--style--block-gap: $block_gap_value; }";2689 $css .= static::ROOT_CSS_PROPERTIES_SELECTOR . " { --wp--style--block-gap: $block_gap_value; }"; 2683 2690 } 2684 2691 $css .= $this->get_layout_styles( $block_metadata );
Note: See TracChangeset
for help on using the changeset viewer.