Make WordPress Core

Changeset 59324 for branches/6.7


Ignore:
Timestamp:
10/29/2024 10:53:22 PM (22 months ago)
Author:
peterwilsoncc
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].

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

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

Location:
branches/6.7
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/6.7

  • branches/6.7/src/wp-admin/edit-form-blocks.php

    r59238 r59324  
    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);
  • branches/6.7/src/wp-admin/site-editor.php

    r59238 r59324  
    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.