WP_Theme_JSON::to_ruleset( string $selector, array $declarations ): string

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


Parameters

$selector string Required
CSS selector.
$declarations array Required
List of declarations.

Top ↑

Return

string The resulting CSS ruleset.


Top ↑

Source

File: wp-includes/class-wp-theme-json.php. View all references

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

Top ↑

Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes

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