Skip to content

Commit

Permalink
Remove the merge keyword that is no longer needed since #58951
Browse files Browse the repository at this point in the history
  • Loading branch information
ajlende committed Feb 14, 2024
1 parent 10081c1 commit 214e8f3
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 29 deletions.
10 changes: 0 additions & 10 deletions lib/class-wp-theme-json-gutenberg.php
Original file line number Diff line number Diff line change
Expand Up @@ -2771,16 +2771,6 @@ public function merge( $incoming ) {
$prevent_override = $preset_metadata['prevent_override'];
if ( is_array( $prevent_override ) ) {
$prevent_override = _wp_array_get( $this->theme_json['settings'], $preset_metadata['prevent_override'] );

/*
* For backwards compatibility with presets converting from a hardcoded `false`
* 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 ) {
$prevent_override = false;
}
}

foreach ( static::VALID_ORIGINS as $origin ) {
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 @@ -116,7 +116,7 @@ private static function migrate_v2_to_v3( $old ) {
if ( ! isset( $old['settings']['typography'] ) ) {
$new['settings']['typography'] = array();
}
$new['settings']['typography']['defaultFontSizes'] = 'merge';
$new['settings']['typography']['defaultFontSizes'] = false;

// Set the new version.
$new['version'] = 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import TextTransformControl from '../text-transform-control';
import TextDecorationControl from '../text-decoration-control';
import WritingModeControl from '../writing-mode-control';
import { getValueFromVariable, TOOLSPANEL_DROPDOWNMENU_PROPS } from './utils';
import { setImmutably, uniqByProperty } from '../../utils/object';
import { setImmutably } from '../../utils/object';

const MIN_TEXT_COLUMNS = 1;
const MAX_TEXT_COLUMNS = 6;
Expand Down Expand Up @@ -111,21 +111,6 @@ function useHasTextColumnsControl( settings ) {
* @return {Array} The merged font sizes.
*/
function getMergedFontSizes( settings ) {
/*
* Backward compatibility for theme.json v2 is triggered by the 'merge'
* value added during the migration process. The old behavior that didn't
* match the other preset controls was to list the partially overridden
* default font sizes. The new behavior either shows all the default font
* sizes or none of them.
*/
if ( settings?.typography?.defaultFontSizes === 'merge' ) {
const fontSizes = settings?.typography?.fontSizes;
const mergedFontSizes = fontSizes
? mergeOrigins( fontSizes ).toReversed() // New array because mergeOrigins result is cached.
: [];
return uniqByProperty( mergedFontSizes, 'slug' ).reverse(); // In-place reverse to save memory.
}

const fontSizes = settings?.typography?.fontSizes;
const defaultFontSizesEnabled = !! settings?.typography?.defaultFontSizes;
return [
Expand Down
4 changes: 2 additions & 2 deletions phpunit/class-wp-theme-json-schema-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public function test_migrate_v1_to_latest() {
'width' => false,
),
'typography' => array(
'defaultFontSizes' => 'merge',
'defaultFontSizes' => false,
'fontStyle' => false,
'fontWeight' => false,
'letterSpacing' => false,
Expand Down Expand Up @@ -293,7 +293,7 @@ public function test_migrate_v2_to_latest() {
'width' => false,
),
'typography' => array(
'defaultFontSizes' => 'merge',
'defaultFontSizes' => false,
'fontStyle' => false,
'fontWeight' => false,
'letterSpacing' => false,
Expand Down

0 comments on commit 214e8f3

Please sign in to comment.