Skip to content

Commit

Permalink
Global styles: preload /global-styles endpoint responses
Browse files Browse the repository at this point in the history
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].

Reviewed by peterwilsoncc.
Merges [59316] to the 6.7 branch.

Props ellatrix, ramonopoly, apermo, peterwilsoncc.
Fixes #62315.



git-svn-id: https://develop.svn.wordpress.org/branches/6.7@59324 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
peterwilsoncc committed Oct 29, 2024
1 parent be30e5d commit 4cfb064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ static function ( $classes ) {

$rest_path = rest_get_route_for_post( $post );

$active_theme = get_stylesheet();

// Preload common data.
$preload_paths = array(
'/wp/v2/types?context=view',
Expand All @@ -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/' . $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',
);

Expand Down
5 changes: 3 additions & 2 deletions src/wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 4cfb064

Please sign in to comment.