WordPress.org

Make WordPress Core

Changeset 6029


Ignore:
Timestamp:
09/04/07 03:21:04 (7 years ago)
Author:
markjaquith
Message:

Better $pagenow determination. fixes #4748

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/vars.php

    r5700 r6029  
    22 
    33// On which page are we ? 
    4 if ( preg_match('#([^/]+\.php)$#', $PHP_SELF, $self_matches) ) { 
     4if ( is_admin() ) { 
     5    // wp-admin pages are checked more carefully 
     6    preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); 
    57    $pagenow = $self_matches[1]; 
    6 } elseif ( strpos($PHP_SELF, '?') !== false ) { 
    7     $pagenow = explode('/', $PHP_SELF); 
    8     $pagenow = trim($pagenow[(sizeof($pagenow)-1)]); 
    9     $pagenow = explode('?', $pagenow); 
    10     $pagenow = $pagenow[0]; 
     8    $pagenow = preg_replace('#\?.*?$#', '', $pagenow); 
     9    if ( '' === $pagenow || 'index' === $pagenow || 'index.php' === $pagenow ) { 
     10        $pagenow = 'index.php'; 
     11    } else { 
     12        preg_match('#(.*?)(/|$)#', $pagenow, $self_matches); 
     13        $pagenow = strtolower($self_matches[1]); 
     14        if ( '.php' !== substr($pagenow, -4, 4) ) 
     15            $pagenow .= '.php'; // for Options +Multiviews: /wp-admin/themes/index.php (themes.php is queried) 
     16    } 
    1117} else { 
    12     $pagenow = 'index.php'; 
     18    if ( preg_match('#([^/]+\.php)([?/].*?)?$#i', $PHP_SELF, $self_matches) ) 
     19        $pagenow = strtolower($self_matches[1]); 
     20    else 
     21        $pagenow = 'index.php'; 
    1322} 
    1423 
Note: See TracChangeset for help on using the changeset viewer.