Commit c252a2f896 for wordpress.org

commit c252a2f8964281ddfcdd615e4ba44e5688421c98
Author: ramonopoly <ramonopoly@git.wordpress.org>
Date:   Tue Nov 25 02:54:35 2025 +0000

    Global Styles Revisions: Preserve block style variations in global styles revisions

    When retrieving global styles revisions through the REST API, any block style variations (e.g., `styles.blocks.core/group.variations.my-variation`) are being removed during `WP_Theme_JSON` sanitization.

    `WP_Theme_JSON` will only allow block style variations that are registered.

    This means user modifications to any theme block style variations were being stripped from global styles revisions when retrieved via the REST API.

    This commit registers theme-defined block style variations in `WP_REST_Global_Styles_Revisions_Controller::prepare_item_for_response` so that they can be properly parsed by `WP_Theme_JSON`, and therefore added to the global styles revisions REST API GET response.

    Props ramonopoly, aaronrobertshaw, ellatrix.

    Fixes #64292.


    Built from https://develop.svn.wordpress.org/trunk@61301


    git-svn-id: http://core.svn.wordpress.org/trunk@60613 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
index 886b97e14c..c5d4e89e5e 100644
--- a/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
+++ b/wp-includes/rest-api/endpoints/class-wp-rest-global-styles-revisions-controller.php
@@ -312,6 +312,15 @@ class WP_REST_Global_Styles_Revisions_Controller extends WP_REST_Revisions_Contr
 		$theme_json = null;

 		if ( ! empty( $global_styles_config['styles'] ) || ! empty( $global_styles_config['settings'] ) ) {
+			/*
+			 * Register block style variations from the theme data.
+			 * This is required so the variations pass sanitization of theme.json data.
+			 */
+			if ( ! empty( $global_styles_config['styles']['blocks'] ) ) {
+				$variations = WP_Theme_JSON_Resolver::get_style_variations( 'block' );
+				wp_register_block_style_variations_from_theme_json_partials( $variations );
+			}
+
 			$theme_json           = new WP_Theme_JSON( $global_styles_config, 'custom' );
 			$global_styles_config = $theme_json->get_raw_data();
 			if ( rest_is_field_included( 'settings', $fields ) ) {
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 282f058298..7e669e1f9f 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.0-alpha-61300';
+$wp_version = '7.0-alpha-61301';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.