| @@ -13,13 +13,16 @@ | ||
| 13 | 13 | * @codeCoverageIgnore It only wraps a WordPress function. |
| 14 | 14 | * |
| 15 | 15 | * @param string $location The path to redirect to. |
| 16 | 16 | * @param int $status The status code to use. |
| 17 | + * @param string $reason The reason for the redirect. | |
| 18 | + * | |
| 19 | + * @return void | |
| 17 | 20 | */ |
| 18 | - public function do_unsafe_redirect( $location, $status = 302 ) { | |
| 21 | + public function do_unsafe_redirect( $location, $status = 302, $reason = 'Yoast SEO' ) { | |
| 19 | 22 | // phpcs:ignore WordPress.Security.SafeRedirect -- intentional, function has been renamed to make unsafe more clear. |
| 20 | - \wp_redirect( $location, $status, 'Yoast SEO' ); | |
| 21 | - exit; | |
| 23 | + \wp_redirect( $location, $status, $reason ); | |
| 24 | + exit(); | |
| 22 | 25 | } |
| 23 | 26 | |
| 24 | 27 | /** |
| 25 | 28 | * Wraps wp_safe_redirect to allow testing for safe redirects. |
| @@ -27,25 +30,41 @@ | ||
| 27 | 30 | * @codeCoverageIgnore It only wraps a WordPress function. |
| 28 | 31 | * |
| 29 | 32 | * @param string $location The path to redirect to. |
| 30 | 33 | * @param int $status The status code to use. |
| 34 | + * @param string $reason The reason for the redirect. | |
| 35 | + * | |
| 36 | + * @return void | |
| 31 | 37 | */ |
| 32 | - public function do_safe_redirect( $location, $status = 302 ) { | |
| 33 | - \wp_safe_redirect( $location, $status, 'Yoast SEO' ); | |
| 34 | - exit; | |
| 38 | + public function do_safe_redirect( $location, $status = 302, $reason = 'Yoast SEO' ) { | |
| 39 | + \wp_safe_redirect( $location, $status, $reason ); | |
| 40 | + exit(); | |
| 35 | 41 | } |
| 36 | 42 | |
| 37 | 43 | /** |
| 38 | - * Wraps wp_redirect to allow testing for redirects. | |
| 44 | + * Sets a header. | |
| 45 | + * This is a tiny helper function to enable better testing. | |
| 39 | 46 | * |
| 40 | - * @deprecated 16.x | |
| 41 | 47 | * @codeCoverageIgnore It only wraps a WordPress function. |
| 42 | 48 | * |
| 43 | - * @param string $location The path to redirect to. | |
| 44 | - * @param int $status The status code to use. | |
| 49 | + * @param string $header The header to set. | |
| 50 | + * | |
| 51 | + * @return void | |
| 45 | 52 | */ |
| 46 | - public function do_redirect( $location, $status = 302 ) { | |
| 47 | - \_deprecated_function( __METHOD__, 'WPSEO 16.x', 'Yoast\WP\SEO\Helpers\Redirect_Helper::do_unsafe_redirect' ); | |
| 53 | + public function set_header( $header ) { | |
| 54 | + \header( $header ); | |
| 55 | + } | |
| 48 | 56 | |
| 49 | - $this->do_unsafe_redirect( $location, $status ); | |
| 57 | + /** | |
| 58 | + * Removes a header. | |
| 59 | + * This is a tiny helper function to enable better testing. | |
| 60 | + * | |
| 61 | + * @codeCoverageIgnore It only wraps a WordPress function. | |
| 62 | + * | |
| 63 | + * @param string $header The header to remove. | |
| 64 | + * | |
| 65 | + * @return void | |
| 66 | + */ | |
| 67 | + public function remove_header( $header ) { | |
| 68 | + \header_remove( $header ); | |
| 50 | 69 | } |
| 51 | 70 | } |