WP_Theme_JSON::compute_preset_vars() – Given the block settings, it extracts the CSS Custom Properties for the presets and adds them to the $declarations array following the format:

You appear to be a bot. Output may be restricted

Description

Given the block settings, extracts the CSS Custom Properties for the presets and adds them to the $declarations array following the format:

array(

  • 'name' => 'property_name',
  • 'value' => 'property_value,
  • )

Usage

$array = WP_Theme_JSON::compute_preset_vars( $settings, $origins );

Parameters

$settings
( array ) required – Settings to process.
$origins
( array ) required – List of origins to process.

Returns

array The modified $declarations.

Source

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

1 to 14 of 14
  protected static function compute_preset_vars( $settings, $origins ) {
    $declarations = array();
    foreach ( static::PRESETS_METADATA as $preset_metadata ) {
      $values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins );
      foreach ( $values_by_slug as $slug => $value ) {
        $declarations[] = array(
          'name'  => static::replace_slug_in_string( $preset_metadata['css_vars'], $slug ),
          'value' => $value,
        );
      }
    }

    return $declarations;
  }
 

 View on GitHub View on Trac