Skip to content
Closed
Changes from all commits
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
13 changes: 10 additions & 3 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ static function ( $classes ) {

$rest_path = rest_get_route_for_post( $post );

$active_theme = get_stylesheet();

$active_theme = get_stylesheet();
$global_styles_endpoint_context = current_user_can( 'edit_theme_options' ) ? 'edit' : 'view';
// Preload common data.
$preload_paths = array(
'/wp/v2/types?context=view',
Expand All @@ -71,7 +71,14 @@ static function ( $classes ) {
'/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',
/*
* Preload the global styles path with the correct context based on user caps.
* NOTE: There is an equivalent conditional check in the client-side code to fetch
* the global styles entity using the appropriate context value.
* See the call to `canUser()`, under `useGlobalStylesUserConfig()` in `packages/edit-site/src/components/use-global-styles-user-config/index.js`.
* Please ensure that the equivalent check is kept in sync with this preload path.
*/
'/wp/v2/global-styles/' . WP_Theme_JSON_Resolver::get_user_global_styles_post_id() . '?context=' . $global_styles_endpoint_context,
);

block_editor_rest_api_preload( $preload_paths, $block_editor_context );
Expand Down
Loading