[wp-trac] Re: [WordPress Trac] #7492: Template tag: wp_include_file
WordPress Trac
wp-trac at lists.automattic.com
Wed Aug 13 08:46:49 GMT 2008
#7492: Template tag: wp_include_file
-------------------------+--------------------------------------------------
Reporter: KKWangen | Owner: westi
Type: enhancement | Status: assigned
Priority: normal | Milestone: 2.7
Component: Template | Version:
Severity: normal | Resolution:
Keywords: |
-------------------------+--------------------------------------------------
Comment (by KKWangen):
This works great, but:
I think it should be possible to filter the path to file, as you can do
that with mostly all other template files. As WordPress is to day, I'm
able to have global 404.php file that all themes use, because I can filter
the path to the file.
So it could be good to have this option for misc. files as well, as this
would give me the option to have global navbar.php that all themes that
have support for it uses.
There was another problem with the code as well:
Some themes include the same files several places in the theme, like the
searchform.php file are included in sidebar.php, in 404.php and sometimes
in a custom archive page template (the default theme does this), but
because load_template() is doing require_once, the search form disappears
from the sidebar when the 404 template or the archive page template are
loaded.
I'm not sure how to deal with that. Could it be possible to set a third
parameter to the code? like:
{{{
function locate_template($template_names, $load = false, $include = false)
}}}
And if $include = true, the misc. template uses include($located) instead
of load_template($located)
This is just a on the top of head idea;
But I think it's right to have the misc. files to only be included once by
default, in case you mess up and writes the wrong filename, and try to
load for example navbar.php in the sidebar as well as in header.php
I'm not sure about what name to give the function, it has to be something
"terrible" logic, like the other template tags are:
wp_load_theme_file() might work, or maybe wp_include_template,
wp_get_template, wp_template?
--
Ticket URL: <http://trac.wordpress.org/ticket/7492#comment:9>
WordPress Trac <http://trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list