Changeset 58339
- Timestamp:
- 06/05/2024 08:11:03 AM (10 months ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r58328 r58339 288 288 $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); 289 289 if ( ! wp_theme_has_theme_json() ) { 290 if ( ! isset( $theme_support_data['settings']['color'] ) ) { 291 $theme_support_data['settings']['color'] = array(); 292 } 293 294 $default_palette = false; 295 if ( current_theme_supports( 'default-color-palette' ) ) { 296 $default_palette = true; 297 } 298 if ( ! isset( $theme_support_data['settings']['color']['palette'] ) ) { 299 // If the theme does not have any palette, we still want to show the core one. 300 $default_palette = true; 301 } 302 $theme_support_data['settings']['color']['defaultPalette'] = $default_palette; 303 304 $default_gradients = false; 305 if ( current_theme_supports( 'default-gradient-presets' ) ) { 306 $default_gradients = true; 307 } 308 if ( ! isset( $theme_support_data['settings']['color']['gradients'] ) ) { 309 // If the theme does not have any gradients, we still want to show the core ones. 310 $default_gradients = true; 311 } 312 $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients; 313 314 if ( ! isset( $theme_support_data['settings']['typography'] ) ) { 315 $theme_support_data['settings']['typography'] = array(); 316 } 317 $default_font_sizes = false; 318 if ( current_theme_supports( 'default-font-sizes' ) ) { 319 $default_font_sizes = true; 320 } 321 if ( ! isset( $theme_support_data['settings']['typography']['fontSizes'] ) ) { 322 // If the theme does not have any font sizes, we still want to show the core one. 323 $default_font_sizes = true; 324 } 325 $theme_support_data['settings']['typography']['defaultFontSizes'] = $default_font_sizes; 326 327 if ( ! isset( $theme_support_data['settings']['spacing'] ) ) { 328 $theme_support_data['settings']['spacing'] = array(); 329 } 330 $default_spacing_sizes = false; 331 if ( current_theme_supports( 'default-spacing-sizes' ) ) { 332 $default_spacing_sizes = true; 333 } 334 if ( ! isset( $theme_support_data['settings']['spacing']['spacingSizes'] ) ) { 335 // If the theme does not have any spacing sizes, we still want to show the core one. 336 $default_spacing_sizes = true; 337 } 338 $theme_support_data['settings']['spacing']['defaultSpacingSizes'] = $default_spacing_sizes; 339 340 if ( ! isset( $theme_support_data['settings']['shadow'] ) ) { 341 $theme_support_data['settings']['shadow'] = array(); 342 } 290 /* 291 * Unlike block themes, classic themes without a theme.json disable 292 * default presets when custom preset theme support is added. This 293 * behavior can be overridden by using the corresponding default 294 * preset theme support. 295 */ 296 $theme_support_data['settings']['color']['defaultPalette'] = 297 ! isset( $theme_support_data['settings']['color']['palette'] ) || 298 current_theme_supports( 'default-color-palette' ); 299 $theme_support_data['settings']['color']['defaultGradients'] = 300 ! isset( $theme_support_data['settings']['color']['gradients'] ) || 301 current_theme_supports( 'default-gradient-presets' ); 302 $theme_support_data['settings']['typography']['defaultFontSizes'] = 303 ! isset( $theme_support_data['settings']['typography']['fontSizes'] ) || 304 current_theme_supports( 'default-font-sizes' ); 305 $theme_support_data['settings']['spacing']['defaultSpacingSizes'] = 306 ! isset( $theme_support_data['settings']['spacing']['spacingSizes'] ) || 307 current_theme_supports( 'default-spacing-sizes' ); 308 343 309 /* 344 310 * Shadow presets are explicitly disabled for classic themes until a -
trunk/src/wp-includes/class-wp-theme-json-schema.php
r58328 r58339 53 53 case 1: 54 54 $theme_json = self::migrate_v1_to_v2( $theme_json ); 55 // no break55 // Deliberate fall through. Once migrated to v2, also migrate to v3. 56 56 case 2: 57 57 $theme_json = self::migrate_v2_to_v3( $theme_json ); 58 // no break59 58 } 60 59 … … 95 94 * Migrates from v2 to v3. 96 95 * 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. 98 100 * 99 101 * @since 6.6.0 … … 130 132 */ 131 133 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 }138 134 $new['settings']['typography']['defaultFontSizes'] = false; 139 135 } … … 149 145 isset( $old['settings']['spacing']['spacingScale'] ) 150 146 ) { 151 if ( ! isset( $new['settings'] ) ) {152 $new['settings'] = array();153 }154 if ( ! isset( $new['settings']['spacing'] ) ) {155 $new['settings']['spacing'] = array();156 }157 147 $new['settings']['spacing']['defaultSpacingSizes'] = false; 158 148 } -
trunk/src/wp-includes/class-wp-theme-json.php
r58328 r58339 3525 3525 // Deprecated theme supports. 3526 3526 if ( isset( $settings['disableCustomColors'] ) ) { 3527 if ( ! isset( $theme_settings['settings']['color'] ) ) {3528 $theme_settings['settings']['color'] = array();3529 }3530 3527 $theme_settings['settings']['color']['custom'] = ! $settings['disableCustomColors']; 3531 3528 } 3532 3529 3533 3530 if ( isset( $settings['disableCustomGradients'] ) ) { 3534 if ( ! isset( $theme_settings['settings']['color'] ) ) {3535 $theme_settings['settings']['color'] = array();3536 }3537 3531 $theme_settings['settings']['color']['customGradient'] = ! $settings['disableCustomGradients']; 3538 3532 } 3539 3533 3540 3534 if ( isset( $settings['disableCustomFontSizes'] ) ) { 3541 if ( ! isset( $theme_settings['settings']['typography'] ) ) {3542 $theme_settings['settings']['typography'] = array();3543 }3544 3535 $theme_settings['settings']['typography']['customFontSize'] = ! $settings['disableCustomFontSizes']; 3545 3536 } 3546 3537 3547 3538 if ( isset( $settings['enableCustomLineHeight'] ) ) { 3548 if ( ! isset( $theme_settings['settings']['typography'] ) ) {3549 $theme_settings['settings']['typography'] = array();3550 }3551 3539 $theme_settings['settings']['typography']['lineHeight'] = $settings['enableCustomLineHeight']; 3552 3540 } 3553 3541 3554 3542 if ( isset( $settings['enableCustomUnits'] ) ) { 3555 if ( ! isset( $theme_settings['settings']['spacing'] ) ) {3556 $theme_settings['settings']['spacing'] = array();3557 }3558 3543 $theme_settings['settings']['spacing']['units'] = ( true === $settings['enableCustomUnits'] ) ? 3559 3544 array( 'px', 'em', 'rem', 'vh', 'vw', '%' ) : … … 3562 3547 3563 3548 if ( isset( $settings['colors'] ) ) { 3564 if ( ! isset( $theme_settings['settings']['color'] ) ) {3565 $theme_settings['settings']['color'] = array();3566 }3567 3549 $theme_settings['settings']['color']['palette'] = $settings['colors']; 3568 3550 } 3569 3551 3570 3552 if ( isset( $settings['gradients'] ) ) { 3571 if ( ! isset( $theme_settings['settings']['color'] ) ) {3572 $theme_settings['settings']['color'] = array();3573 }3574 3553 $theme_settings['settings']['color']['gradients'] = $settings['gradients']; 3575 3554 } … … 3583 3562 } 3584 3563 } 3585 if ( ! isset( $theme_settings['settings']['typography'] ) ) {3586 $theme_settings['settings']['typography'] = array();3587 }3588 3564 $theme_settings['settings']['typography']['fontSizes'] = $font_sizes; 3589 3565 } 3590 3566 3591 3567 if ( isset( $settings['enableCustomSpacing'] ) ) { 3592 if ( ! isset( $theme_settings['settings']['spacing'] ) ) {3593 $theme_settings['settings']['spacing'] = array();3594 }3595 3568 $theme_settings['settings']['spacing']['padding'] = $settings['enableCustomSpacing']; 3596 3569 } 3597 3570 3598 3571 if ( isset( $settings['spacingSizes'] ) ) { 3599 if ( ! isset( $theme_settings['settings']['spacing'] ) ) {3600 $theme_settings['settings']['spacing'] = array();3601 }3602 3572 $theme_settings['settings']['spacing']['spacingSizes'] = $settings['spacingSizes']; 3603 3573 } … … 3776 3746 * 3777 3747 * @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. 3782 3751 * 3783 3752 * @return null|void
Note: See TracChangeset
for help on using the changeset viewer.