WordPress.org

Make WordPress Core

Opened 7 weeks ago

#54541 new defect (bug)

Add actions to template loading to assist with collecting debug info

Reported by: rmccue Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Themes Keywords: needs-patch
Focuses: performance Cc:

Description

locate_template() is the low-level workhorse that handles finding template parts; with the second parameter ($load = true), it also handles actually loading those templates. This is used throughout the template hierarchy loading system; get_template_part() calls it, as well as get_header(), get_footer(), etc.

In order to provide timing data to debug tools like Query Monitor, having actions before and after the template itself loads would be super useful. We could do this within each usage of locate_template(), or inside it.

Potentially, this could be a shortcircuit filter, allowing for alternative loading patterns (#13239) or automatic fragment caching. However I don't want to derail this ticket, as there are a lot of strong opinions on the template hierarchy, so I would suggest we do not provide a filter at this stage; right now, just having the timing data would be useful.

(I offer no opinions at this time on the relation to the Gutenberg FSE templating.)

Change History (0)

Note: See TracTickets for help on using tickets.