WP_Style_Engine_Processor::get_css( array $options = array() ): string

In this article

Gets the CSS rules as a string.

Parameters

$optionsarrayoptional
An array of options.
  • 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 The computed CSS.

Source

public function get_css( $options = array() ) {
	$defaults = array(
		'optimize' => false,
		'prettify' => defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG,
	);
	$options  = wp_parse_args( $options, $defaults );

	// If we have stores, get the rules from them.
	foreach ( $this->stores as $store ) {
		$this->add_rules( $store->get_all_rules() );
	}

	// Combine CSS selectors that have identical declarations.
	if ( true === $options['optimize'] ) {
		$this->combine_rules_selectors();
	}

	// Build the CSS.
	$css = '';
	foreach ( $this->css_rules as $rule ) {
		$css .= $rule->get_css( $options['prettify'] );
		$css .= $options['prettify'] ? "\n" : '';
	}
	return $css;
}

Changelog

VersionDescription
6.4.0The Optimization is no longer the default.
6.1.0Introduced.

User Contributed Notes

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