diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-09-19 04:51:18 +0000 |
commit | 0e41b5d52fdc6af6442816b5f465c9db9f84e126 (patch) | |
tree | e139a90049b158d4eed892d1662ee7f5c358fa31 /wp-includes/style-engine/class-wp-style-engine-processor.php | |
parent | Adding upstream version 6.5.5+dfsg1. (diff) | |
download | wordpress-upstream.tar.xz wordpress-upstream.zip |
Adding upstream version 6.6.1+dfsg1.upstream/6.6.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
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" : ''; } |