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. git-svn-id: https://develop.svn.wordpress.org/trunk@42633 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
212c880d71
commit
40f76ae917
@ -1189,11 +1189,12 @@ if ( ! function_exists( 'wp_redirect' ) ) :
|
||||
*
|
||||
* @global bool $is_IIS
|
||||
*
|
||||
* @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 string $location The path or URL to redirect to.
|
||||
* @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.
|
||||
*/
|
||||
function wp_redirect( $location, $status = 302 ) {
|
||||
function wp_redirect( $location, $status = 302, $x_redirect_by = 'WordPress' ) {
|
||||
global $is_IIS;
|
||||
|
||||
/**
|
||||
@ -1237,7 +1238,7 @@ if ( ! function_exists( 'wp_redirect' ) ) :
|
||||
* @param int $status Status code to use.
|
||||
* @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 ) ) {
|
||||
header( "X-Redirect-By: $x_redirect_by" );
|
||||
}
|
||||
|
@ -176,7 +176,8 @@ class Tests_Pluggable extends WP_UnitTestCase {
|
||||
),
|
||||
'wp_redirect' => array(
|
||||
'location',
|
||||
'status' => 302,
|
||||
'status' => 302,
|
||||
'x_redirect_by' => 'WordPress',
|
||||
),
|
||||
'wp_sanitize_redirect' => array( 'location' ),
|
||||
'_wp_sanitize_utf8_in_redirect' => array( 'matches' ),
|
||||
|
Loading…
x
Reference in New Issue
Block a user