wp-includes/class-wp-theme-json.php:2482Converts each styles section into a list of rulesets to be appended to the stylesheet.
$nodesarray$originsstring[]string protected function get_css_variables( $nodes, $origins ) { $stylesheet = ''; foreach ( $nodes as $metadata ) { if ( null === $metadata['selector'] ) { continue; } $selector = $metadata['selector']; $feature_selectors = $metadata['selectors'] ?? array(); $node = _wp_array_get( $this->theme_json, $metadata['path'], array() ); /* * Group preset declarations by selector. Blocks that define * feature-level selectors need their preset CSS variables * output under that feature selector instead of the block's * root selector. */ $vars_by_selector = array(); $vars_by_selector[ $selector ] = array(); foreach ( static::PRESETS_METADATA as $preset_metadata ) { if ( empty( $preset_metadata['css_vars'] ) ) { continue; } $values_by_slug = static::get_settings_values_by_slug( $node, $preset_metadata, $origins ); if ( empty( $values_by_slug ) ) { continue; } $target = static::get_feature_selector( $feature_selectors, $preset_metadata['path'][0], $selector ); if ( ! isset( $vars_by_selector[ $target ] ) ) { $vars_by_selector[ $target ] = array(); } foreach ( $values_by_slug as $slug => $value ) { $vars_by_selector[ $target ][] = array( 'name' => static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ), 'value' => $value, ); } } // Theme vars always use the block's default selector. foreach ( static::compute_theme_vars( $node ) as $theme_var ) { $vars_by_selector[ $selector ][] = $theme_var; } foreach ( $vars_by_selector as $rule_selector => $declarations ) { $stylesheet .= static::to_ruleset( $rule_selector, $declarations ); } } return $stylesheet; }Introduced in 5.8.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
src/wp-includes/class-wp-theme-json.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.