From 1f4eb489af6773939913a363778812838f1ec9ef Mon Sep 17 00:00:00 2001 From: Peter Wilson <519727+peterwilsoncc@users.noreply.github.com> Date: Tue, 23 Aug 2022 10:36:48 +1000 Subject: [PATCH] Indiciate plugin as source of redirect. --- inc/classes/class-srm-redirect.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/inc/classes/class-srm-redirect.php b/inc/classes/class-srm-redirect.php index b03bc667..7c546745 100644 --- a/inc/classes/class-srm-redirect.php +++ b/inc/classes/class-srm-redirect.php @@ -245,13 +245,12 @@ public function maybe_redirect() { header( 'X-Safe-Redirect-Manager: true' ); header( 'X-Safe-Redirect-ID: ' . esc_attr( $matched_redirect['redirect_id'] ) ); - // if we have a valid status code, then redirect with it - if ( in_array( $matched_redirect['status_code'], srm_get_valid_status_codes(), true ) ) { - wp_safe_redirect( $matched_redirect['redirect_to'], $matched_redirect['status_code'] ); - } else { - wp_safe_redirect( $matched_redirect['redirect_to'] ); + // Use default status code if an invalid value is set. + if ( ! in_array( $matched_redirect['status_code'], srm_get_valid_status_codes(), true ) ) { + $matched_redirect['status_code'] = apply_filters( 'srm_default_direct_status', 302 ); } + wp_safe_redirect( $matched_redirect['redirect_to'], $matched_redirect['status_code'], 'Safe Redirect Manager' ); exit; }