WP_Style_Engine::compile_stylesheet_from_css_rules( WP_Style_Engine_CSS_Rule[] $css_rules, array $options = array() ): string

In this article

Returns a compiled stylesheet from stored CSS rules.

Parameters

$css_rulesWP_Style_Engine_CSS_Rule[]required
An array of WP_Style_Engine_CSS_Rule objects from a store or otherwise.
$optionsarrayoptional
An array of options.
  • context string|null
    An identifier describing the origin of the style object, e.g. 'block-supports' or 'global-styles'. Default 'block-supports'.
    When set, the style engine will attempt to store the CSS rules.
  • optimize bool
    Whether to optimize the CSS output, e.g. combine rules.
    Default false.
  • prettify bool
    Whether to add new lines and indents to output.
    Defaults to whether the SCRIPT_DEBUG constant is defined.

Default:array()

Return

string A compiled stylesheet from stored CSS rules.

Source

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 );
}

Changelog

VersionDescription
6.1.0Introduced.

User Contributed Notes

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