WordPress Trac: Ticket #12491: add a pre_template_include filter, so as to allow caching of the template filehttps://core.trac.wordpress.org/ticket/12491
<p>
rather than running file exists all over the place in the template loader, we should offer the possibility for a plugin to cache the information for use in subsequent pages.
</p>
en-usWordPress Trachttps://core.trac.wordpress.org/chrome/site/your_project_logo.pnghttps://core.trac.wordpress.org/ticket/12491
Trac 1.0.1Denis-de-BernardyWed, 03 Mar 2010 00:29:42 GMTattachment sethttps://core.trac.wordpress.org/ticket/12491
https://core.trac.wordpress.org/ticket/12491
<ul>
<li><strong>attachment</strong>
set to <em>12491.diff</em>
</li>
</ul>
TicketnacinWed, 03 Mar 2010 02:10:25 GMThttps://core.trac.wordpress.org/ticket/12491#comment:1
https://core.trac.wordpress.org/ticket/12491#comment:1
<p>
Patch looks fine, though I'm wondering why you didn't place it above 404 as well, just cause.
</p>
<p>
More so, couldn't you write to cache on the template_include hook and pull from cache on template_redirect?
</p>
<p>
Seems like a worksforme, considering that the two hooks now seem more than flexible enough for what you're going for.
</p>
TicketDenis-de-BernardyWed, 03 Mar 2010 03:42:16 GMThttps://core.trac.wordpress.org/ticket/12491#comment:2
https://core.trac.wordpress.org/ticket/12491#comment:2
<p>
re 404, the point would be to write a plugin that looks up the available template files, caches that accordingly, and knows, based on what the WP Query tells it, what file to use without needing to do a file_exists() call.
</p>
<p>
template_redirect works fine too for this, up to a point:
</p>
<ul><li>it would mean the plugin needs to handle robots, feeds, etc. it would also mean the plugin would need to manage whatever we add in there in the future.
</li><li>it would re-introduce the inflexibility that led us to introduce the 2nd hook in the first place, i.e. the plugin itself would not be plugin-able.
</li></ul>
TickethakreFri, 05 Mar 2010 08:27:36 GMThttps://core.trac.wordpress.org/ticket/12491#comment:3
https://core.trac.wordpress.org/ticket/12491#comment:3
<p>
Additionally, and that is not that visible in the trac patch browser, <em>pre_template_include</em> is building a good pair to <em>template_include</em>, a principle that you can find more and more often within the codebase.
</p>
TicketnacinMon, 26 Apr 2010 07:35:07 GMThttps://core.trac.wordpress.org/ticket/12491#comment:4
https://core.trac.wordpress.org/ticket/12491#comment:4
<p>
Apparently I had misread the diff, and thought 404 was processed before the filter. Obviously, filter comes first in the diff.
</p>
TicketnacinSun, 16 May 2010 17:29:18 GMTmilestone changedhttps://core.trac.wordpress.org/ticket/12491#comment:5
https://core.trac.wordpress.org/ticket/12491#comment:5
<ul>
<li><strong>milestone</strong>
changed from <em>3.0</em> to <em>3.1</em>
</li>
</ul>
TicketnacinThu, 28 Oct 2010 11:38:14 GMTmilestone changedhttps://core.trac.wordpress.org/ticket/12491#comment:6
https://core.trac.wordpress.org/ticket/12491#comment:6
<ul>
<li><strong>milestone</strong>
changed from <em>Awaiting Triage</em> to <em>Future Release</em>
</li>
</ul>
TicketnacinSat, 25 Jan 2014 08:15:40 GMTcomponent changed; focuses sethttps://core.trac.wordpress.org/ticket/12491#comment:7
https://core.trac.wordpress.org/ticket/12491#comment:7
<ul>
<li><strong>focuses</strong>
<em>performance</em> added
</li>
<li><strong>component</strong>
changed from <em>Optimization</em> to <em>Template</em>
</li>
</ul>
TicketnacinSat, 01 Feb 2014 07:55:30 GMTfocuses, component changedhttps://core.trac.wordpress.org/ticket/12491#comment:8
https://core.trac.wordpress.org/ticket/12491#comment:8
<ul>
<li><strong>focuses</strong>
<em>template</em> added
</li>
<li><strong>component</strong>
changed from <em>Template</em> to <em>Themes</em>
</li>
</ul>
Ticket