Make WordPress Core


Ignore:
Timestamp:
02/09/2012 09:04:36 PM (12 years ago)
Author:
ryan
Message:

404 non-existant pages. Make handle_404() readable. Props benbalter, nacin. fixes #15770

File:
1 edited

Legend:

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

    r19712 r19892  
    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
Note: See TracChangeset for help on using the changeset viewer.