[wp-trac] [WordPress Trac] #11871: $pagenow is wrong in frontend processing (always set to "index.php")
WordPress Trac
wp-trac at lists.automattic.com
Tue Jan 12 01:38:48 UTC 2010
#11871: $pagenow is wrong in frontend processing (always set to "index.php")
--------------------------+-------------------------------------------------
Reporter: codestyling | Owner:
Type: defect (bug) | Status: new
Priority: high | Milestone: 2.9.2
Component: Template | Version: 2.9.1
Severity: critical | Keywords: template pagenow defect
--------------------------+-------------------------------------------------
The global var ''$pagenow'' will be evaluated at all versions using the
'''vars.php''' ''else'' path (non admin pages).
But this is the wrong place. It's only possible to set the correct
processed page (template file name) at the '''template-loader.php''' after
evaluation of correct template file!
In my opinion there should be a function inside the ''template-
loader.php'' like:
{{{
function redefine_pagenow($template) {
global $pagenow;
if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $template,
$self_matches) )
$pagenow = strtolower($self_matches[1]);
else
$pagenow = 'index.php';
}
}}}
and the ''if/else'' cascades should use the function for redefine the
correct template file been processed currently as frontend view (example
excerpt):
{{{
...
} else if ( is_single() && $template = get_single_template() ) {
redefine_pagenow($template);
include($template);
return;
} else if ( is_page() && $template = get_page_template() ) {
redefine_pagenow($template);
include($template);
return;
} else if ( is_category() && $template = get_category_template())
{
redefine_pagenow($template);
include($template);
return;
...
}}}
This will permit theme/template designer to detect using the correct
''$pagenow'' var what template is been currently processed instead of
always ''index.php''
This problem is also related to older versions of WordPress.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/11871>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list