diff options
Diffstat (limited to 'wp-includes/style-engine/class-wp-style-engine-processor.php')
-rw-r--r-- | wp-includes/style-engine/class-wp-style-engine-processor.php | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/wp-includes/style-engine/class-wp-style-engine-processor.php b/wp-includes/style-engine/class-wp-style-engine-processor.php index 0778748..d5e6c73 100644 --- a/wp-includes/style-engine/class-wp-style-engine-processor.php +++ b/wp-includes/style-engine/class-wp-style-engine-processor.php @@ -58,6 +58,7 @@ class WP_Style_Engine_Processor { * Adds rules to be processed. * * @since 6.1.0 + * @since 6.6.0 Added support for rules_group. * * @param WP_Style_Engine_CSS_Rule|WP_Style_Engine_CSS_Rule[] $css_rules A single, or an array of, * WP_Style_Engine_CSS_Rule objects @@ -70,7 +71,24 @@ class WP_Style_Engine_Processor { } foreach ( $css_rules as $rule ) { - $selector = $rule->get_selector(); + $selector = $rule->get_selector(); + $rules_group = $rule->get_rules_group(); + + /** + * If there is a rules_group and it already exists in the css_rules array, + * add the rule to it. + * Otherwise, create a new entry for the rules_group. + */ + if ( ! empty( $rules_group ) ) { + if ( isset( $this->css_rules[ "$rules_group $selector" ] ) ) { + $this->css_rules[ "$rules_group $selector" ]->add_declarations( $rule->get_declarations() ); + continue; + } + $this->css_rules[ "$rules_group $selector" ] = $rule; + continue; + } + + // If the selector already exists, add the declarations to it. if ( isset( $this->css_rules[ $selector ] ) ) { $this->css_rules[ $selector ]->add_declarations( $rule->get_declarations() ); continue; @@ -117,6 +135,7 @@ class WP_Style_Engine_Processor { // Build the CSS. $css = ''; foreach ( $this->css_rules as $rule ) { + // See class WP_Style_Engine_CSS_Rule for the get_css method. $css .= $rule->get_css( $options['prettify'] ); $css .= $options['prettify'] ? "\n" : ''; } |