Changeset 58241 for trunk/src/wp-includes/class-wp-theme-json.php
- Timestamp:
- 05/30/2024 01:14:15 AM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json.php
r58228 r58241 1261 1261 * 1262 1262 * @since 6.2.0 1263 * @since 6.6.0 Enforced 0-1-0 specificity for block custom CSS selectors. 1263 1264 * 1264 1265 * @param string $css The CSS to process. … … 1275 1276 if ( $is_root_css ) { 1276 1277 // If the part doesn't contain braces, it applies to the root level. 1277 $processed_css .= trim( $selector ) . '{' . trim( $part ) . '}';1278 $processed_css .= ':root :where(' . trim( $selector ) . '){' . trim( $part ) . '}'; 1278 1279 } else { 1279 1280 // If the part contains braces, it's a nested CSS rule. … … 1287 1288 ? static::scope_selector( $selector, $nested_selector ) 1288 1289 : static::append_to_selector( $selector, $nested_selector ); 1289 $ processed_css .= $part_selector . '{' . trim( $css_value ) . '}';1290 }1290 $final_selector = ":root :where($part_selector)"; 1291 $processed_css .= $final_selector . '{' . trim( $css_value ) . '}';} 1291 1292 } 1292 1293 return $processed_css; … … 1409 1410 * @since 6.5.1 Only output rules referencing content and wide sizes when values exist. 1410 1411 * @since 6.5.3 Add types parameter to check if only base layout styles are needed. 1412 * @since 6.6.0 Updated layout style specificity to be compatible with overall 0-1-0 specificity in global styles. 1411 1413 * 1412 1414 * @param array $block_metadata Metadata about the block to get styles for. … … 1435 1437 $node = _wp_array_get( $this->theme_json, $block_metadata['path'], array() ); 1436 1438 $layout_definitions = wp_get_layout_definitions(); 1437 $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors.1439 $layout_selector_pattern = '/^[a-zA-Z0-9\-\.\,\ *+>:\(\)]*$/'; // Allow alphanumeric classnames, spaces, wildcard, sibling, child combinator and pseudo class selectors. 1438 1440 1439 1441 /* … … 1510 1512 ); 1511 1513 } else { 1512 $format = static::ROOT_BLOCK_SELECTOR === $selector ? ' :where(%s .%s) %s' : '%s-%s%s';1514 $format = static::ROOT_BLOCK_SELECTOR === $selector ? '.%2$s %3$s' : '%1$s-%2$s %3$s'; 1513 1515 $layout_selector = sprintf( 1514 1516 $format, … … 1594 1596 1595 1597 $layout_selector = sprintf( 1596 '%s .%s%s', 1597 $selector, 1598 '.%s%s', 1598 1599 $class_name, 1599 1600 $base_style_rule['selector'] … … 2502 2503 * @since 6.1.0 2503 2504 * @since 6.6.0 Setting a min-height of HTML when root styles have a background gradient or image. 2505 * Updated general global styles specificity to 0-1-0. 2504 2506 * 2505 2507 * @param array $block_metadata Metadata about the block to get styles for. … … 2651 2653 2652 2654 // 2. Generate and append the rules that use the general selector. 2653 $block_rules .= static::to_ruleset( $selector, $declarations );2655 $block_rules .= static::to_ruleset( ":root :where($selector)", $declarations ); 2654 2656 2655 2657 // 3. Generate and append the rules that use the duotone selector. … … 2668 2670 // 5. Generate and append the feature level rulesets. 2669 2671 foreach ( $feature_declarations as $feature_selector => $individual_feature_declarations ) { 2670 $block_rules .= static::to_ruleset( $feature_selector, $individual_feature_declarations );2672 $block_rules .= static::to_ruleset( ":root :where($feature_selector)", $individual_feature_declarations ); 2671 2673 } 2672 2674 2673 2675 // 6. Generate and append the style variation rulesets. 2674 2676 foreach ( $style_variation_declarations as $style_variation_selector => $individual_style_variation_declarations ) { 2675 $block_rules .= static::to_ruleset( $style_variation_selector, $individual_style_variation_declarations );2677 $block_rules .= static::to_ruleset( ":root :where($style_variation_selector)", $individual_style_variation_declarations ); 2676 2678 } 2677 2679 … … 2684 2686 * @since 6.1.0 2685 2687 * @since 6.6.0 Use `ROOT_CSS_PROPERTIES_SELECTOR` for CSS custom properties and improved consistency of root padding rules. 2688 * Updated specificity of body margin reset and first/last child selectors. 2686 2689 * 2687 2690 * @param string $selector The root node selector. … … 2715 2718 * @link https://github.com/WordPress/gutenberg/issues/36147. 2716 2719 */ 2717 $css .= ' body{ margin: 0; }';2720 $css .= ':where(body) { margin: 0; }'; 2718 2721 2719 2722 if ( $use_root_padding ) { … … 2738 2741 $block_gap_value = static::get_property_value( $this->theme_json, array( 'styles', 'spacing', 'blockGap' ) ); 2739 2742 $css .= ":where(.wp-site-blocks) > * { margin-block-start: $block_gap_value; margin-block-end: 0; }"; 2740 $css .= ':where(.wp-site-blocks) > :first-child :first-child{ margin-block-start: 0; }';2741 $css .= ':where(.wp-site-blocks) > :last-child :last-child{ margin-block-end: 0; }';2743 $css .= ':where(.wp-site-blocks) > :first-child { margin-block-start: 0; }'; 2744 $css .= ':where(.wp-site-blocks) > :last-child { margin-block-end: 0; }'; 2742 2745 2743 2746 // For backwards compatibility, ensure the legacy block gap CSS variable is still available.
Note: See TracChangeset
for help on using the changeset viewer.