WP_Theme_JSON::to_ruleset() WordPress Method
The WP_Theme_JSON::to_ruleset() method is used to convert a theme JSON file into a set of theme rules. These theme rules can be used to determine whether a theme is valid or not, and to automatically generate a theme.
WP_Theme_JSON::to_ruleset( string $selector, array $declarations ) #
Given a selector and a declaration list, creates the corresponding ruleset.
Contents
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
954 955 956 957 958 959 960 961 962 963 964 965 966 967 | 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 . '}' ; } |
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.8.0 | Introduced. |