Opened 5 weeks ago
Closed 28 hours ago
#64402 closed defect (bug) (fixed)
REST API: Block themes without theme.json cannot use global styles
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | REST API | Keywords: | |
| Focuses: | Cc: |
Description
In Gutenberg, the global styles data is obtained as follows:
- Send a request to the theme endpoint (
/wp/v2/themes) - Derive the global styles ID from the
_linksfrom the response data - Use that ID to retrieve the global styles data
On the backend, if a global styles ID is available, a link to it is added here.
However, the get_user_data_from_wp_global_styles function returns an empty array if the theme does not have a theme.json, even if it is a block theme (Source). As a result, no link is added to the theme endpoint, and Gutenberg fails to access the global styles data.
The block theme should be determined purely by the wp_is_block_theme() function, regardless of whether a theme.json is present.
Links to the global styles id should be exposed even to block themes that do not have a theme.json.
Change History (2)
Note: See
TracTickets for help on using
tickets.
Note that this bug is automatically resolved if we can move #64408 forward. This is because #64408 enables the global styles across all themes.
See this code being removed: https://github.com/WordPress/wordpress-develop/pull/10623/changes#diff-d6b86476eed058e7cf8b6e57fa52c4fd75b1f0907e1a9ccb0149528a24f7578bL483-L492