Make WordPress Core

Opened 11 months ago

Closed 10 months ago

Last modified 9 months ago

#64402 closed defect (bug) (fixed)

REST API: Block themes without theme.json cannot use global styles

Reported by: wildworks Owned by:
Priority: normal Milestone: 7.0
Component: REST API Version:
Severity: normal Keywords:
Cc: Focuses:

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 _links from the response data
  • Use that ID to retrieve the global styles data

​Source

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 (3)

#1 @wildworks
11 months ago

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

#2 @youknowriad
10 months ago

  • Resolution → fixed
  • Status new → closed

#3 @sabernhardt
9 months ago

  • Milestone Awaiting Review → 7.0
Note: See TracTickets for help on using tickets.