Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 );

$stylesheet = 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/' . $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',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depending on user capabilities, a different clientside request will fire, e.g.,

✅ user can update global styles: '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=edit',

🔕 user cannot update global styles: '/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=view',

So at the moment, editors will get a clientside request since '?context=view', isn't preloaded.

I'm wondering if it's worth changing this to "view" context based on caps.

Probably for a follow up, as this already fixes a bunch of unnecessary requests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

);

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