Make WordPress Core


Ignore:
Timestamp:
06/05/2024 08:11:03 AM (18 months ago)
Author:
oandregal
Message:

Editor: improve code quality of theme.json classes.

Follow-up to [58328], #61282.

Props ajlende, ramonopoly.
Fixes #61370.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-theme-json-schema.php

    r58328 r58339  
    5353            case 1:
    5454                $theme_json = self::migrate_v1_to_v2( $theme_json );
    55                 // no break
     55                // Deliberate fall through. Once migrated to v2, also migrate to v3.
    5656            case 2:
    5757                $theme_json = self::migrate_v2_to_v3( $theme_json );
    58                 // no break
    5958        }
    6059
     
    9594     * Migrates from v2 to v3.
    9695     *
    97      * - Sets settings.typography.defaultFontSizes to false.
     96     * - Sets settings.typography.defaultFontSizes to false if settings.typography.fontSizes are defined.
     97     * - Sets settings.spacing.defaultSpacingSizes to false if settings.spacing.spacingSizes are defined.
     98     * - Prevents settings.spacing.spacingSizes from merging with settings.spacing.spacingScale by
     99     *   unsetting spacingScale when spacingSizes are defined.
    98100     *
    99101     * @since 6.6.0
     
    130132         */
    131133        if ( isset( $old['settings']['typography']['fontSizes'] ) ) {
    132             if ( ! isset( $new['settings'] ) ) {
    133                 $new['settings'] = array();
    134             }
    135             if ( ! isset( $new['settings']['typography'] ) ) {
    136                 $new['settings']['typography'] = array();
    137             }
    138134            $new['settings']['typography']['defaultFontSizes'] = false;
    139135        }
     
    149145            isset( $old['settings']['spacing']['spacingScale'] )
    150146        ) {
    151             if ( ! isset( $new['settings'] ) ) {
    152                 $new['settings'] = array();
    153             }
    154             if ( ! isset( $new['settings']['spacing'] ) ) {
    155                 $new['settings']['spacing'] = array();
    156             }
    157147            $new['settings']['spacing']['defaultSpacingSizes'] = false;
    158148        }
Note: See TracChangeset for help on using the changeset viewer.