Opened 5 weeks ago
Last modified 8 days ago
#63253 new enhancement
Theme REST API: expose "has_theme_json" field
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | has-patch has-unit-tests |
Focuses: | Cc: |
Description
Currently, there is no official way to detect whether the active theme has theme.json
or not via REST API.
We needed to check for the existence of theme.json to conditionally expose Stylebook for the classic theme. As a temporary approach, we used the supportsLayout
setting, which is the equivalent of the wp_theme_has_theme_json()
function:
However, there is no guarantee that this setting will remain equivalent to wp_theme_has_theme_json()
in the future.
We should expose the new "has_theme_json" field via the theme REST API.
Change History (5)
This ticket was mentioned in PR #8665 on WordPress/wordpress-develop by @wildworks.
5 weeks ago
#2
- Keywords has-patch has-unit-tests added
#3
@
5 weeks ago
Testing Instructions
- Open the post editor or the site editor
- Open the console panel of your browser
- Run
wp.data.select('core').getCurrentTheme()
- Confirm that the response includes the
has_theme_json
field
@ankitkumarshah commented on PR #8665:
5 weeks ago
#4
#5
@
8 days ago
Update: I realized that using wp_theme_has_theme_json()
in the REST API response isn't correct. Because the wp_theme_has_theme_json()
function returns results based on the active theme.
See https://github.com/WordPress/gutenberg/pull/69857#issuecomment-2801814369 for more details.
I think we need to add a new has_theme_json
method to the WP_Theme
class first, so I submitted #63299.
Trac ticket: https://core.trac.wordpress.org/ticket/63253
Gutenberg PR: https://github.com/WordPress/gutenberg/pull/69857