Skip to content

Commit 1913680

Browse files
committed
Global styles: preload /global-styles endpoint responses
This commit fixes a regression whereby requests to global styles endpoints were not being preloaded, resulting in several requests being fired clientside unnecessarily. For performance reasons, we preload the requests so that the data is in the editor store and ready to use straight away. The outcome is that the editor loads more quickly. Follow-up to [62042]. Props ellatrix, ramonopoly, apermo, peterwilsoncc. Fixes #62315. git-svn-id: https://develop.svn.wordpress.org/trunk@59316 602fd350-edb4-49c9-b593-d223f7449a82
1 parent aa03a4d commit 1913680

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/wp-admin/edit-form-blocks.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ static function ( $classes ) {
5151

5252
$rest_path = rest_get_route_for_post( $post );
5353

54+
$active_theme = get_stylesheet();
55+
5456
// Preload common data.
5557
$preload_paths = array(
5658
'/wp/v2/types?context=view',
@@ -65,8 +67,10 @@ static function ( $classes ) {
6567
sprintf( '%s/autosaves?context=edit', $rest_path ),
6668
'/wp/v2/settings',
6769
array( '/wp/v2/settings', 'OPTIONS' ),
68-
'/wp/v2/global-styles/themes/' . get_stylesheet(),
70+
'/wp/v2/global-styles/themes/' . $active_theme . '?context=view',
71+
'/wp/v2/global-styles/themes/' . $active_theme . '/variations?context=view',
6972
'/wp/v2/themes?context=edit&status=active',
73+
array( '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id(), 'OPTIONS' ),
7074
'/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit',
7175
);
7276

src/wp-admin/site-editor.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,9 @@ static function ( $classes ) {
9797
'/wp/v2/template-parts?context=edit&per_page=-1',
9898
'/wp/v2/themes?context=edit&status=active',
9999
'/wp/v2/global-styles/' . $active_global_styles_id . '?context=edit',
100-
'/wp/v2/global-styles/' . $active_global_styles_id,
101-
'/wp/v2/global-styles/themes/' . $active_theme,
100+
array( '/wp/v2/global-styles/' . $active_global_styles_id, 'OPTIONS' ),
101+
'/wp/v2/global-styles/themes/' . $active_theme . '?context=view',
102+
'/wp/v2/global-styles/themes/' . $active_theme . '/variations?context=view',
102103
array( $navigation_rest_route, 'OPTIONS' ),
103104
array(
104105
add_query_arg(

0 commit comments

Comments
 (0)