From ab5222786a52d91dba644664c4f2babe515f0200 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 18 Dec 2017 01:03:06 +0000 Subject: [PATCH] Canonical: Introduce `x_redirect_by` filter that allows applications to identify themselves via `X-Redirect-By` header when they're doing a redirect. Props joostdevalk. Fixes #42313. git-svn-id: https://develop.svn.wordpress.org/trunk@42408 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index b50772b99c..c41fd2458b 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -1226,6 +1226,22 @@ if ( ! function_exists( 'wp_redirect' ) ) : status_header( $status ); // This causes problems on IIS and some FastCGI setups } + /** + * Filters the X-Redirect-By header. + * + * Allows applications to identify themselves when they're doing a redirect. + * + * @since 5.0.0 + * + * @param string $x_redirect_by The application doing the 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 ); + if ( is_string( $x_redirect_by ) ) { + header( sprintf( "X-Redirect-By: %s", $x_redirect_by ) ); + } + header( "Location: $location", true, $status ); return true;