On this page
WP_Style_Engine::compile_css( string[] $css_declarations, string $css_selector ): string
Returns compiled CSS from css_declarations.
Parameters
$css_declarationsstring[] Required-
An associative array of CSS definitions, e.g., array( "$property" => "$value", "$property" => "$value" ).
$css_selectorstring Required-
When a selector is passed, the function will return a full CSS rule
$selector { ...rules }, otherwise a concatenated string of properties and values.
Return
string A compiled CSS string.
Source
File: wp-includes/style-engine/class-wp-style-engine.php. View all references
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();
}
Related
Uses
| Uses | Description |
|---|---|
| WP_Style_Engine_CSS_Rule::__construct() wp-includes/style-engine/class-wp-style-engine-css-rule.php | Constructor |
| WP_Style_Engine_CSS_Declarations::__construct() wp-includes/style-engine/class-wp-style-engine-css-declarations.php | Constructor for this object. |
Used By
| Used By | Description |
|---|---|
| wp_style_engine_get_styles() wp-includes/style-engine.php | Global public interface method to generate styles from a single style object, e.g., the value of a block’s attributes.style object or the top level styles in theme.json. |
Changelog
| Version | Description |
|---|---|
| 6.1.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_style_engine/compile_css