Make WordPress Core

Opened 14 years ago

Closed 9 years ago

#15957 closed enhancement (wontfix)

add two new actions to track template loading

Reported by: willnorris's profile willnorris Owned by: koopersmith's profile koopersmith
Milestone: Priority: normal
Severity: normal Version:
Component: Themes Keywords:
Focuses: template Cc:


I would like to add two new actions "pre_load_template" and "post_load_template" inside the load_template() method. The purpose of this is primarily for debugging and development purposes. For example, I'd like to use these actions to add debug comments in a theme's output along the lines of:

<!-- begin ../themes/twentyten/loop.php -->
<!-- end ../themes/twentyten/loop.php -->

This makes it much easier to identify which theme file is responsible for which part of the final page, particularly in the case where some files are being pulled from a parent theme and some are from the child theme.

Attachments (1)

theme.diff (542 bytes) - added by willnorris 14 years ago.

Download all attachments as: .zip

Change History (9)

14 years ago

#1 @scribu
14 years ago

Related: #13239, #12877

I think a single filter would suffice. You can use the 'shutdown' action instead of 'post_load_template'.

#2 @willnorris
14 years ago

  • Component changed from Themes to Template

I'm actually using this with Daryl's modular template idea (#12877) so it's definitely related. As for the 'shutdown' action, unless I'm mistaken, that's only called when PHP shuts down. The idea of 'post_load_template' is to be called at the end of each template loading. Since a dozen or more template files can sometimes be involved in constructing a page, this allows you to clearly mark the beginning and end of each template.

#3 @markjaquith
14 years ago

  • Owner set to koopersmith
  • Status changed from new to reviewing

Asking for Daryl to weigh in.

#4 @koopersmith
14 years ago

  • Milestone changed from Awaiting Review to Future Release

While the ability to be able to insert content before and after a template is sensible in this context, I'd like to wait before introducing new actions.

I think that at this point, the best way to improve the themes API is to add carefully designed, comprehensive concepts instead of bolting on more functions and filters. I know that this makes certain cases more difficult now, but it will benefit us when it comes to maintaining backwards compatibility later.

In this case, I think that if the concepts are executed properly, these actions won't be necessary.

#5 @willnorris
14 years ago

Daryl: I'm all for a comprehensive update to the Themes API rather than bandaids like this. Is there a good place to track this work? A ticket where most of this is happening?

#6 @ericlewis
12 years ago

Related: #13239

Version 0, edited 12 years ago by ericlewis (next)

#7 @nacin
10 years ago

  • Component changed from Template to Themes
  • Focuses template added

#8 @wonderboymusic
9 years ago

  • Milestone Future Release deleted
  • Resolution set to wontfix
  • Status changed from reviewing to closed

No discussion in 5 years.

Note: See TracTickets for help on using tickets.