WP_Theme_JSON::get_css_variables() – Converts each styles section into a list of rulesets to be appended to the stylesheet.

You appear to be a bot. Output may be restricted

Description

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;
  • }

Usage

$string = WP_Theme_JSON::get_css_variables( $nodes, $origins );

Parameters

$nodes
( array ) required – Nodes with settings.
$origins
( array ) required – List of origins to process.

Returns

string The new stylesheet.

Source

File name: wordpress/wp-includes/class-wp-theme-json.php
Lines:

1 to 17 of 17
  protected function get_css_variables( $nodes, $origins ) {
    $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( static::compute_preset_vars( $node, $origins ), static::compute_theme_vars( $node ) );

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

    return $stylesheet;
  }
 

 View on GitHub View on Trac