Add an optional $description parameter to status_header() so custom HTTP status descriptions can be provided.

Fixes #21472
Props nbachiyski, iamfriendly


git-svn-id: https://develop.svn.wordpress.org/trunk@34914 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn 2015-10-07 21:25:54 +00:00
parent 8483316de5
commit b877e3c692

View File

@ -981,16 +981,21 @@ function get_status_header_desc( $code ) {
* Set HTTP status header. * Set HTTP status header.
* *
* @since 2.0.0 * @since 2.0.0
* @since 4.4.0 Added the `$description` parameter.
* *
* @see get_status_header_desc() * @see get_status_header_desc()
* *
* @param int $code HTTP status code. * @param int $code HTTP status code.
* @param string $description Optional. A custom description for the HTTP status.
*/ */
function status_header( $code ) { function status_header( $code, $description = '' ) {
$description = get_status_header_desc( $code ); if ( ! $description ) {
$description = get_status_header_desc( $code );
}
if ( empty( $description ) ) if ( empty( $description ) ) {
return; return;
}
$protocol = wp_get_server_protocol(); $protocol = wp_get_server_protocol();
$status_header = "$protocol $code $description"; $status_header = "$protocol $code $description";