WP_Theme_JSON::to_ruleset()protected staticWP 5.8.0

Given a selector and a declaration list, creates the corresponding ruleset.

Method of the class: WP_Theme_JSON{}

No Hooks.

Return

String. The resulting CSS ruleset.

Usage

$result = WP_Theme_JSON::to_ruleset( $selector, $declarations );
$selector(string) (required)
CSS selector.
$declarations(array) (required)
List of declarations.

Changelog

Since 5.8.0 Introduced.

WP_Theme_JSON::to_ruleset() code WP 6.1.1

protected static function to_ruleset( $selector, $declarations ) {
	if ( empty( $declarations ) ) {
		return '';
	}

	$declaration_block = array_reduce(
		$declarations,
		static function ( $carry, $element ) {
			return $carry .= $element['name'] . ': ' . $element['value'] . ';'; },
		''
	);

	return $selector . '{' . $declaration_block . '}';
}