Make WordPress Core


Ignore:
Timestamp:
05/03/2024 04:45:20 AM (3 months ago)
Author:
isabel_brison
Message:

Editor: add Style Engine support for nested CSS rules.

Adds support for passing a $rules_group string to wp_style_engine_get_stylesheet_from_css_rules(), so rules can be nested under a media query, layer or other rule.

Props isabel_brison, ramonopoly.
Fixes #61099.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/style-engine.php

    r56574 r58089  
    114114 *
    115115 * @since 6.1.0
     116 * @since 6.6.0 Added support for `$rules_group` in the `$css_rules` array.
    116117 *
    117118 * @param array $css_rules {
     
    119120 *
    120121 *     @type array ...$0 {
     122 *         @type string   $rules_group  A parent CSS selector in the case of nested CSS,
     123 *                                      or a CSS nested @rule, such as `@media (min-width: 80rem)` or `@layer module`.
    121124 *         @type string   $selector     A CSS selector.
    122125 *         @type string[] $declarations An associative array of CSS definitions,
     
    155158        }
    156159
     160        $rules_group = $css_rule['rules_group'] ?? null;
    157161        if ( ! empty( $options['context'] ) ) {
    158             WP_Style_Engine::store_css_rule( $options['context'], $css_rule['selector'], $css_rule['declarations'] );
     162            WP_Style_Engine::store_css_rule( $options['context'], $css_rule['selector'], $css_rule['declarations'], $rules_group );
    159163        }
    160164
    161         $css_rule_objects[] = new WP_Style_Engine_CSS_Rule( $css_rule['selector'], $css_rule['declarations'] );
     165        $css_rule_objects[] = new WP_Style_Engine_CSS_Rule( $css_rule['selector'], $css_rule['declarations'], $rules_group );
    162166    }
    163167
Note: See TracChangeset for help on using the changeset viewer.