Make WordPress Core


Ignore:
Timestamp:
06/05/2024 08:11:03 AM (11 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.php

    r58328 r58339  
    35253525        // Deprecated theme supports.
    35263526        if ( isset( $settings['disableCustomColors'] ) ) {
    3527             if ( ! isset( $theme_settings['settings']['color'] ) ) {
    3528                 $theme_settings['settings']['color'] = array();
    3529             }
    35303527            $theme_settings['settings']['color']['custom'] = ! $settings['disableCustomColors'];
    35313528        }
    35323529
    35333530        if ( isset( $settings['disableCustomGradients'] ) ) {
    3534             if ( ! isset( $theme_settings['settings']['color'] ) ) {
    3535                 $theme_settings['settings']['color'] = array();
    3536             }
    35373531            $theme_settings['settings']['color']['customGradient'] = ! $settings['disableCustomGradients'];
    35383532        }
    35393533
    35403534        if ( isset( $settings['disableCustomFontSizes'] ) ) {
    3541             if ( ! isset( $theme_settings['settings']['typography'] ) ) {
    3542                 $theme_settings['settings']['typography'] = array();
    3543             }
    35443535            $theme_settings['settings']['typography']['customFontSize'] = ! $settings['disableCustomFontSizes'];
    35453536        }
    35463537
    35473538        if ( isset( $settings['enableCustomLineHeight'] ) ) {
    3548             if ( ! isset( $theme_settings['settings']['typography'] ) ) {
    3549                 $theme_settings['settings']['typography'] = array();
    3550             }
    35513539            $theme_settings['settings']['typography']['lineHeight'] = $settings['enableCustomLineHeight'];
    35523540        }
    35533541
    35543542        if ( isset( $settings['enableCustomUnits'] ) ) {
    3555             if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
    3556                 $theme_settings['settings']['spacing'] = array();
    3557             }
    35583543            $theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ?
    35593544                array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) :
     
    35623547
    35633548        if ( isset( $settings['colors'] ) ) {
    3564             if ( ! isset( $theme_settings['settings']['color'] ) ) {
    3565                 $theme_settings['settings']['color'] = array();
    3566             }
    35673549            $theme_settings['settings']['color']['palette'] = $settings['colors'];
    35683550        }
    35693551
    35703552        if ( isset( $settings['gradients'] ) ) {
    3571             if ( ! isset( $theme_settings['settings']['color'] ) ) {
    3572                 $theme_settings['settings']['color'] = array();
    3573             }
    35743553            $theme_settings['settings']['color']['gradients'] = $settings['gradients'];
    35753554        }
     
    35833562                }
    35843563            }
    3585             if ( ! isset( $theme_settings['settings']['typography'] ) ) {
    3586                 $theme_settings['settings']['typography'] = array();
    3587             }
    35883564            $theme_settings['settings']['typography']['fontSizes'] = $font_sizes;
    35893565        }
    35903566
    35913567        if ( isset( $settings['enableCustomSpacing'] ) ) {
    3592             if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
    3593                 $theme_settings['settings']['spacing'] = array();
    3594             }
    35953568            $theme_settings['settings']['spacing']['padding'] = $settings['enableCustomSpacing'];
    35963569        }
    35973570
    35983571        if ( isset( $settings['spacingSizes'] ) ) {
    3599             if ( ! isset( $theme_settings['settings']['spacing'] ) ) {
    3600                 $theme_settings['settings']['spacing'] = array();
    3601             }
    36023572            $theme_settings['settings']['spacing']['spacingSizes'] = $settings['spacingSizes'];
    36033573        }
     
    37763746     *
    37773747     * @since 6.1.0
    3778      * @deprecated 6.6.0
    3779      *
    3780      * @param string $origin Optional. What source of data to set the spacing sizes for.
    3781      *                       One of 'default', 'theme', or 'custom'. Default 'default'.
     3748     * @deprecated 6.6.0 No longer used as the spacingSizes are automatically
     3749     *                   generated in the constructor and merge methods instead
     3750     *                   of manually after instantiation.
    37823751     *
    37833752     * @return null|void
Note: See TracChangeset for help on using the changeset viewer.