WP_Style_Engine::compile_css
Returns compiled CSS from CSS declarations.
Method of the class: WP_Style_Engine{}
No Hooks.
Returns
String. A compiled CSS string.
Usage
$result = WP_Style_Engine::compile_css( $css_declarations, $css_selector );
- $css_declarations(string[]) (required)
- An associative array of CSS definitions, e.g.
array( "$property" => "$value", "$property" => "$value" ). - $css_selector(string) (required)
- When a selector is passed, the function will return a full CSS rule
$selector { ...rules }, otherwise a concatenated string of properties and values.
Changelog
| Since 6.1.0 | Introduced. |
WP_Style_Engine::compile_css() WP Style Engine::compile css code WP 6.9.1
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();
}