WP_Style_Engine::store_css_rule( string $store_name, string $css_selector, string[]|WP_Style_Engine_CSS_Declarations $css_declarations, string $rules_group = '' )

In this article

Stores a CSS rule using the provided CSS selector and CSS declarations.

Parameters

$store_namestringrequired
A valid store key.
$css_selectorstringrequired
When a selector is passed, the function will return a full CSS rule $selector { ...rules } otherwise a concatenated string of properties and values.
$css_declarationsstring[]|WP_Style_Engine_CSS_Declarationsrequired
An associative array of CSS definitions, e.g. array( "$property" => "$value", "$property" => "$value" ), or a WP_Style_Engine_CSS_Declarations object.
$rules_groupstringoptional
A parent CSS selector in the case of nested CSS, or a CSS nested @rule, such as @media (min-width: 80rem) or @layer module.

Default:''

Source

public static function store_css_rule( $store_name, $css_selector, $css_declarations, $rules_group = '' ) {
	if ( empty( $store_name ) || empty( $css_selector ) || empty( $css_declarations ) ) {
		return;
	}
	static::get_store( $store_name )->add_rule( $css_selector, $rules_group )->add_declarations( $css_declarations );
}

Changelog

VersionDescription
7.1.0Extended $css_declarations parameter to accept WP_Style_Engine_CSS_Declarations object.
6.6.0Added the $rules_group parameter.
6.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.