Canonical: Add $x_redirect_by parameter to wp_redirect() that allows applications doing the redirect to identify themselves.

This complements the `x_redirect_by` filter added in [42408].

Props NathanAtmoz, johnbillion.
Fixes #42313.
Built from https://develop.svn.wordpress.org/trunk@42633


git-svn-id: http://core.svn.wordpress.org/trunk@42462 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2018-02-01 15:06:35 +00:00
parent 1e5629d1f1
commit 673ff22b2b
2 changed files with 6 additions and 5 deletions

View File

@ -1189,11 +1189,12 @@ if ( ! function_exists( 'wp_redirect' ) ) :
* *
* @global bool $is_IIS * @global bool $is_IIS
* *
* @param string $location The path or URL to redirect to. * @param string $location The path or URL to redirect to.
* @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily). * @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily).
* @param string $x_redirect_by Optional. The application doing the redirect. Default 'WordPress'.
* @return bool False if the redirect was cancelled, true otherwise. * @return bool False if the redirect was cancelled, true otherwise.
*/ */
function wp_redirect( $location, $status = 302 ) { function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
global $is_IIS; global $is_IIS;
/** /**
@ -1237,7 +1238,7 @@ if ( ! function_exists( 'wp_redirect' ) ) :
* @param int $status Status code to use. * @param int $status Status code to use.
* @param string $location The path to redirect to. * @param string $location The path to redirect to.
*/ */
$x_redirect_by = apply_filters( 'x_redirect_by', 'WordPress', $status, $location ); $x_redirect_by = apply_filters( 'x_redirect_by', $x_redirect_by, $status, $location );
if ( is_string( $x_redirect_by ) ) { if ( is_string( $x_redirect_by ) ) {
header( "X-Redirect-By: $x_redirect_by" ); header( "X-Redirect-By: $x_redirect_by" );
} }

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '5.0-alpha-42632'; $wp_version = '5.0-alpha-42633';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.