WP_Style_Engine::compile_stylesheet_from_css_rules()public staticWP 6.1.0

Returns a compiled stylesheet from stored CSS rules.

Method of the class: WP_Style_Engine{}

No Hooks.

Return

String. A compiled stylesheet from stored CSS rules.

Usage

$result = WP_Style_Engine::compile_stylesheet_from_css_rules( $css_rules, $options );
$css_rules(WP_Style_Engine_CSS_Rule[]) (required)
An array of WP_Style_Engine_CSS_Rule objects from a store or otherwise.
$options(array)

An array of options.

Default: empty array

  • context(string|null)
    An identifier describing the origin of the style object, e.g. 'block-supports' or 'global-styles'. When set, the style engine will attempt to store the CSS rules.
    Default: 'block-supports'

  • optimize(true|false)
    Whether to optimize the CSS output, e.g. combine rules.
    Default: false

  • prettify(true|false)
    Whether to add new lines and indents to output.
    Default: whether the SCRIPT_DEBUG constant is defined

Changelog

Since 6.1.0 Introduced.

WP_Style_Engine::compile_stylesheet_from_css_rules() code WP 6.5.2

public static function compile_stylesheet_from_css_rules( $css_rules, $options = array() ) {
	$processor = new WP_Style_Engine_Processor();
	$processor->add_rules( $css_rules );
	return $processor->get_css( $options );
}