Skip to content

Commit

Permalink
Compute presets from theme.json: skip those without classes or vari…
Browse files Browse the repository at this point in the history
…ables (#53574)
  • Loading branch information
oandregal authored Aug 14, 2023
1 parent 4388c48 commit e1e0545
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,10 @@ protected static function compute_preset_classes( $settings, $selector, $origins

$stylesheet = '';
foreach ( static::PRESETS_METADATA as $preset_metadata ) {
if ( empty( $preset_metadata['classes'] ) ) {
continue;
}

$slugs = static::get_settings_slugs( $settings, $preset_metadata, $origins );
foreach ( $preset_metadata['classes'] as $class => $property ) {
foreach ( $slugs as $slug ) {
Expand Down Expand Up @@ -1768,6 +1772,10 @@ protected static function replace_slug_in_string( $input, $slug ) {
protected static function compute_preset_vars( $settings, $origins ) {
$declarations = array();
foreach ( static::PRESETS_METADATA as $preset_metadata ) {
if ( empty( $preset_metadata['css_vars'] ) ) {
continue;
}

$values_by_slug = static::get_settings_values_by_slug( $settings, $preset_metadata, $origins );
foreach ( $values_by_slug as $slug => $value ) {
$declarations[] = array(
Expand Down

0 comments on commit e1e0545

Please sign in to comment.