Gets the CSS rules as a string.
Parameters
$options
arrayoptional- An array of options.
optimize
boolWhether to optimize the CSS output, e.g. combine rules.
Default false.prettify
boolWhether to add new lines and indents to output.
Defaults to whether theSCRIPT_DEBUG
constant is defined.
Default:
array()
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 ) {
// See class WP_Style_Engine_CSS_Rule for the get_css method.
$css .= $rule->get_css( $options['prettify'] );
$css .= $options['prettify'] ? "\n" : '';
}
return $css;
}
User Contributed Notes
You must log in before being able to contribute a note or feedback.