Changeset 55146
- Timestamp:
- 01/26/2023 06:37:47 PM (23 months ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/block-editor.php
r55086 r55146 217 217 'defaultEditorStyles' => $default_editor_styles, 218 218 'blockCategories' => get_default_block_categories(), 219 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ),220 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ),221 'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ),222 'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ),223 'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ),224 'enableCustomSpacing' => get_theme_support( 'custom-spacing' ),225 'enableCustomUnits' => get_theme_support( 'custom-units' ),226 219 'isRTL' => is_rtl(), 227 220 'imageDefaultSize' => $image_default_size, … … 234 227 ); 235 228 236 // Theme settings. 237 $color_palette = current( (array) get_theme_support( 'editor-color-palette' ) ); 238 if ( false !== $color_palette ) { 239 $editor_settings['colors'] = $color_palette; 240 } 241 242 $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) ); 243 if ( false !== $font_sizes ) { 244 $editor_settings['fontSizes'] = $font_sizes; 245 } 246 247 $gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) ); 248 if ( false !== $gradient_presets ) { 249 $editor_settings['gradients'] = $gradient_presets; 229 $theme_settings = get_classic_theme_supports_block_editor_settings(); 230 foreach ( $theme_settings as $key => $value ) { 231 $editor_settings[ $key ] = $value; 250 232 } 251 233 … … 695 677 return $styles; 696 678 } 679 680 /** 681 * Returns the classic theme supports settings for block editor. 682 * 683 * @since 6.2.0 684 * 685 * @return array The classic theme supports settings. 686 */ 687 function get_classic_theme_supports_block_editor_settings() { 688 $theme_settings = array( 689 'disableCustomColors' => get_theme_support( 'disable-custom-colors' ), 690 'disableCustomFontSizes' => get_theme_support( 'disable-custom-font-sizes' ), 691 'disableCustomGradients' => get_theme_support( 'disable-custom-gradients' ), 692 'disableLayoutStyles' => get_theme_support( 'disable-layout-styles' ), 693 'enableCustomLineHeight' => get_theme_support( 'custom-line-height' ), 694 'enableCustomSpacing' => get_theme_support( 'custom-spacing' ), 695 'enableCustomUnits' => get_theme_support( 'custom-units' ), 696 ); 697 698 // Theme settings. 699 $color_palette = current( (array) get_theme_support( 'editor-color-palette' ) ); 700 if ( false !== $color_palette ) { 701 $theme_settings['colors'] = $color_palette; 702 } 703 704 $font_sizes = current( (array) get_theme_support( 'editor-font-sizes' ) ); 705 if ( false !== $font_sizes ) { 706 $theme_settings['fontSizes'] = $font_sizes; 707 } 708 709 $gradient_presets = current( (array) get_theme_support( 'editor-gradient-presets' ) ); 710 if ( false !== $gradient_presets ) { 711 $theme_settings['gradients'] = $gradient_presets; 712 } 713 714 return $theme_settings; 715 } -
trunk/src/wp-includes/class-wp-theme-json-resolver.php
r55128 r55146 287 287 * and merge the static::$theme upon that. 288 288 */ 289 $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_ default_block_editor_settings() );289 $theme_support_data = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); 290 290 if ( ! wp_theme_has_theme_json() ) { 291 291 if ( ! isset( $theme_support_data['settings']['color'] ) ) { -
trunk/tests/phpunit/tests/blocks/editor.php
r54891 r55146 570 570 571 571 /** 572 * @ticket 57547 573 * 574 * @covers ::get_classic_theme_supports_block_editor_settings 575 */ 576 public function test_get_classic_theme_supports_block_editor_settings() { 577 $font_sizes = array( 578 array( 579 'name' => 'Small', 580 'size' => 12, 581 'slug' => 'small', 582 ), 583 array( 584 'name' => 'Regular', 585 'size' => 16, 586 'slug' => 'regular', 587 ), 588 ); 589 590 add_theme_support( 'editor-font-sizes', $font_sizes ); 591 $settings = get_classic_theme_supports_block_editor_settings(); 592 remove_theme_support( 'editor-font-sizes' ); 593 594 $this->assertFalse( $settings['disableCustomColors'], 'Value for array key "disableCustomColors" does not match expectations' ); 595 $this->assertFalse( $settings['disableCustomFontSizes'], 'Value for array key "disableCustomFontSizes" does not match expectations' ); 596 $this->assertFalse( $settings['disableCustomGradients'], 'Value for array key "disableCustomGradients" does not match expectations' ); 597 $this->assertFalse( $settings['disableLayoutStyles'], 'Value for array key "disableLayoutStyles" does not match expectations' ); 598 $this->assertFalse( $settings['enableCustomLineHeight'], 'Value for array key "enableCustomLineHeight" does not match expectations' ); 599 $this->assertFalse( $settings['enableCustomSpacing'], 'Value for array key "enableCustomSpacing" does not match expectations' ); 600 $this->assertFalse( $settings['enableCustomUnits'], 'Value for array key "enableCustomUnits" does not match expectations' ); 601 602 $this->assertSame( 603 $font_sizes, 604 $settings['fontSizes'], 605 'Value for array key "fontSizes" does not match expectations' 606 ); 607 } 608 609 /** 572 610 * Data provider. 573 611 * -
trunk/tests/phpunit/tests/theme/wpThemeJson.php
r55008 r55146 2646 2646 public function test_get_editor_settings_custom_units_can_be_disabled() { 2647 2647 add_theme_support( 'custom-units', array() ); 2648 $actual = WP_Theme_JSON::get_from_editor_settings( get_ default_block_editor_settings() );2648 $actual = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); 2649 2649 remove_theme_support( 'custom-units' ); 2650 2650 … … 2663 2663 public function test_get_editor_settings_custom_units_can_be_enabled() { 2664 2664 add_theme_support( 'custom-units' ); 2665 $actual = WP_Theme_JSON::get_from_editor_settings( get_ default_block_editor_settings() );2665 $actual = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); 2666 2666 remove_theme_support( 'custom-units' ); 2667 2667 … … 2680 2680 public function test_get_editor_settings_custom_units_can_be_filtered() { 2681 2681 add_theme_support( 'custom-units', 'rem', 'em' ); 2682 $actual = WP_Theme_JSON::get_from_editor_settings( get_ default_block_editor_settings() );2682 $actual = WP_Theme_JSON::get_from_editor_settings( get_classic_theme_supports_block_editor_settings() ); 2683 2683 remove_theme_support( 'custom-units' ); 2684 2684
Note: See TracChangeset
for help on using the changeset viewer.