WP_Style_Engine::compile_css()public staticWP 6.1.0

Returns compiled CSS from CSS declarations.

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

Хуков нет.

Возвращает

Строку. A compiled CSS string.

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

$result = WP_Style_Engine::compile_css( $css_declarations, $css_selector );
$css_declarations(string[]) (обязательный)
An associative array of CSS definitions, e.g. array( "$property" => "$value", "$property" => "$value" ).
$css_selector(строка) (обязательный)
When a selector is passed, the function will return a full CSS rule $selector { ...rules }, otherwise a concatenated string of properties and values.

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

С версии 6.1.0 Введена.

Код WP_Style_Engine::compile_css() WP 6.7.1

public static function compile_css( $css_declarations, $css_selector ) {
	if ( empty( $css_declarations ) || ! is_array( $css_declarations ) ) {
		return '';
	}

	// Return an entire rule if there is a selector.
	if ( $css_selector ) {
		$css_rule = new WP_Style_Engine_CSS_Rule( $css_selector, $css_declarations );
		return $css_rule->get_css();
	}

	$css_declarations = new WP_Style_Engine_CSS_Declarations( $css_declarations );
	return $css_declarations->get_declarations_string();
}