#21213 closed defect (bug) (fixed)
Underscores get stripped out in $type ( get_query_template() )
| Reported by: | rinatkhaziev | Owned by: | SergeyBiryukov |
|---|---|---|---|
| Priority: | normal | Milestone: | 5.2 |
| Component: | Themes | Version: | 2.5 |
| Severity: | normal | Keywords: | needs-testing has-patch bulk-reopened |
| Cc: | Focuses: | template |
Description
What happens is:
$type = preg_replace( '|[^a-z0-9-]+|', '', $type );
strips underscore. Effectively, incoming "front_page" becomes frontpage, which leads to not working (but documented) hook front_page_template.
I tested this on: nginx 1.2.1/php-fpm 5.4.3 (homebrew macos) and nginx 1.0/php-fpm 5.3.3 with the latest revision ATM
The fix is as simple as
$type = preg_replace( '|[^a-z0-9-_]+|', '', $type );
Patch is attached.
Attachments (2)
Change History (16)
#2
follow-up:
↓ 3
@
14 years ago
Also mentioned in ticket:15337:9.
#3
in reply to: ↑ 2
@
14 years ago
Replying to SergeyBiryukov:
Also mentioned in ticket:15337:9.
This is related to the ticket you mentioned for sure, the only thing is that front page would be left as "front-page" instead of "front_page". front_page_template is the hook for modifying template hierarchy.
#4
@
14 years ago
- Milestone Awaiting Review → 3.6
- Version 3.4.1 → 2.5
Related: [7223], [7224]. template_php.patch seems sane.
An alternative would be to rename the filter to front-page_template: 21213.patch.
$type[0]_$type[1]_template filter would need the same change for consistency, see #15337.
#5
@
13 years ago
- Version 2.5 → trunk
I was getting ready to report this same bug for the attachment page template file $mimetype_$subtype.php. For example, template files text_plain.php and image_jpeg.php will not work but textplain.php and imagejpeg.php do work. The template_php.patch fix will resolve this issue also, but 21213.patch obviously won't.
#6
@
13 years ago
- Version trunk → 2.5
Version number indicates when the bug was initially introduced/reported.
#7
@
13 years ago
Note that both patches change the name of the filter fired for the front page template. I did a quick check on the plugins directory, this can break at least one plugin which filters frontpage_template: http://plugins.trac.wordpress.org/browser/page-transitions/trunk/main.php#L33
Haven't found any others, but I did find three plugins that filter on front_page_template:
- app-your-wordpress-uppsite/themes/webapp/functions.php
- commentpress-core/themes/commentpress-theme/functions.php
- wparty/wparty-theme.php
#10
@
12 years ago
I was just about to write a patch for this. The RegEx is clearly inconsistent with the intent of get_front_page_template():
function get_front_page_template() {
$templates = array('front-page.php');
return get_query_template( 'front_page', $templates );
}
What is the point of passing front_page as $type, if the underscore gets stripped? Either pass frontpage instead of front_page, or fix the RegEx.
This is very confusing for Theme developers.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
proposed patch for the bug