Make WordPress Core

Ticket #2409: 2409-rework.diff

File 2409-rework.diff, 3.7 KB (added by rob1n, 18 years ago)
  • wp-includes/query.php

     
    641641
    642642                $this->init_query_flags();
    643643                $this->is_404 = true;
     644               
     645                status_header( 404 );
    644646
    645647                $this->is_feed = $is_feed;
    646648        }
  • wp-includes/wp-db.php

     
    369369        function bail($message) { // Just wraps errors in a nice header and footer
    370370                if ( !$this->show_errors )
    371371                        return false;
    372 
     372               
     373                status_header( 503 );
    373374                header('Content-Type: text/html; charset=utf-8');
    374375
    375376                if (strpos($_SERVER['PHP_SELF'], 'wp-admin') !== false)
  • wp-includes/functions.php

     
    916916        $wp->main($query_vars);
    917917}
    918918
     919function get_status_header_desc( $code ) {
     920        global $wp_header_to_desc;
     921       
     922        $code = (int) $code;
     923       
     924        if ( isset( $wp_header_to_desc[$code] ) ) {
     925                return $wp_header_to_desc[$code];
     926        } else {
     927                return '';
     928        }
     929}
     930
    919931function status_header( $header ) {
    920         if ( 200 == $header )
    921                 $text = 'OK';
    922         elseif ( 301 == $header )
    923                 $text = 'Moved Permanently';
    924         elseif ( 302 == $header )
    925                 $text = 'Moved Temporarily';
    926         elseif ( 304 == $header )
    927                 $text = 'Not Modified';
    928         elseif ( 404 == $header )
    929                 $text = 'Not Found';
    930         elseif ( 410 == $header )
    931                 $text = 'Gone';
    932 
    933         if ( version_compare(phpversion(), '4.3.0', '>=') )
    934                 @header("HTTP/1.1 $header $text", true, $header);
    935         else
    936                 @header("HTTP/1.1 $header $text");
     932        $text = get_status_header( $header );
     933       
     934        if ( empty( $text ) ) {
     935                return false;
     936        } else {
     937                if ( version_compare( phpversion(), '4.3.0', '>=' ) ) {
     938                        return @header( "HTTP/1.1 $header $text", true, $header );
     939                } else {
     940                        return @header( "HTTP/1.1 $header $text" );
     941                }
     942        }
    937943}
    938944
    939945function nocache_headers() {
  • wp-includes/vars.php

     
    3535$is_apache = ((strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false) || (strpos($_SERVER['SERVER_SOFTWARE'], 'LiteSpeed') !== false)) ? true : false;
    3636$is_IIS = (strpos($_SERVER['SERVER_SOFTWARE'], 'Microsoft-IIS') !== false) ? true : false;
    3737
     38$wp_header_to_desc = apply_filters( 'wp_header_to_desc_array', array(
     39        100 => 'Continue',
     40        101 => 'Switching Protocols',
     41       
     42        200 => 'OK',
     43        201 => 'Created',
     44        202 => 'Accepted',
     45        203 => 'Non-Authoritative Information',
     46        204 => 'No Content',
     47        205 => 'Reset Content',
     48        206 => 'Partial Content',
     49       
     50        300 => 'Multiple Choices',
     51        301 => 'Moved Permanently',
     52        302 => 'Found',
     53        303 => 'See Other',
     54        304 => 'Not Modified',
     55        305 => 'Use Proxy',
     56        307 => 'Temporary Redirect',
     57       
     58        400 => 'Bad Request',
     59        401 => 'Unauthorized',
     60        403 => 'Forbidden',
     61        404 => 'Not Found',
     62        405 => 'Method Not Allowed',
     63        406 => 'Not Acceptable',
     64        407 => 'Proxy Authentication Required',
     65        408 => 'Request Timeout',
     66        409 => 'Conflict',
     67        410 => 'Gone',
     68        411 => 'Length Required',
     69        412 => 'Precondition Failed',
     70        413 => 'Request Entity Too Large',
     71        414 => 'Request-URI Too Long',
     72        415 => 'Unsupported Media Type',
     73        416 => 'Requested Range Not Satisfiable',
     74        417 => 'Expectation Failed',
     75       
     76        500 => 'Internal Server Error',
     77        501 => 'Not Implemented',
     78        502 => 'Bad Gateway',
     79        503 => 'Service Unavailable',
     80        504 => 'Gateway Timeout',
     81        505 => 'HTTP Version Not Supported'
     82) );
     83
    3884?>
     85 No newline at end of file