diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 30c24173f4..b28cab8681 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -262,6 +262,35 @@ class WP_Theme_JSON { 'box-shadow' => array( 'shadow' ), ); + /** + * Indirect metadata for style properties that are not directly output. + * + * Each element maps from a CSS property name to an array of + * paths to the value in theme.json & block attributes. + * + * Indirect properties are not output directly by `compute_style_properties`, + * but are used elsewhere in the processing of global styles. The indirect + * property is used to validate whether or not a style value is allowed. + * + * @since 6.1.2 + * @var array + */ + const INDIRECT_PROPERTIES_METADATA = array( + 'gap' => array( + array( 'spacing', 'blockGap' ), + ), + 'column-gap' => array( + array( 'spacing', 'blockGap', 'left' ), + ), + 'row-gap' => array( + array( 'spacing', 'blockGap', 'top' ), + ), + 'max-width' => array( + array( 'layout', 'contentSize' ), + array( 'layout', 'wideSize' ), + ), + ); + /** * Protected style properties. * @@ -2949,6 +2978,10 @@ class WP_Theme_JSON { } } } + + // Ensure indirect properties not included in any `PRESETS_METADATA` value are allowed. + static::remove_indirect_properties( $input, $output ); + return $output; } @@ -2977,6 +3010,10 @@ class WP_Theme_JSON { } } } + + // Ensure indirect properties not handled by `compute_style_properties` are allowed. + static::remove_indirect_properties( $input, $output ); + return $output; } @@ -2995,6 +3032,29 @@ class WP_Theme_JSON { return ! empty( trim( $filtered ) ); } + /** + * Removes indirect properties from the given input node and + * sets in the given output node. + * + * @since 6.1.2 + * + * @param array $input Node to process. + * @param array $output The processed node. Passed by reference. + */ + private static function remove_indirect_properties( $input, &$output ) { + foreach ( static::INDIRECT_PROPERTIES_METADATA as $property => $paths ) { + foreach ( $paths as $path ) { + $value = _wp_array_get( $input, $path ); + if ( + is_string( $value ) && + static::is_safe_css_declaration( $property, $value ) + ) { + _wp_array_set( $output, $path, $value ); + } + } + } + } + /** * Returns the raw data. * diff --git a/wp-includes/version.php b/wp-includes/version.php index 7b8180cbc8..ed80ac9942 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-beta2-55344'; +$wp_version = '6.2-beta2-55345'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.