Opened 14 years ago
Closed 14 years ago
#1524 closed defect (bug) (fixed)
Use template_include instead of template_redirect for template loading
Reported by: | greenshady | Owned by: | |
---|---|---|---|
Milestone: | 2.0 | Priority: | normal |
Severity: | normal | Version: | |
Component: | Front-end | Keywords: | |
Cc: |
Description
In bbp-core-hooks.php
, we have this line of code:
add_action( 'template_redirect', 'bbp_custom_template', 999 );
This function is for locating the template to use for the page. It calls bbp_load_template()
to actually load the template. If a template is found, it calls exit()
. If the priority wasn't set to 999, I'd say we'd have a big issue there. But, it's likely this won't mess up anything with that priority.
Nevertheless, WordPress has a filter hook in wp-includes/template-loader.php
for overwriting the included template for the page. This functionality should be changed to use this hook rather than template_redirect
.
Using template_redirect
and exiting causes conflicts with plugins/themes that use the template filter hooks as the correct template won't be loaded.
I'll see about writing a patch if no one can get to this in the next few days.
Attachments (1)
Change History (7)
#2
@
14 years ago
I work on a site that has a unique template hierarchy, which I'm integrating bbPress into. We use various template-loading filter hooks to load specific templates. The templates I expected to load were not loading because my filters never had a chance to execute.
The bbPress function isn't a major problem because it only changes things in very specific scenarios (based on the conditional tags). Plus, it has the bbp_custom_template
hook, which I can easily filter to handle my needs.
WP already has hooks in place for this type of thing though, so we might as well use them. It'll probably save some headaches later.
#4
@
14 years ago
There's probably more consolidation and clean-up that can be done here, but this first round of clean-up should alleviate your woes.
#5
@
14 years ago
Awesome! That should work much better.
I've attached a patch that should use add_filter
instead of add_action
for the template_include
filter hook.
I meant to revisit this code in the future, but if you're noticing incompatibilities already, I've got a fix on the way.
It shouldn't cause any conflicts unless there's some other kind of slug collision. What was happening that was causing you issues?