[wp-trac] [WordPress Trac] #53176: Block Editor: Backport the FSE infrastructure required to make the template editor work for classic themes.
WordPress Trac
noreply at wordpress.org
Wed May 19 12:29:32 UTC 2021
#53176: Block Editor: Backport the FSE infrastructure required to make the template
editor work for classic themes.
----------------------------+---------------------
Reporter: youknowriad | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: 5.8
Component: Editor | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+---------------------
Comment (by Bernhard Reiter):
In Gutenberg, we're currently
[https://github.com/WordPress/gutenberg/blob/416d1adb2ec0f46b111d5b3898859244c41f06b1/lib
/full-site-editing/template-loader.php#L20 hooking] into all the
[https://developer.wordpress.org/reference/hooks/type_template/
`{type}_template`] filters.
The overall sequence in Core looks about like this:
* WordPress detects that the current route maps to an entity of type
`{type}` (e.g. a `page` or `category`).
* It calls `get_{type}_template()` (e.g. `get_page_template()`), which in
turn passes an array of candidate template slugs (with `.php` file
extension) to
[https://developer.wordpress.org/reference/functions/get_query_template/
`get_query_template()`].
* Internally, `get_query_template()` calls, in order:
* the
[https://developer.wordpress.org/reference/hooks/type_template_hierarchy/
`type_template_hiearchy`] filter, which can modify the template candidate
list.
* [https://developer.wordpress.org/reference/functions/locate_template/
`locate_template`], to find the template file with the highest specificity
that matches the candidate list.
* the [https://developer.wordpress.org/reference/hooks/type_template/
`type_template`] filter, which can modify that result (the path to the
template file).
Gutenberg only hooks into the latter filter, to "redirect" WordPress to
its special `template-canvas.php` template file, which will render the
best matching block template (if any). The reason for this is that WP
expects a (PHP) file _path_ -- and in GB, we can't guarantee that there's
always a template file, since block templates can also come from a
`wp_template` post object.
OTOH, it means that Gutenberg is conflating concerns within that filter,
rather than aligning them within the framework of e.g.
`get_{type}_template()` and `locate_template()`.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/53176#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list