* @access public
* @var array
*/
- var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'debug', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
+ var $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type');
/**
* Private query variables.
$home_path = trim($home_path, '/');
// Trim path info from the end and the leading home path from the
- // front. For path info requests, this leaves us with the requesting
- // filename, if any. For 404 requests, this leaves us with the
+ // front. For path info requests, this leaves us with the requesting
+ // filename, if any. For 404 requests, this leaves us with the
// requested permalink.
$req_uri = str_replace($pathinfo, '', $req_uri);
$req_uri = trim($req_uri, '/');
}
}
- // query_string filter deprecated. Use request filter instead.
+ // query_string filter deprecated. Use request filter instead.
if ( has_filter('query_string') ) { // Don't bother filtering and parsing if no plugins are hooked in.
$this->query_string = apply_filters('query_string', $this->query_string);
parse_str($this->query_string, $this->query_vars);
function handle_404() {
global $wp_query;
- if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) {
+ // If we've already issued a 404, bail.
+ if ( is_404() )
+ return;
+
+ // Never 404 for the admin, robots, or if we found posts.
+ if ( is_admin() || is_robots() || $wp_query->posts ) {
+ status_header( 200 );
+ return;
+ }
+
+ // We will 404 for paged queries, as no posts were found.
+ if ( ! is_paged() ) {
+
// Don't 404 for these queries if they matched an object.
- if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() && !is_paged() ) {
- if ( !is_404() )
- status_header( 200 );
+ if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() ) {
+ status_header( 200 );
+ return;
+ }
+
+ // Don't 404 for these queries either.
+ if ( is_home() || is_search() ) {
+ status_header( 200 );
return;
}
- $wp_query->set_404();
- status_header( 404 );
- nocache_headers();
- } elseif ( !is_404() ) {
- status_header( 200 );
}
+
+ // Guess it's time to 404.
+ $wp_query->set_404();
+ status_header( 404 );
+ nocache_headers();
}
/**
}
}
-
-?>