WordPress at Your Fingertips
function is not described

WP_Theme_JSON::get_css_variables() private WP 5.8.0

Converts each styles section into a list of rulesets to be appended to the stylesheet. These rulesets contain all the css variables (custom variables and preset variables).

See glossary at https://developer.mozilla.org/en-US/docs/Web/CSS/Syntax

For each section this creates a new ruleset such as:

block-selector {
  --wp--preset--category--slug: value;
  --wp--custom--variable: value;
}

{} It's a method of the class: WP_Theme_JSON{}

No Hooks.

Return

String. The new stylesheet.

Usage

// private - for code of main (parent) class only
$result = $this->get_css_variables( $nodes );
$nodes(array) (required)
Nodes with settings.

Changelog

Since 5.8.0 Introduced.

Code of WP_Theme_JSON::get_css_variables() WP 5.8.2

private function get_css_variables( $nodes ) {
	$stylesheet = '';
	foreach ( $nodes as $metadata ) {
		if ( null === $metadata['selector'] ) {
			continue;
		}

		$selector = $metadata['selector'];

		$node         = _wp_array_get( $this->theme_json, $metadata['path'], array() );
		$declarations = array_merge( self::compute_preset_vars( $node ), self::compute_theme_vars( $node ) );

		$stylesheet .= self::to_ruleset( $selector, $declarations );
	}

	return $stylesheet;
}