From a415c29efee45520ae252d2aa28f1083a521cd7b Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 09:56:49 +0200 Subject: Adding upstream version 6.4.3+dfsg1. Signed-off-by: Daniel Baumann --- .../class-wp-style-engine-css-rules-store.php | 155 +++++++++++++++++++++ 1 file changed, 155 insertions(+) create mode 100644 wp-includes/style-engine/class-wp-style-engine-css-rules-store.php (limited to 'wp-includes/style-engine/class-wp-style-engine-css-rules-store.php') 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 new file mode 100644 index 0000000..371e59f --- /dev/null +++ b/wp-includes/style-engine/class-wp-style-engine-css-rules-store.php @@ -0,0 +1,155 @@ +set_name( $store_name ); + } + return static::$stores[ $store_name ]; + } + + /** + * Gets an array of all available stores. + * + * @since 6.1.0 + * + * @return WP_Style_Engine_CSS_Rules_Store[] + */ + public static function get_stores() { + return static::$stores; + } + + /** + * Clears all stores from static::$stores. + * + * @since 6.1.0 + */ + public static function remove_all_stores() { + static::$stores = array(); + } + + /** + * Sets the store name. + * + * @since 6.1.0 + * + * @param string $name The store name. + */ + public function set_name( $name ) { + $this->name = $name; + } + + /** + * Gets the store name. + * + * @since 6.1.0 + * + * @return string + */ + public function get_name() { + return $this->name; + } + + /** + * Gets an array of all rules. + * + * @since 6.1.0 + * + * @return WP_Style_Engine_CSS_Rule[] + */ + public function get_all_rules() { + return $this->rules; + } + + /** + * Gets a WP_Style_Engine_CSS_Rule object by its selector. + * If the rule does not exist, it will be created. + * + * @since 6.1.0 + * + * @param string $selector The CSS selector. + * @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 ); + + // Bail early if there is no selector. + if ( empty( $selector ) ) { + return; + } + + // Create the rule if it doesn't exist. + if ( empty( $this->rules[ $selector ] ) ) { + $this->rules[ $selector ] = new WP_Style_Engine_CSS_Rule( $selector ); + } + + return $this->rules[ $selector ]; + } + + /** + * Removes a selector from the store. + * + * @since 6.1.0 + * + * @param string $selector The CSS selector. + */ + public function remove_rule( $selector ) { + unset( $this->rules[ $selector ] ); + } +} -- cgit v1.2.3