Fields: Add support for classic themes in template#76441
Conversation
|
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. |
| 'date', | ||
| 'slug', | ||
| 'parent', | ||
| 'author', |
There was a problem hiding this comment.
These changes are not related, but I reordered a bit the fields to match the order of the current post summary.
| }, [] ); | ||
|
|
||
| // Augment record only when needed(not a block theme with available templates). | ||
| const augmentedRecord = useMemo( () => { |
There was a problem hiding this comment.
I explored/investigated a few approaches for this and I think that's the simplest solution.
availableTemplates is used in classic themes to construct the select with the templates that we can change to. In core this happens here and is part of the editor settings.
The problem is that fields package doesn't have access to that prop without the editor package as a dependency. There is a getEditorSettings in core-data but fetches the settings from REST API, where the prop is not available.
I explored/considered updating REST endpoints (settings/post/post types) but in the end this is useful only in a single place in our code (here) and augmenting the record conditionally seemed the best path forward.
|
Size Change: +468 B (+0.01%) Total Size: 8.75 MB
ℹ️ View Unchanged
|
|
I just wanted to note that the Template control logic is complex. There are so many variations of theme/templates that we have to account for. I think even the current control, which went through many iterations and bug fixes, still has some unresolved issues. Let's not rush this and test properly before we merge and replace anything. |
@t-hamano yes. The create template button will move in a different panel (
I agree. Although the logic added in this field for classic themes was 'ported' from the existing code of
@Mamaduka of course. Noting though that this change only affects the template field in DataForm in inspector control experiment which is now broken for classic themes and there are follow ups planned for the template actions (for all kind of themes). |
t-hamano
left a comment
There was a problem hiding this comment.
Since this change is applied to the template UI only when the DataForm experiment is enabled, I think it's OK to ship this PR.
Should the new template action panel also be implemented based on the DataForm experiment?
template
Yes. It will be implemented in follow ups. |


What?
Part of: #76104
Which is part of the bigger: #76076
Extracted from: #76251
In this exploration the discussions led to:
templatefield as part of thequick edit/post summaryshould be only about changing a templateThis PR handles part of the first point above by making the
templatefield to work properly (only change template) in the context of quick edit and post summary with DataForm. Right now thetemplatefield is broken for classic themes (with and without template support).There will be a follow up to update the actual UI for changing a template based on the designs for all the types of themes.
Testing Instructions
Editor Inspector: Use DataFormtemplate supportlike2014. Noting that classic themes don't have access to the site editor and therefore the quick edit there.templatefield with the experiment enabled.template support4, 5, 6Snippet to add template support