#58123 closed enhancement (fixed)
Indicate when a theme supports the Site editor in the Themes REST API response
Reported by: |
|
Owned by: |
|
---|---|---|---|
Milestone: | 6.3 | Priority: | normal |
Severity: | normal | Version: | |
Component: | REST API | Keywords: | has-patch has-unit-tests has-testing-info has-screenshots add-to-field-guide |
Focuses: | rest-api | Cc: |
Description
I currently can't find a way to know if the active theme supports the Site editor based on the /themes REST API response for that theme.
We have theme supports data for block-template-parts
in the response, which can be an indication of Site editor support, but use of this doesn't seem consistent. For example, Twenty Twenty-Two doesn't declare block-template-parts
support, but it supports using the Site editor.
One way to know would be to surface the result of WP_Theme::is_block_theme
for each theme (or at least for the active theme) in the API response.
Attachments (1)
Change History (12)
This ticket was mentioned in PR #4323 on WordPress/wordpress-develop by @grantmkin.
2 years ago
#1
- Keywords has-patch has-unit-tests added
#2
@
23 months ago
- Keywords has-testing-info needs-testing has-screenshots added
- Milestone changed from Awaiting Review to 6.3
Welcome back to Trac, and thanks for the ticket and PR, @grantmkin!
This LGTM 👍🏻 Moving into the 6.3 milestone for consideration.
Test Report
Patch tested: https://github.com/WordPress/wordpress-develop/pull/4323
Steps to Test
- Activate Gutenberg. This conveniently makes use of Core's
wp/v2/themes
endpoint. - Activate a block theme. This is needed to make the Editor available.
- Navigate to Appearance > Editor (
/wp-admin/site-editor.php
). - In the browser console, inspect the network connections (in Chrome this is the Network tab), and filter results by "themes" and/or fetch/XHR requests. Reload the page if nothing is there the first try.
- Locate the request for
themes?context=edit...
and preview/inspect the response. - 👀 Expand and inspect the data for each theme.
- 🩹 Apply patch.
- Refresh the page, and repeat Step 5.
- 👀 Expand and inspect the data for each theme again.
Expected Results
After applying the patch:
- ✅ Observe that for block themes, the theme data includes
is_block_theme: true
. - ✅ Observe that for classic themes, the theme data includes
is_block_theme: false
.
Environment
- Hardware: MacBook Pro Apple M1 Pro
- OS: macOS 13.4
- Browser: Google Chrome 114.0.5735.106
- Server: nginx/1.25.0
- PHP: 7.4.33
- WordPress: 6.3-alpha-55505-src
- Theme: twentytwentythree v1.1
- Active Plugins:
- gutenberg v16.0.0
Actual Results
- ✅ Block themes (like TT3) include
is_block_theme: true
. - ✅ Classic themes (like TT) include
is_block_theme: false
.
Supplemental Artifacts
Figure 1: Chrome DevTools Network tab themes
endpoint response data for block theme.
Figure 2: Chrome DevTools Network tab themes
endpoint response data for classic theme.
This ticket was mentioned in Slack in #core by zunaid321. View the logs.
23 months ago
#4
@
23 months ago
Test Report
This report validates that the indicated patch addresses the issue.
Patch tested: https://github.com/WordPress/wordpress-develop/pull/4323
Environment
- OS: Windows 11 (22H2)
- Web Server: nginx/1.23.4
- PHP: 7.4.33
- WordPress: 6.3-alpha-55505-src
- Browser: Chrome Version 114.0.5735.110 (Official Build) (64-bit)
- Theme: Twenty Twenty-Three
Before Applying The Patch
- Followed the instructions of @ironprogrammer
- ❌ is_block_theme - was not available
After Applying The Patch
- Followed the same instructions
- ✅ is_block_theme was displaying the correct info for both classic and block based themes.
Plugins Used
- Attached: gutenberg.16.0.0.zip
Screenshots
- Before Patch: https://prnt.sc/NWmL4MV5WVmf
- After Patch: https://prnt.sc/k-dcTe1S4jFq
#5
@
23 months ago
- Keywords commit added
surface the result of
WP_Theme::is_block_theme
Makes sense imho. The patch also looks good. Not sure if it needs two new tests for one boolean value, could they be combined? But the more-the merrier :)
#7
@
23 months ago
- Keywords needs-testing commit removed
- Owner set to audrasjb
- Status changed from new to reviewing
Removing commit
since I added a request to add the ticket number in the related unit tests functions.
#8
@
23 months ago
Not sure if it needs two new tests for one boolean value, could they be combined?
Tests combined in https://github.com/WordPress/wordpress-develop/pull/4323/commits/a66c9f54db7ce63c2756b013bb37b1487078017b
Removing commit since I added a request to add the ticket number in the related unit tests functions.
---
Let me know if there's anything else needed!
@audrasjb commented on PR #4323:
23 months ago
#10
committed in https://core.trac.wordpress.org/changeset/55951
Adds a
is_block_theme
property to each theme in the wp/v2/themes API response, which usesWP_Theme::is_block_theme
.This helps to indicate if a theme supports the Site editor, or not.
Trac ticket: https://core.trac.wordpress.org/ticket/58123