Make WordPress Core

Opened 16 years ago

Closed 11 years ago

#15957 closed enhancement (wontfix)

add two new actions to track template loading

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

Description

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 16 years ago.

Download all attachments as: .zip

Change History (9)

@willnorris
16 years ago

#1 @scribu
16 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
16 years ago

  • Component ThemesTemplate

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
16 years ago

  • Owner set to koopersmith
  • Status newreviewing

Asking for Daryl to weigh in.

#4 @koopersmith
16 years ago

  • Milestone Awaiting ReviewFuture 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
16 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
14 years ago

Related: #13239

Last edited 14 years ago by scribu (previous) (diff)

#7 @nacin
13 years ago

  • Component TemplateThemes
  • Focuses template added

#8 @wonderboymusic
11 years ago

  • Milestone Future Release
  • Resolutionwontfix
  • Status reviewingclosed

No discussion in 5 years.

Note: See TracTickets for help on using tickets.