WP_Theme_JSON::to_ruleset( string $selector, array $declarations )
This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
Given a selector and a declaration list, creates the corresponding ruleset.
Parameters
- $selector
-
(string) (Required) CSS selector.
- $declarations
-
(array) (Required) List of declarations.
Return
(string) CSS ruleset.
Source
File: wp-includes/class-wp-theme-json.php
private static function to_ruleset( $selector, $declarations ) { if ( empty( $declarations ) ) { return ''; } $declaration_block = array_reduce( $declarations, function ( $carry, $element ) { return $carry .= $element['name'] . ': ' . $element['value'] . ';'; }, '' ); return $selector . '{' . $declaration_block . '}'; }
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |
© 2003–2021 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_theme_json/to_ruleset