-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Load page templates via theme.json abstractions #28700
Conversation
Size Change: 0 B Total Size: 1.37 MB ℹ️ View Unchanged
|
11f4d79
to
247efa2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great and testing works well.
I hope you don't mind - I pushed a commit of composer format
to make the php tests happy and hopefully pass.
Thank you 🙂 |
6ed01a9
to
469cb6c
Compare
$resolver = new WP_Theme_JSON_Resolver(); | ||
$data = $resolver->get_theme_data()->get_page_templates(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circling back to this. Now that theme
is static. Do we need to call new
here? Or would something like:
WP_Theme_JSON_Resolver::get_theme_data()->get_page_templates();
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the follow-up that bundles non-behavioral changes: #28855 (it also makes get_theme_data
static).
This PR is a follow up to #27778 (which introduced the
pageTemplates
field in theme.json) and #28110 #28533 that refactored it to accommodate the new needs for this file #28163The idea is to mature the APIs we use to read data from theme.json, as to:
An initial list of steps we need to check when adding new fields to
theme.json
:While the role of the
WP_Theme_JSON
class in this space seems well established, the role ofWP_Theme_JSON_Resolver
needs to be accommodated to the new use cases we want to support beyond settings & styles. This PR is the first step to do that and usespageTemplates
as an example.Proposed API for consumers:
How to test
master
branch). It defines one page template: page-home whose text is "Page without title".experimental-theme.json
of the TT1-blocks theme and update the text to be "My home page".Follow-ups
This PR refactors code, it doesn't change any behavior. A follow up to this that adds new behavior is a PR that enables the page template title to be translated.
I think
WP_Theme_JSON_Resolver
needs more maturation. I'd like to create small and focused follow-up PRs to improve it. It'll allow us to move quickly by making reviews easier.