Changeset 1570
- Timestamp:
- 08/27/2004 08:59:38 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-blog-header.php
r1558 r1570 9 9 require_once( dirname(__FILE__) . '/wp-includes/wp-l10n.php'); 10 10 11 // Process PATH_INFO, if set. 12 $path_info = array(); 13 if ( !empty( $_SERVER['PATH_INFO'] ) ) { 11 $query_vars = array(); 12 13 // Process PATH_INFO and 404. 14 if ((isset($_GET['error']) && $_GET['error'] == '404') || 15 (! empty( $_SERVER['PATH_INFO']))) { 16 14 17 // Fetch the rewrite rules. 15 18 $rewrite = rewrite_rules('matches'); 16 19 17 $pathinfo = $_SERVER['PATH_INFO'];18 // Trim leading '/'.19 $pathinfo = preg_replace('!^/!', '', $pathinfo);20 21 20 if (! empty($rewrite)) { 22 // Get the name of the file requesting path info. 23 $req_uri = $_SERVER['REQUEST_URI']; 21 $pathinfo = $_SERVER['PATH_INFO']; 22 $req_uri = $_SERVER['REQUEST_URI']; 23 $home_path = parse_url(get_settings('home')); 24 $home_path = $home_path['path']; 25 26 // Trim path info from the end and the leading home path from the 27 // front. For path info requests, this leaves us with the requesting 28 // filename, if any. For 404 requests, this leaves us with the 29 // requested permalink. 24 30 $req_uri = str_replace($pathinfo, '', $req_uri); 25 $req_uri = preg_replace("!/+$!", '', $req_uri); 26 $req_uri = explode('/', $req_uri); 27 $req_uri = $req_uri[count($req_uri)-1]; 31 $req_uri = str_replace($home_path, '', $req_uri); 32 $req_uri = trim($req_uri, '/'); 33 $pathinfo = trim($pathinfo, '/'); 34 35 // The requested permalink is in $pathinfo for path info requests and 36 // $req_uri for other requests. 37 if (! empty($pathinfo)) { 38 $request = $pathinfo; 39 } else { 40 $request = $req_uri; 41 } 28 42 29 43 // Look for matches. 30 $pathinfomatch = $pathinfo;44 $request_match = $request; 31 45 foreach ($rewrite as $match => $query) { 32 // If the request URIis the anchor of the match, prepend it46 // If the requesting file is the anchor of the match, prepend it 33 47 // to the path info. 34 35 $pathinfomatch = $req_uri . '/' . $pathinfo;36 37 38 if (preg_match("!^$match!", $ pathinfomatch, $matches)) {48 if ((! empty($req_uri)) && (strpos($match, $req_uri) === 0)) { 49 $request_match = $req_uri . '/' . $request; 50 } 51 52 if (preg_match("!^$match!", $request_match, $matches)) { 39 53 // Got a match. 40 54 // Trim the query of everything up to the '?'. … … 45 59 46 60 // Parse the query. 47 parse_str($query, $path_info); 61 parse_str($query, $query_vars); 62 63 // If we're processing a 404 request, clear the error var 64 // since we found something. 65 if (isset($_GET['error'])) { 66 unset($_GET['error']); 67 } 68 48 69 break; 49 70 } 50 71 } 51 } 52 } 53 54 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename' );72 } 73 } 74 75 $wpvarstoreset = array('m','p','posts','w', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'feed', 'author_name', 'static', 'pagename', 'error'); 55 76 56 77 for ($i=0; $i<count($wpvarstoreset); $i += 1) { … … 58 79 if (!isset($$wpvar)) { 59 80 if (empty($_POST[$wpvar])) { 60 if (empty($_GET[$wpvar]) && empty($ path_info[$wpvar])) {81 if (empty($_GET[$wpvar]) && empty($query_vars[$wpvar])) { 61 82 $$wpvar = ''; 62 83 } elseif (!empty($_GET[$wpvar])) { 63 84 $$wpvar = $_GET[$wpvar]; 64 85 } else { 65 $$wpvar = $ path_info[$wpvar];86 $$wpvar = $query_vars[$wpvar]; 66 87 } 67 88 } else { … … 200 221 include(ABSPATH . 'wp-content/search.php'); 201 222 exit; 223 } else if (is_404() && (! isset($wp_did_404)) && 224 file_exists(ABSPATH . 'wp-content/404.php')) { 225 $wp_did_404 = true; 226 include(ABSPATH . 'wp-content/404.php'); 227 exit; 202 228 } else if (is_feed() && $pagenow != 'wp-feed.php') { 203 229 include(dirname(__FILE__) . '/wp-feed.php'); -
trunk/wp-includes/classes.php
r1558 r1570 23 23 var $is_feed = false; 24 24 var $is_home = false; 25 var $is_404 = false; 25 26 26 27 function init () { … … 38 39 $this->is_feed = false; 39 40 $this->is_home = false; 41 $this->is_404 = false; 40 42 41 43 unset($this->posts); … … 161 163 } 162 164 165 if ('' != $qv['error'] || '404' == $qv['pagename']) { 166 $this->is_404 = true; 167 } 168 163 169 if ( ($this->is_date || $this->is_author || $this->is_category) 164 170 && (! ($this->is_single || $this->is_page)) ) { … … 166 172 } 167 173 168 if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed )) {174 if ( ! ($this->is_archive || $this->is_single || $this->is_page || $this->is_search || $this->is_feed || $this->is_404)) { 169 175 $this->is_home = true; 170 176 } -
trunk/wp-includes/functions.php
r1558 r1570 1663 1663 } 1664 1664 1665 function is_404 () { 1666 global $wp_query; 1667 1668 return $wp_query->is_404; 1669 } 1670 1665 1671 function get_query_var($var) { 1666 1672 global $wp_query;
Note: See TracChangeset
for help on using the changeset viewer.