Make WordPress Core

Ticket #10722: handle_404.patch

File handle_404.patch, 1.2 KB (added by prettyboymp, 15 years ago)
  • classes.php

     
    459459        function handle_404() {
    460460                global $wp_query;
    461461
    462                 if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) {
    463                         // Don't 404 for these queries if they matched an object.
    464                         if ( ( is_tag() || is_category() || is_author() ) && $wp_query->get_queried_object() ) {
    465                                 if ( !is_404() )
    466                                         status_header( 200 );
    467                                 return;
    468                         }
     462                $handle_404 = false;
     463
     464                if ( (0 == count($wp_query->posts)) && !is_404() && !is_search() && ( $this->did_permalink || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) && ( ( is_tag() || is_category() || is_author() ) && $wp_query->get_queried_object() ) ) {
     465                        $handle_404 = true;
     466                }
     467
     468                if(apply_filters('handle_404', $handle_404))
     469                {
    469470                        $wp_query->set_404();
    470471                        status_header( 404 );
    471472                        nocache_headers();
    472                 } elseif ( !is_404() ) {
     473                }
     474                elseif(!is_404())
     475                {
    473476                        status_header( 200 );
    474477                }
    475478        }