From 542261e829d212d742eb10c9aa305382dc332ad3 Mon Sep 17 00:00:00 2001 From: Ella <4710635+ellatrix@users.noreply.github.com> Date: Mon, 28 Oct 2024 15:51:18 +0100 Subject: [PATCH 1/4] Preload: fix multiple regressions around global styles --- src/wp-admin/edit-form-blocks.php | 6 +++++- src/wp-admin/site-editor.php | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index c4727ea3ba8a0..0f743a84ed66e 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -51,6 +51,8 @@ static function ( $classes ) { $rest_path = rest_get_route_for_post( $post ); +$stylesheet = get_stylesheet(); + // Preload common data. $preload_paths = array( '/wp/v2/types?context=view', @@ -65,8 +67,10 @@ static function ( $classes ) { sprintf( '%s/autosaves?context=edit', $rest_path ), '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), - '/wp/v2/global-styles/themes/' . get_stylesheet(), + '/wp/v2/global-styles/themes/' . $stylesheet . '?context=view', + '/wp/v2/global-styles/themes/' . $stylesheet . '/variations?context=view' '/wp/v2/themes?context=edit&status=active', + array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ) '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit', ); diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index a678fc1e44ab3..daf24f2fa73ba 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -97,8 +97,9 @@ static function ( $classes ) { '/wp/v2/template-parts?context=edit&per_page=-1', '/wp/v2/themes?context=edit&status=active', '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', - '/wp/v2/global-styles/' . $active_global_styles_id, - '/wp/v2/global-styles/themes/' . $active_theme, + array( '/wp/v2/global-styles/' . $active_global_styles_id, 'OPTIONS' ) + '/wp/v2/global-styles/themes/' . $active_theme . '?context=view', + '/wp/v2/global-styles/themes/' . $active_theme . '/variations?context=view', array( $navigation_rest_route, 'OPTIONS' ), array( add_query_arg( From 4f3644c76f8d98c250b0d6159df8aac79ca48ae4 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 29 Oct 2024 10:26:31 +1100 Subject: [PATCH 2/4] Add missing comma in $preload_paths array --- src/wp-admin/site-editor.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index daf24f2fa73ba..3207bccdf2632 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -97,7 +97,7 @@ static function ( $classes ) { '/wp/v2/template-parts?context=edit&per_page=-1', '/wp/v2/themes?context=edit&status=active', '/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit', - array( '/wp/v2/global-styles/' . $active_global_styles_id, 'OPTIONS' ) + array( '/wp/v2/global-styles/' . $active_global_styles_id, 'OPTIONS' ), '/wp/v2/global-styles/themes/' . $active_theme . '?context=view', '/wp/v2/global-styles/themes/' . $active_theme . '/variations?context=view', array( $navigation_rest_route, 'OPTIONS' ), From 8c90aaee88d7bda1441b6e1348c4972aa8404812 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 29 Oct 2024 10:28:07 +1100 Subject: [PATCH 3/4] Add missing commas to $preload_paths array in edit-form-blocks --- src/wp-admin/edit-form-blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 0f743a84ed66e..83d7622387a87 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -68,9 +68,9 @@ static function ( $classes ) { '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), '/wp/v2/global-styles/themes/' . $stylesheet . '?context=view', - '/wp/v2/global-styles/themes/' . $stylesheet . '/variations?context=view' + '/wp/v2/global-styles/themes/' . $stylesheet . '/variations?context=view', '/wp/v2/themes?context=edit&status=active', - array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ) + array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ), '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit', ); From 530adb2ff8a4e8b9c95ce24102705664a5979805 Mon Sep 17 00:00:00 2001 From: Ramon Date: Tue, 29 Oct 2024 12:56:22 +1100 Subject: [PATCH 4/4] rename stylesheet to active_theme --- src/wp-admin/edit-form-blocks.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 83d7622387a87..5dbb9f33e4970 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -51,7 +51,7 @@ static function ( $classes ) { $rest_path = rest_get_route_for_post( $post ); -$stylesheet = get_stylesheet(); +$active_theme = get_stylesheet(); // Preload common data. $preload_paths = array( @@ -67,8 +67,8 @@ static function ( $classes ) { sprintf( '%s/autosaves?context=edit', $rest_path ), '/wp/v2/settings', array( '/wp/v2/settings', 'OPTIONS' ), - '/wp/v2/global-styles/themes/' . $stylesheet . '?context=view', - '/wp/v2/global-styles/themes/' . $stylesheet . '/variations?context=view', + '/wp/v2/global-styles/themes/' . $active_theme . '?context=view', + '/wp/v2/global-styles/themes/' . $active_theme . '/variations?context=view', '/wp/v2/themes?context=edit&status=active', array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ), '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit',