diff --git a/lib/class-wp-theme-json.php b/lib/class-wp-theme-json.php index 35da7df75b79a..6728fb72d0267 100644 --- a/lib/class-wp-theme-json.php +++ b/lib/class-wp-theme-json.php @@ -649,7 +649,7 @@ private static function compute_style_properties( $declarations, $styles ) { foreach ( $properties as $prop ) { $value = self::get_property_value( $styles, $prop['value'] ); if ( ! empty( $value ) ) { - $declarations[] = array( + $declarations[] = array( 'name' => $prop['name'], 'value' => $value, ); @@ -678,6 +678,9 @@ private static function compute_preset_classes( $settings, $selector ) { $stylesheet = ''; foreach ( self::PRESETS_METADATA as $preset ) { $values = _wp_array_get( $settings, $preset['path'], array() ); + if ( empty( $values ) ) { + continue; + } foreach ( $values as $value ) { foreach ( $preset['classes'] as $class ) { $stylesheet .= self::to_ruleset( @@ -716,6 +719,9 @@ private static function compute_preset_classes( $settings, $selector ) { private static function compute_preset_vars( $declarations, $settings ) { foreach ( self::PRESETS_METADATA as $preset ) { $values = _wp_array_get( $settings, $preset['path'], array() ); + if ( empty( $values ) ) { + continue; + } foreach ( $values as $value ) { $declarations[] = array( 'name' => '--wp--preset--' . $preset['css_var_infix'] . '--' . $value['slug'],