From 2ff5a8027f55a5740f76381b67974be6227a5b9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9?= <583546+oandregal@users.noreply.github.com> Date: Thu, 15 Dec 2022 12:29:49 +0100 Subject: [PATCH] Port compat/6.2 dimensions See https://github.com/WordPress/gutenberg/pull/45300 --- .../wordpress-6.2/class-wp-theme-json-6-2.php | 149 ------------------ .../class-wp-theme-json-gutenberg.php | 11 ++ 2 files changed, 11 insertions(+), 149 deletions(-) diff --git a/lib/compat/wordpress-6.2/class-wp-theme-json-6-2.php b/lib/compat/wordpress-6.2/class-wp-theme-json-6-2.php index fe01eb273066e2..41d7d952c4cfdf 100644 --- a/lib/compat/wordpress-6.2/class-wp-theme-json-6-2.php +++ b/lib/compat/wordpress-6.2/class-wp-theme-json-6-2.php @@ -15,87 +15,6 @@ * @access private */ class WP_Theme_JSON_6_2 extends WP_Theme_JSON_6_1 { - const APPEARANCE_TOOLS_OPT_INS = array( - array( 'border', 'color' ), - array( 'border', 'radius' ), - array( 'border', 'style' ), - array( 'border', 'width' ), - array( 'color', 'link' ), - array( 'dimensions', 'minHeight' ), - array( 'spacing', 'blockGap' ), - array( 'spacing', 'margin' ), - array( 'spacing', 'padding' ), - array( 'typography', 'lineHeight' ), - ); - - /** - * Metadata for style properties. - * - * Each element is a direct mapping from the CSS property name to the - * path to the value in theme.json & block attributes. - * - * @since 5.8.0 - * @since 5.9.0 Added the `border-*`, `font-family`, `font-style`, `font-weight`, - * `letter-spacing`, `margin-*`, `padding-*`, `--wp--style--block-gap`, - * `text-decoration`, `text-transform`, and `filter` properties, - * simplified the metadata structure. - * @since 6.1.0 Added the `border-*-color`, `border-*-width`, `border-*-style`, - * `--wp--style--root--padding-*`, and `box-shadow` properties, - * removed the `--wp--style--block-gap` property. - * @since 6.2.0 Added `min-height`. - * @var array - */ - const PROPERTIES_METADATA = array( - 'background' => array( 'color', 'gradient' ), - 'background-color' => array( 'color', 'background' ), - 'border-radius' => array( 'border', 'radius' ), - 'border-top-left-radius' => array( 'border', 'radius', 'topLeft' ), - 'border-top-right-radius' => array( 'border', 'radius', 'topRight' ), - 'border-bottom-left-radius' => array( 'border', 'radius', 'bottomLeft' ), - 'border-bottom-right-radius' => array( 'border', 'radius', 'bottomRight' ), - 'border-color' => array( 'border', 'color' ), - 'border-width' => array( 'border', 'width' ), - 'border-style' => array( 'border', 'style' ), - 'border-top-color' => array( 'border', 'top', 'color' ), - 'border-top-width' => array( 'border', 'top', 'width' ), - 'border-top-style' => array( 'border', 'top', 'style' ), - 'border-right-color' => array( 'border', 'right', 'color' ), - 'border-right-width' => array( 'border', 'right', 'width' ), - 'border-right-style' => array( 'border', 'right', 'style' ), - 'border-bottom-color' => array( 'border', 'bottom', 'color' ), - 'border-bottom-width' => array( 'border', 'bottom', 'width' ), - 'border-bottom-style' => array( 'border', 'bottom', 'style' ), - 'border-left-color' => array( 'border', 'left', 'color' ), - 'border-left-width' => array( 'border', 'left', 'width' ), - 'border-left-style' => array( 'border', 'left', 'style' ), - 'color' => array( 'color', 'text' ), - 'font-family' => array( 'typography', 'fontFamily' ), - 'font-size' => array( 'typography', 'fontSize' ), - 'font-style' => array( 'typography', 'fontStyle' ), - 'font-weight' => array( 'typography', 'fontWeight' ), - 'letter-spacing' => array( 'typography', 'letterSpacing' ), - 'line-height' => array( 'typography', 'lineHeight' ), - 'margin' => array( 'spacing', 'margin' ), - 'margin-top' => array( 'spacing', 'margin', 'top' ), - 'margin-right' => array( 'spacing', 'margin', 'right' ), - 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ), - 'margin-left' => array( 'spacing', 'margin', 'left' ), - 'min-height' => array( 'dimensions', 'minHeight' ), - 'padding' => array( 'spacing', 'padding' ), - 'padding-top' => array( 'spacing', 'padding', 'top' ), - 'padding-right' => array( 'spacing', 'padding', 'right' ), - 'padding-bottom' => array( 'spacing', 'padding', 'bottom' ), - 'padding-left' => array( 'spacing', 'padding', 'left' ), - '--wp--style--root--padding' => array( 'spacing', 'padding' ), - '--wp--style--root--padding-top' => array( 'spacing', 'padding', 'top' ), - '--wp--style--root--padding-right' => array( 'spacing', 'padding', 'right' ), - '--wp--style--root--padding-bottom' => array( 'spacing', 'padding', 'bottom' ), - '--wp--style--root--padding-left' => array( 'spacing', 'padding', 'left' ), - 'text-decoration' => array( 'typography', 'textDecoration' ), - 'text-transform' => array( 'typography', 'textTransform' ), - 'filter' => array( 'filter', 'duotone' ), - 'box-shadow' => array( 'shadow' ), - ); /** * Indirect metadata for style properties that are not directly output. @@ -116,74 +35,6 @@ class WP_Theme_JSON_6_2 extends WP_Theme_JSON_6_1 { 'row-gap' => array( 'spacing', 'blockGap', 'top' ), ); - /** - * The valid properties under the settings key. - * - * @since 5.8.0 As `ALLOWED_SETTINGS`. - * @since 5.9.0 Renamed from `ALLOWED_SETTINGS` to `VALID_SETTINGS`, - * added new properties for `border`, `color`, `spacing`, - * 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`. - * @var array - */ - const VALID_SETTINGS = array( - 'appearanceTools' => null, - 'useRootPaddingAwareAlignments' => null, - 'border' => array( - 'color' => null, - 'radius' => null, - 'style' => null, - 'width' => null, - ), - 'color' => array( - 'background' => null, - 'custom' => null, - 'customDuotone' => null, - 'customGradient' => null, - 'defaultDuotone' => null, - 'defaultGradients' => null, - 'defaultPalette' => null, - 'duotone' => null, - 'gradients' => null, - 'link' => null, - 'palette' => null, - 'text' => null, - ), - 'custom' => null, - 'dimensions' => array( - 'minHeight' => null, - ), - 'layout' => array( - 'contentSize' => null, - 'definitions' => null, - 'wideSize' => null, - ), - 'spacing' => array( - 'customSpacingSize' => null, - 'spacingSizes' => null, - 'spacingScale' => null, - 'blockGap' => null, - 'margin' => null, - 'padding' => null, - 'units' => null, - ), - 'typography' => array( - 'fluid' => null, - 'customFontSize' => null, - 'dropCap' => null, - 'fontFamilies' => null, - 'fontSizes' => null, - 'fontStyle' => null, - 'fontWeight' => null, - 'letterSpacing' => null, - 'lineHeight' => null, - 'textDecoration' => null, - 'textTransform' => null, - ), - ); - /** * The valid properties under the styles key. * diff --git a/lib/compat/wordpress-6.2/class-wp-theme-json-gutenberg.php b/lib/compat/wordpress-6.2/class-wp-theme-json-gutenberg.php index ee6d669544e65d..79308e0593fe68 100644 --- a/lib/compat/wordpress-6.2/class-wp-theme-json-gutenberg.php +++ b/lib/compat/wordpress-6.2/class-wp-theme-json-gutenberg.php @@ -192,6 +192,7 @@ class WP_Theme_JSON_Gutenberg { * @since 6.1.0 Added the `border-*-color`, `border-*-width`, `border-*-style`, * `--wp--style--root--padding-*`, and `box-shadow` properties, * removed the `--wp--style--block-gap` property. + * @since 6.2.0 Added `min-height`. * @var array */ const PROPERTIES_METADATA = array( @@ -229,6 +230,7 @@ class WP_Theme_JSON_Gutenberg { 'margin-right' => array( 'spacing', 'margin', 'right' ), 'margin-bottom' => array( 'spacing', 'margin', 'bottom' ), 'margin-left' => array( 'spacing', 'margin', 'left' ), + 'min-height' => array( 'dimensions', 'minHeight' ), 'outline-color' => array( 'outline', 'color' ), 'outline-offset' => array( 'outline', 'offset' ), 'outline-style' => array( 'outline', 'style' ), @@ -291,6 +293,7 @@ class WP_Theme_JSON_Gutenberg { * 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`. * @var array */ const VALID_SETTINGS = array( @@ -317,6 +320,9 @@ class WP_Theme_JSON_Gutenberg { 'text' => null, ), 'custom' => null, + 'dimensions' => array( + 'minHeight' => null, + ), 'layout' => array( 'contentSize' => null, 'definitions' => null, @@ -356,6 +362,7 @@ class WP_Theme_JSON_Gutenberg { * @since 6.1.0 Added new side properties for `border`, * added new property `shadow`, * updated `blockGap` to be allowed at any level. + * @since 6.2.0 Added `dimensions.minHeight`. * @var array */ const VALID_STYLES = array( @@ -374,6 +381,9 @@ class WP_Theme_JSON_Gutenberg { 'gradient' => null, 'text' => null, ), + 'dimensions' => array( + 'minHeight' => null, + ), 'filter' => array( 'duotone' => null, ), @@ -492,6 +502,7 @@ public static function get_element_class_name( $element ) { array( 'border', 'style' ), array( 'border', 'width' ), array( 'color', 'link' ), + array( 'dimensions', 'minHeight' ), array( 'spacing', 'blockGap' ), array( 'spacing', 'margin' ), array( 'spacing', 'padding' ),