Template activation: fix /lookup endpoint to use custom resolve fn#72049
Template activation: fix /lookup endpoint to use custom resolve fn#72049
Conversation
0ca0d47 to
b45cf60
Compare
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
Flaky tests detected in 469ba69. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18226813568
|
| .click(); | ||
| await page.getByRole( 'menuitem', { name: 'Change template' } ).click(); | ||
| await page.getByRole( 'option', { name: 'Custom' } ).click(); | ||
| await expect( |
There was a problem hiding this comment.
This test was previously giving a false positive. It only checks for Single Entries at the very end, but it failed to set the template Custom in the first place.
|
Size Change: -6 B (0%) Total Size: 1.96 MB
ℹ️ View Unchanged
|
|
Merging this because template activation basically doesn't work in the editor. Adjusted the e2e test for better coverage. |
| @@ -0,0 +1,17 @@ | |||
| <?php | |||
|
|
|||
| class Gutenberg_REST_Old_Templates_Controller extends WP_REST_Templates_Controller { | |||
There was a problem hiding this comment.
Hi @ellatrix I need to extend WP_REST_Templates_Controller for another feature.
Can I piggy back off Gutenberg_REST_Old_Templates_Controller?
Could you explain how it relates to Gutenberg_REST_Templates_Controller? Some comments in the code might help folks working on 6.9.
There was a problem hiding this comment.
As we discussed, it would make sense to add the method to override for all 3 controllers if you need to filter templates.
|
I just cherry-picked this PR to the release/21.8 branch to get it included in the next release: 682b5be |
What?
The rewrite (#71811) adjusting template resolution use an earlier filter instead of
get_block_templatesshould have also adjusted the/lookupendpoint, which is still using the coreresolve_block_templatefunction. It should use modified version instead.Why?
Currently when you create a new page template and edit a page, that inactive page template will be shown instead of the active theme one. That's because the old resolve template function is still called, and WP thinks that edit should be active.
How?
We override the endpoint callback.
Testing Instructions
Duplicate and edit a page template. Do not activate it. Then create a new page. Use the "show template" preview button. You should see the theme template, not the newly created inactive template.
Testing Instructions for Keyboard
Screenshots or screencast