diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 688cf6cb44..291564b44c 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -7,10 +7,7 @@ else require_once(ABSPATH . 'wp-admin/admin-functions.php'); auth_redirect(); -header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-cache, must-revalidate, max-age=0'); -header('Pragma: no-cache'); +nocache_headers(); update_category_cache(); diff --git a/wp-blog-header.php b/wp-blog-header.php index 8508003c51..fec37d8d33 100644 --- a/wp-blog-header.php +++ b/wp-blog-header.php @@ -107,14 +107,11 @@ for ($i=0; $i= $wp_modified_timestamp) && ($client_etag == $wp_etag)) : (($client_modified_timestamp >= $wp_modified_timestamp) || ($client_etag == $wp_etag)) ) { - if ( preg_match('/cgi/',php_sapi_name()) ) { - header('Status: 304 Not Modified'); - echo "\r\n\r\n"; - exit; - } else { - if ( version_compare(phpversion(), '4.3.0', '>=') ) - header('Not Modified', TRUE, 304); - else - header('HTTP/1.x 304 Not Modified'); - exit; - } + status_header( 304 ); + exit; } } @@ -191,10 +178,9 @@ if ( (0 == count($posts)) && !is_404() && !is_search() && ( isset($rewrite) || (!empty($_SERVER['QUERY_STRING']) && (false === strpos($_SERVER['REQUEST_URI'], '?'))) ) ) { $wp_query->is_404 = true; - if ( preg_match('/cgi/', php_sapi_name()) ) - @header('Status: 404 Not Found'); - else - @header('HTTP/1.x 404 Not Found'); + status_header( 404 ); +} else { + status_header( 200 ); } if ($pagenow != 'post.php' && $pagenow != 'edit.php') { diff --git a/wp-comments-post.php b/wp-comments-post.php index c7d5a6fd1e..865bb280ee 100644 --- a/wp-comments-post.php +++ b/wp-comments-post.php @@ -52,10 +52,7 @@ setcookie('comment_author_' . COOKIEHASH, stripslashes($comment_author), time() setcookie('comment_author_email_' . COOKIEHASH, stripslashes($comment_author_email), time() + 30000000, COOKIEPATH); setcookie('comment_author_url_' . COOKIEHASH, stripslashes($comment_author_url), time() + 30000000, COOKIEPATH); -header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-cache, must-revalidate, max-age=0'); -header('Pragma: no-cache'); +nocache_headers(); $location = (empty($_POST['redirect_to'])) ? $_SERVER["HTTP_REFERER"] : $_POST['redirect_to']; diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c35a2795b2..05a0518907 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -1849,4 +1849,36 @@ function wp_remote_fopen( $uri ) { } } +function status_header( $header ) { + if ( 200 == $header ) { + $text = 'OK'; + } elseif ( 301 == $header ) { + $text = 'Moved Permanently'; + } elseif ( 302 == $header ) { + $text = 'Moved Temporarily'; + } elseif ( 304 == $header ) { + $text = 'Not Modified'; + } elseif ( 404 == $header ) { + $text = 'Not Found'; + } elseif ( 410 == $header ) { + $text = 'Gone'; + } + if ( preg_match('/cgi/',php_sapi_name()) ) { + @header("Status: $header $text"); + echo "\r\n\r\n"; + } else { + if ( version_compare(phpversion(), '4.3.0', '>=') ) + @header($text, TRUE, $header); + else + @header("HTTP/1.x $header $text"); + } +} + +function nocache_headers() { + @ header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); + @ header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); + @ header('Cache-Control: no-cache, must-revalidate, max-age=0'); + @ header('Pragma: no-cache'); +} + ?> \ No newline at end of file diff --git a/wp-includes/pluggable-functions.php b/wp-includes/pluggable-functions.php index f16bbfe66c..14437c7317 100644 --- a/wp-includes/pluggable-functions.php +++ b/wp-includes/pluggable-functions.php @@ -106,10 +106,7 @@ function auth_redirect() { if ( (!empty($_COOKIE['wordpressuser_' . COOKIEHASH]) && !wp_login($_COOKIE['wordpressuser_' . COOKIEHASH], $_COOKIE['wordpresspass_' . COOKIEHASH], true)) || (empty($_COOKIE['wordpressuser_' . COOKIEHASH])) ) { - header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: no-cache, must-revalidate, max-age=0'); - header('Pragma: no-cache'); + nocache_headers(); header('Location: ' . get_settings('siteurl') . '/wp-login.php?redirect_to=' . urlencode($_SERVER['REQUEST_URI'])); exit(); diff --git a/wp-login.php b/wp-login.php index 734944fb41..dafa1e8dda 100644 --- a/wp-login.php +++ b/wp-login.php @@ -4,10 +4,8 @@ require( dirname(__FILE__) . '/wp-config.php' ); $action = $_REQUEST['action']; $error = ''; -header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); -header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); -header('Cache-Control: no-cache, must-revalidate'); -header('Pragma: no-cache'); +nocache_headers(); + header('Content-Type: '.get_bloginfo('html_type').'; charset='.get_bloginfo('charset')); if ( defined('RELOCATE') ) { // Move flag is set @@ -24,10 +22,7 @@ case 'logout': wp_clearcookie(); do_action('wp_logout'); - header('Expires: Wed, 11 Jan 1984 05:00:00 GMT'); - header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); - header('Cache-Control: no-cache, must-revalidate, max-age=0'); - header('Pragma: no-cache'); + nocache_headers(); wp_redirect('wp-login.php'); exit();