Skip to content

Commit

Permalink
Use 'merge' to mimic old behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlende committed Jan 30, 2024
1 parent 3da60aa commit 0333ef6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 15 additions & 1 deletion lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2772,7 +2772,21 @@ public function merge( $incoming ) {

// Replace the presets.
foreach ( static::PRESETS_METADATA as $preset ) {
$override_preset = ! static::get_metadata_boolean( $this->theme_json['settings'], $preset['prevent_override'], true );
$override_preset = false;
if ( is_array( $preset['prevent_override'] ) ) {
$prevent_override = _wp_array_get( $this->theme_json['settings'], $preset['prevent_override'] );
/*
* For backwards compatibility with presets converting from a hardcoded `false`

Check failure on line 2779 in lib/class-wp-theme-json-gutenberg.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Whitespace found at end of line
* for `prevent_override` to a path to a boolean (`defaultFontSizes`, for example),
* the 'merge' value for the new setting both overrides the preset and tells the
* UI to continue to display a merged set of the default values.
*/
if ( 'merge' === $prevent_override ) {
$override_preset = true;
} elseif ( is_bool( $prevent_override ) ) {
$override_preset = ! $prevent_override;
}
}

foreach ( static::VALID_ORIGINS as $origin ) {
$base_path = $node['path'];
Expand Down
2 changes: 1 addition & 1 deletion lib/class-wp-theme-json-schema-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ private static function migrate_v2_to_v3( $old ) {
if ( ! isset( $old['settings']['typography'] ) ) {
$new['settings']['typography'] = array();
}
$new['settings']['typography']['defaultFontSizes'] = false;
$new['settings']['typography']['defaultFontSizes'] = 'merge';

// Set the new version.
$new['version'] = 3;
Expand Down

0 comments on commit 0333ef6

Please sign in to comment.