WP_Style_Engine::compile_css( string[] $css_declarations, string $css_selector ): string

In this article

Returns compiled CSS from CSS declarations.

Parameters

$css_declarationsstring[]required
An associative array of CSS definitions, e.g. array( "$property" => "$value", "$property" => "$value" ).
$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.

Return

string A compiled CSS string.

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

VersionDescription
6.1.0Introduced.

User Contributed Notes

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