Make WordPress Core

Changeset 57885


Ignore:
Timestamp:
03/27/2024 03:58:46 PM (2 years ago)
Author:
swissspidy
Message:

Editor: disable shadow.defaultPresets for classic themes.

With this change default shadow presets are never shown for classic themes, and classic themes have no options for adding custom ones.
This essentially reverts [57717] and [57827] / [57828], which had unintended consequences.

Props ajlende, oandregal, madhudollu, swissspidy, get_dave, andrewserong, desrosj.
Fixes #60815.

Location:
trunk
Files:
6 edited

Legend:

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

    r57260 r57885  
    312312                        }
    313313                        $theme_support_data['settings']['color']['defaultGradients'] = $default_gradients;
     314
     315                        if ( ! isset( $theme_support_data['settings']['shadow'] ) ) {
     316                                $theme_support_data['settings']['shadow'] = array();
     317                        }
     318                        /*
     319                         * Shadow presets are explicitly disabled for classic themes until a
     320                         * decision is made for whether the default presets should match the
     321                         * other presets or if they should be disabled by default in classic
     322                         * themes. See https://github.com/WordPress/gutenberg/issues/59989.
     323                         */
     324                        $theme_support_data['settings']['shadow']['defaultPresets'] = false;
    314325
    315326                        // Allow themes to enable link color setting via theme_support.
  • trunk/src/wp-includes/class-wp-theme-json.php

    r57751 r57885  
    659659         * @since 6.2.0 Added `dimensions.minHeight` and `position.sticky`.
    660660         * @since 6.4.0 Added `background.backgroundImage`.
    661          * @since 6.5.0 Added `background.backgroundSize`, `dimensions.aspectRatio`, and `shadow.defaultPresets`.
     661         * @since 6.5.0 Added `background.backgroundSize` and `dimensions.aspectRatio`.
    662662         * @var array
    663663         */
     
    680680                array( 'spacing', 'padding' ),
    681681                array( 'typography', 'lineHeight' ),
    682                 array( 'shadow', 'defaultPresets' ),
    683682        );
    684683
  • trunk/src/wp-includes/theme.json

    r57827 r57885  
    192192                },
    193193                "shadow": {
    194                         "defaultPresets": false,
     194                        "defaultPresets": true,
    195195                        "presets": [
    196196                                {
  • trunk/tests/phpunit/data/themedir1/block-theme/theme.json

    r57662 r57885  
    4949                        "padding": true,
    5050                        "blockGap": true
     51                },
     52                "shadow": {
     53                        "presets": [
     54                                {
     55                                        "name": "Natural",
     56                                        "slug": "natural",
     57                                        "shadow": "2px 2px 3px #000"
     58                                },
     59                                {
     60                                        "name": "Test",
     61                                        "slug": "test",
     62                                        "shadow": "2px 2px 3px #000"
     63                                }
     64                        ]
    5165                },
    5266                "blocks": {
  • trunk/tests/phpunit/tests/theme/wpThemeJson.php

    r57717 r57885  
    294294                                'lineHeight' => true,
    295295                        ),
    296                         'shadow'     => array(
    297                                 'defaultPresets' => true,
    298                         ),
    299296                        'blocks'     => array(
    300297                                'core/paragraph' => array(
     
    334331                                        'typography' => array(
    335332                                                'lineHeight' => false,
    336                                         ),
    337                                         'shadow'     => array(
    338                                                 'defaultPresets' => true,
    339333                                        ),
    340334                                ),
  • trunk/tests/phpunit/tests/theme/wpThemeJsonResolver.php

    r57662 r57885  
    202202                                        'blockGap' => true,
    203203                                ),
     204                                'shadow'     => array(
     205                                        'presets' => array(
     206                                                'theme' => array(
     207                                                        array(
     208                                                                'name'   => 'Natural',
     209                                                                'slug'   => 'natural',
     210                                                                'shadow' => '2px 2px 3px #000',
     211                                                        ),
     212                                                        array(
     213                                                                'name'   => 'Test',
     214                                                                'slug'   => 'test',
     215                                                                'shadow' => '2px 2px 3px #000',
     216                                                        ),
     217                                                ),
     218                                        ),
     219                                ),
    204220                                'blocks'     => array(
    205221                                        'core/paragraph' => array(
     
    556572                                                        'slug' => 'custom',
    557573                                                        'size' => '100px',
     574                                                ),
     575                                        ),
     576                                ),
     577                        ),
     578                        'shadow'     => array(
     579                                'presets' => array(
     580                                        'theme' => array(
     581                                                array(
     582                                                        'name'   => 'Natural',
     583                                                        'slug'   => 'natural',
     584                                                        'shadow' => '2px 2px 3px #000',
     585                                                ),
     586                                                array(
     587                                                        'name'   => 'Test',
     588                                                        'slug'   => 'test',
     589                                                        'shadow' => '2px 2px 3px #000',
    558590                                                ),
    559591                                        ),
     
    10711103                );
    10721104        }
     1105
     1106        /**
     1107         * @ticket 60815
     1108         */
     1109        public function test_theme_shadow_presets_do_not_override_default_shadow_presets() {
     1110                switch_theme( 'block-theme' );
     1111
     1112                $theme_json_resolver = new WP_Theme_JSON_Resolver();
     1113                $theme_json          = $theme_json_resolver->get_merged_data();
     1114                $actual_settings     = $theme_json->get_settings()['shadow']['presets'];
     1115
     1116                $expected_settings = array(
     1117                        'default' => array(
     1118                                array(
     1119                                        'name'   => 'Natural',
     1120                                        'shadow' => '6px 6px 9px rgba(0, 0, 0, 0.2)',
     1121                                        'slug'   => 'natural',
     1122                                ),
     1123                                array(
     1124                                        'name'   => 'Deep',
     1125                                        'shadow' => '12px 12px 50px rgba(0, 0, 0, 0.4)',
     1126                                        'slug'   => 'deep',
     1127                                ),
     1128                                array(
     1129                                        'name'   => 'Sharp',
     1130                                        'shadow' => '6px 6px 0px rgba(0, 0, 0, 0.2)',
     1131                                        'slug'   => 'sharp',
     1132                                ),
     1133                                array(
     1134                                        'name'   => 'Outlined',
     1135                                        'shadow' => '6px 6px 0px -3px rgba(255, 255, 255, 1), 6px 6px rgba(0, 0, 0, 1)',
     1136                                        'slug'   => 'outlined',
     1137                                ),
     1138                                array(
     1139                                        'name'   => 'Crisp',
     1140                                        'shadow' => '6px 6px 0px rgba(0, 0, 0, 1)',
     1141                                        'slug'   => 'crisp',
     1142                                ),
     1143                        ),
     1144                        'theme'   => array(
     1145                                array(
     1146                                        'name'   => 'Test',
     1147                                        'shadow' => '2px 2px 3px #000',
     1148                                        'slug'   => 'test',
     1149                                ),
     1150                        ),
     1151                );
     1152
     1153                wp_recursive_ksort( $actual_settings );
     1154                wp_recursive_ksort( $expected_settings );
     1155
     1156                $this->assertSame(
     1157                        $expected_settings,
     1158                        $actual_settings
     1159                );
     1160        }
     1161
     1162        /**
     1163         * @ticket 60815
     1164         */
     1165        public function test_shadow_default_presets_value_for_block_and_classic_themes() {
     1166                $theme_json_resolver = new WP_Theme_JSON_Resolver();
     1167                $theme_json          = $theme_json_resolver->get_merged_data();
     1168
     1169                $default_presets_for_classic = $theme_json->get_settings()['shadow']['defaultPresets'];
     1170                $this->assertFalse( $default_presets_for_classic );
     1171
     1172                switch_theme( 'block-theme' );
     1173                $theme_json_resolver = new WP_Theme_JSON_Resolver();
     1174                $theme_json          = $theme_json_resolver->get_merged_data();
     1175
     1176                $default_presets_for_block = $theme_json->get_settings()['shadow']['defaultPresets'];
     1177                $this->assertTrue( $default_presets_for_block );
     1178        }
    10731179}
Note: See TracChangeset for help on using the changeset viewer.