Returns compiled CSS from CSS declarations.
Parameters
$css_declarations
string[]required- An associative array of CSS definitions, e.g.
array( "$property" => "$value", "$property" => "$value" )
. $css_selector
stringrequired- When a selector is passed, the function will return a full CSS rule
$selector { ...rules }
, otherwise a concatenated string of properties and values.
Source
public static function compile_css( $css_declarations, $css_selector ) {
if ( empty( $css_declarations ) || ! is_array( $css_declarations ) ) {
return '';
}
// Return an entire rule if there is a selector.
if ( $css_selector ) {
$css_rule = new WP_Style_Engine_CSS_Rule( $css_selector, $css_declarations );
return $css_rule->get_css();
}
$css_declarations = new WP_Style_Engine_CSS_Declarations( $css_declarations );
return $css_declarations->get_declarations_string();
}
Changelog
Version | Description |
---|---|
6.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.