From c382748f6c37b9374e6c74fbceb145c4486f960f Mon Sep 17 00:00:00 2001 From: audrasjb Date: Wed, 4 Oct 2023 19:10:26 +0000 Subject: [PATCH] Editor: Preserve block style variations when securing theme. Adds the ability to process block style variations to the `remove_insecure_properties` function of theme json class. Props dsas, ramonopoly, dean, isabel_brison, joemcgill, audrasjb. Merges [56502] and [56778] to the 6.3 branch. Fixes #59108. Built from https://develop.svn.wordpress.org/branches/6.3@56779 git-svn-id: http://core.svn.wordpress.org/branches/6.3@56291 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-theme-json.php | 15 +++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/wp-includes/class-wp-theme-json.php b/wp-includes/class-wp-theme-json.php index 00172b4579..600b828212 100644 --- a/wp-includes/class-wp-theme-json.php +++ b/wp-includes/class-wp-theme-json.php @@ -2849,6 +2849,7 @@ class WP_Theme_JSON { * Removes insecure data from theme.json. * * @since 5.9.0 + * @since 6.3.2 Preserves global styles block variations when securing styles. * * @param array $theme_json Structure to sanitize. * @return array Sanitized structure. @@ -2910,6 +2911,20 @@ class WP_Theme_JSON { if ( ! empty( $output ) ) { _wp_array_set( $sanitized, $metadata['path'], $output ); } + + if ( isset( $metadata['variations'] ) ) { + foreach ( $metadata['variations'] as $variation ) { + $variation_input = _wp_array_get( $theme_json, $variation['path'], array() ); + if ( empty( $variation_input ) ) { + continue; + } + + $variation_output = static::remove_insecure_styles( $variation_input ); + if ( ! empty( $variation_output ) ) { + _wp_array_set( $sanitized, $variation['path'], $variation_output ); + } + } + } } $setting_nodes = static::get_setting_nodes( $theme_json ); diff --git a/wp-includes/version.php b/wp-includes/version.php index bb04aac502..76cc9375f2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.3.2-alpha-56777'; +$wp_version = '6.3.2-alpha-56779'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.