Make WordPress Core


Ignore:
Timestamp:
03/27/2024 03:58:46 PM (22 months 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.