### Eclipse Workspace Patch 1.0 #P wordpress Index: wp-includes/default-filters.php =================================================================== --- wp-includes/default-filters.php (revision 15308) +++ wp-includes/default-filters.php (working copy) @@ -253,4 +253,7 @@ add_action( 'admin_init', 'register_admin_color_schemes', 1); add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); +// HTTP Redirect Hypertext +add_action( 'redirect_hypertext', 'wp_redirect_hypertext', 10, 3 ); + ?> Index: wp-includes/pluggable.php =================================================================== --- wp-includes/pluggable.php (revision 15308) +++ wp-includes/pluggable.php (working copy) @@ -869,29 +869,82 @@ * * @param string $location The path to redirect to * @param int $status Status code to use + * @param bool $hyptertext Should a Hypertext Fragment be used? * @return bool False if $location is not set */ -function wp_redirect($location, $status = 302) { +function wp_redirect( $location, $status = 302, $hypertext = true ) { global $is_IIS; - $location = apply_filters('wp_redirect', $location, $status); - $status = apply_filters('wp_redirect_status', $status, $location); + $location = apply_filters( 'wp_redirect', $location, $status ); + $status = (int) apply_filters( 'wp_redirect_status', $status, $location ); + $hypertext = apply_filters( 'wp_redirect_hypertext', $hypertext, $status, $location); if ( !$location ) // allows the wp_redirect filter to cancel a redirect return false; + + if ( 3 != (int) ($status/100) ) // Handle HTTP redirect status 3xx only + return false; - $location = wp_sanitize_redirect($location); + $location = wp_sanitize_redirect( $location ); if ( $is_IIS ) { - header("Refresh: 0;url=$location"); + header( "Refresh: 0;url=$location" ); } else { if ( php_sapi_name() != 'cgi-fcgi' ) - status_header($status); // This causes problems on IIS and some FastCGI setups - header("Location: $location", true, $status); + status_header( $status ); // This causes problems on IIS and some FastCGI setups + header( "Location: $location", true, $status ); } + + // output a hypertext fragment? - sometimes wordpress needs to ignore the + // HTTP 1.1 suggestion to output a hypertext fragment on redirects, e.g. with + // plugin activation checks. + if ( !$hypertext ) + return; + + // hyptertext should be output for certain methods / stati only + $method = $_SERVER['REQUEST_METHOD']; + $html = ('HEAD' !== $method) && (301 === $status || 302 === $status || 303 === $status || 307 === $status); + + if ( !$html ) + return; + + $hypertext = sprintf( '%s %s: %s', $status, esc_html( get_status_header_desc( $status ) ), esc_attr( $location ), esc_html( $location ) ); + $hypertext = apply_filters( 'redirect_hypertext', $hypertext, $location, $status ); + + echo $hypertext; } endif; +if ( !function_exists('wp_redirect_hypertext') ) : +/** + * Generate a Hypertext Fragment for a HTTP Redirect + * + * @since 3.1 + * + * @param + * @return hypertext fragment + */ +function wp_redirect_hypertext($hypertext, $location, $status) { + $version = $GLOBALS['wp_version']; + list($link, $title, $description, $charset) = array_map('get_bloginfo', array('wpurl', 'name', 'description', 'charset')); + + $homepage = sprintf('%s - %s', esc_attr( $link ), esc_html( $title ), esc_html( $description ) ); + + ob_start(); +?> +
+