Opened 5 weeks ago
Last modified 5 weeks ago
#62322 new enhancement
Global styles: preload user global styles based on user caps in the Post Editor
Reported by: | ramonopoly | Owned by: | |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | 6.7 |
Component: | Editor | Keywords: | has-patch |
Focuses: | Cc: |
Description
A ticket to track the syncing of https://github.com/WordPress/gutenberg/pull/66541
What
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.
Why
Preloading the global styles endpoint according to role context means that admins and non admins, e.g., editors, avoid unnecessary clientside requests.
Different clientside requests fire for each.
Change History (1)
This ticket was mentioned in PR #7681 on WordPress/wordpress-develop by @ramonopoly.
5 weeks ago
#1
Note: See
TracTickets for help on using
tickets.
## What
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.## Why
Preloading the global styles endpoint according to role context means that admins and non admins, e.g., editors, avoid unnecessary clientside requests.
Different clientside requests fire for each.
## How?
Use
current_user_can( 'edit_theme_options' )
to test for global styles edit caps. This matches post type caps.## Testing Instructions
global-styles
endpoints aren't fetched client side, but are, rather, preloaded via rest_preload_api_requestFor admins in the POST and SITE editors the following URLS should be preloaded:
For editors in the POST editor:
Trac ticket: https://core.trac.wordpress.org/ticket/62322