From 263ef5505d272274d648bdd847d2b3be7172cbb1 Mon Sep 17 00:00:00 2001 From: hellofromTonya Date: Wed, 1 Feb 2023 18:07:12 +0000 Subject: [PATCH] Themes: Add shadow presets support for theme.json. Adds shadow presets support for `theme.json` within the `WP_Theme_JSON` by * Adding it to presets metadata and valid settings. * Defining the default shadow presets in Core's `theme.json`. Includes PHPUnit tests. References: * [https://github.com/WordPress/gutenberg/pull/46813 Gutenberg PR 46813] * [https://github.com/WordPress/gutenberg/pull/47272 Gutenberg PR 47272] Follow-up to [54162], [52049], [50973]. Props madhudollu, mamaduka, oandregal, scruffian, hellofromTonya. Fixes #57559. Built from https://develop.svn.wordpress.org/trunk@55176 git-svn-id: http://core.svn.wordpress.org/trunk@54709 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 16 +++++++++++++++- wp-includes/theme.json | 14 ++++++++++++++ wp-includes/version.php | 2 +- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 207067ea9c..71801df2af 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -115,6 +115,7 @@ class WP_Theme_JSON { * `use_default_names` preset key, and simplified the metadata structure. * @since 6.0.0 Replaced `override` with `prevent_override` and updated the * `prevent_override` value for `color.duotone` to use `color.defaultDuotone`. + * @since 6.2.0 Added 'shadow' presets. * @var array */ const PRESETS_METADATA = array( @@ -176,6 +177,15 @@ class WP_Theme_JSON { 'classes' => array(), 'properties' => array( 'padding', 'margin' ), ), + array( + 'path' => array( 'shadow', 'presets' ), + 'prevent_override' => array( 'shadow', 'defaultPresets' ), + 'use_default_names' => false, + 'value_key' => 'shadow', + 'css_vars' => '--wp--preset--shadow--$slug', + 'classes' => array(), + 'properties' => array( 'box-shadow' ), + ), ); /** @@ -294,7 +304,7 @@ class WP_Theme_JSON { * and `typography`, and renamed others according to the new schema. * @since 6.0.0 Added `color.defaultDuotone`. * @since 6.1.0 Added `layout.definitions` and `useRootPaddingAwareAlignments`. - * @since 6.2.0 Added `dimensions.minHeight`. + * @since 6.2.0 Added `dimensions.minHeight`, 'shadow.presets', and 'shadow.defaultPresets'. * @var array */ const VALID_SETTINGS = array( @@ -338,6 +348,10 @@ class WP_Theme_JSON { 'padding' => null, 'units' => null, ), + 'shadow' => array( + 'presets' => null, + 'defaultPresets' => null, + ), 'typography' => array( 'fluid' => null, 'customFontSize' => null, diff --git a/wp-includes/theme.json b/wp-includes/theme.json index 40432cedf3..512f6d796c 100644 --- a/wp-includes/theme.json +++ b/wp-includes/theme.json @@ -325,6 +325,20 @@ } } }, + "shadow": { + "presets": [ + { + "name": "Natural", + "slug": "natural", + "shadow": "0 .2rem .3rem 0 rgba(0,0,0, 0.3), 0 .5rem .6rem 0 rgba(0,0,0, 0.4)" + }, + { + "name": "Sharp", + "slug": "sharp", + "shadow": ".5rem .5rem 0 0 rgba(0,0,0, 0.4)" + } + ] + }, "spacing": { "blockGap": null, "margin": false, diff --git a/wp-includes/version.php b/wp-includes/version.php index 915aad5576..f386091c48 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55175'; +$wp_version = '6.2-alpha-55176'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.