From ab714bd549ccaff24a1bc096e391f4b2f7d123e6 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 20 Nov 2017 20:23:50 +0000 Subject: [PATCH] General: Pass on the return value from `wp_redirect()` for `wp_safe_redirect()`. This brings the behaviour of the two functions in line with each other. Props Drivingralle Fixes 42108 git-svn-id: https://develop.svn.wordpress.org/trunk@42206 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/pluggable.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/pluggable.php b/src/wp-includes/pluggable.php index 927302b0d8..294b3e4763 100644 --- a/src/wp-includes/pluggable.php +++ b/src/wp-includes/pluggable.php @@ -1285,10 +1285,19 @@ if ( !function_exists('wp_safe_redirect') ) : * wp_safe_redirect( $url ); * exit; * + * Exiting can also be selectively manipulated by using wp_safe_redirect() as a conditional + * in conjunction with the {@see 'wp_redirect'} and {@see 'wp_redirect_location'} filters: + * + * if ( wp_safe_redirect( $url ) ) { + * exit; + * } + * * @since 2.3.0 + * @since 5.0.0 The return value from wp_redirect() is now passed on. * * @param string $location The path or URL to redirect to. * @param int $status Optional. HTTP response status code to use. Default '302' (Moved Temporarily). + * @return bool $redirect False if the redirect was cancelled, true otherwise. */ function wp_safe_redirect($location, $status = 302) { @@ -1305,7 +1314,7 @@ function wp_safe_redirect($location, $status = 302) { */ $location = wp_validate_redirect( $location, apply_filters( 'wp_safe_redirect_fallback', admin_url(), $status ) ); - wp_redirect($location, $status); + return wp_redirect( $location, $status ); } endif;