Make WordPress Core

Changeset 59316


Ignore:
Timestamp:
10/29/2024 03:11:35 AM (5 months ago)
Author:
ramonopoly
Message:

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.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/edit-form-blocks.php

    r59238 r59316  
    5151
    5252$rest_path = rest_get_route_for_post( $post );
     53
     54$active_theme = get_stylesheet();
    5355
    5456// Preload common data.
     
    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);
  • trunk/src/wp-admin/site-editor.php

    r59238 r59316  
    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(
Note: See TracChangeset for help on using the changeset viewer.