summaryrefslogtreecommitdiffstats
path: root/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:51:22 +0000
commitfc0a79914946dac00ccd51b1aacffe267de7210e (patch)
tree1403384efbfe8f8776ff60aaa40f7d535c02c822 /wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
parentReleasing progress-linux version 6.5.5+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-fc0a79914946dac00ccd51b1aacffe267de7210e.tar.xz
wordpress-fc0a79914946dac00ccd51b1aacffe267de7210e.zip
Merging upstream version 6.6.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/style-engine/class-wp-style-engine-css-rules-store.php')
-rw-r--r--wp-includes/style-engine/class-wp-style-engine-css-rules-store.php15
1 files changed, 13 insertions, 2 deletions
diff --git a/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php b/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
index 371e59f..4a82f28 100644
--- a/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
+++ b/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php
@@ -121,19 +121,30 @@ class WP_Style_Engine_CSS_Rules_Store {
* If the rule does not exist, it will be created.
*
* @since 6.1.0
+ * @since 6.6.0 Added the $rules_group parameter.
*
* @param string $selector The CSS selector.
+ * @param string $rules_group A parent CSS selector in the case of nested CSS, or a CSS nested @rule,
+ * such as `@media (min-width: 80rem)` or `@layer module`.
* @return WP_Style_Engine_CSS_Rule|void Returns a WP_Style_Engine_CSS_Rule object,
* or void if the selector is empty.
*/
- public function add_rule( $selector ) {
- $selector = trim( $selector );
+ public function add_rule( $selector, $rules_group = '' ) {
+ $selector = $selector ? trim( $selector ) : '';
+ $rules_group = $rules_group ? trim( $rules_group ) : '';
// Bail early if there is no selector.
if ( empty( $selector ) ) {
return;
}
+ if ( ! empty( $rules_group ) ) {
+ if ( empty( $this->rules[ "$rules_group $selector" ] ) ) {
+ $this->rules[ "$rules_group $selector" ] = new WP_Style_Engine_CSS_Rule( $selector, array(), $rules_group );
+ }
+ return $this->rules[ "$rules_group $selector" ];
+ }
+
// Create the rule if it doesn't exist.
if ( empty( $this->rules[ $selector ] ) ) {
$this->rules[ $selector ] = new WP_Style_Engine_CSS_Rule( $selector );