Make WordPress Core


Ignore:
File:
1 edited

Legend:

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

    r19280 r19935  
    1616         * @var array
    1717         */
    18         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');
     18        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');
    1919
    2020        /**
    … …  
    157157
    158158                        // Trim path info from the end and the leading home path from the
    159                         // front.  For path info requests, this leaves us with the requesting
    160                         // filename, if any.  For 404 requests, this leaves us with the
     159                        // front. For path info requests, this leaves us with the requesting
     160                        // filename, if any. For 404 requests, this leaves us with the
    161161                        // requested permalink.
    162162                        $req_uri = str_replace($pathinfo, '', $req_uri);
    … …  
    402402                }
    403403
    404                 // query_string filter deprecated.  Use request filter instead.
     404                // query_string filter deprecated. Use request filter instead.
    405405                if ( has_filter('query_string') ) {  // Don't bother filtering and parsing if no plugins are hooked in.
    406406                        $this->query_string = apply_filters('query_string', $this->query_string);
    … …  
    475475                global $wp_query;
    476476
    477                 if ( !is_admin() && ( 0 == count( $wp_query->posts ) ) && !is_404() && !is_robots() && !is_search() && !is_home() ) {
     477                // If we've already issued a 404, bail.
     478                if ( is_404() )
     479                        return;
     480
     481                // Never 404 for the admin, robots, or if we found posts.
     482                if ( is_admin() || is_robots() || $wp_query->posts ) {
     483                        status_header( 200 );
     484                        return;
     485                }
     486
     487                // We will 404 for paged queries, as no posts were found.
     488                if ( ! is_paged() ) {
     489
    478490                        // Don't 404 for these queries if they matched an object.
    479                         if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() && !is_paged() ) {
    480                                 if ( !is_404() )
    481                                         status_header( 200 );
     491                        if ( ( is_tag() || is_category() || is_tax() || is_author() || is_post_type_archive() ) && $wp_query->get_queried_object() ) {
     492                                status_header( 200 );
    482493                                return;
    483494                        }
    484                         $wp_query->set_404();
    485                         status_header( 404 );
    486                         nocache_headers();
    487                 } elseif ( !is_404() ) {
    488                         status_header( 200 );
    489                 }
     495
     496                        // Don't 404 for these queries either.
     497                        if ( is_home() || is_search() ) {
     498                                status_header( 200 );
     499                                return;
     500                        }
     501                }
     502
     503                // Guess it's time to 404.
     504                $wp_query->set_404();
     505                status_header( 404 );
     506                nocache_headers();
    490507        }
    491508
    … …  
    602619
    603620}
    604 
    605 ?>
Note: See TracChangeset for help on using the changeset viewer.