mirror of
https://github.com/WordPress/WordPress.git
synced 2025-02-20 19:56:49 +01:00
Editor: Preload Global Styles REST requests based on user permissions.
For the Post Editor, preload '/wp/v2/global-styles/' . $global_styles_id with a context corresponding to user caps, that is, 'edit' for users that can edit global styles, and 'view' for everyone else. Preloading the global styles endpoint according to role context means that admins and non admins, e.g., editors, avoid unnecessary client side requests. Props ramonopoly. Fixes #62322. Built from https://develop.svn.wordpress.org/trunk@59795 git-svn-id: http://core.svn.wordpress.org/trunk@59137 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e92abc0735
commit
096c95390c
|
|
@ -51,8 +51,8 @@ wp_enqueue_script( 'wp-edit-post' );
|
|||
|
||||
$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',
|
||||
|
|
@ -71,7 +71,14 @@ $preload_paths = array(
|
|||
'/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 );
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8-alpha-59794';
|
||||
$wp_version = '6.8-alpha-59795';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user