WP_Style_Engine_Processor::get_css()publicWP 6.1.0

Gets the CSS rules as a string.

Метод класса: WP_Style_Engine_Processor{}

Хуков нет.

Возвращает

Строку. The computed CSS.

Использование

$WP_Style_Engine_Processor = new WP_Style_Engine_Processor();
$WP_Style_Engine_Processor->get_css( $options );
$options(массив)

An array of options.

По умолчанию: empty array

  • optimize(true|false)
    Whether to optimize the CSS output, e.g. combine rules.
    По умолчанию: false

  • prettify(true|false)
    Whether to add new lines and indents to output.
    По умолчанию: whether the SCRIPT_DEBUG constant is defined

Список изменений

С версии 6.1.0 Введена.
С версии 6.4.0 The Optimization is no longer the default.

Код WP_Style_Engine_Processor::get_css() WP 6.5.2

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