Skip to content

Commit

Permalink
Merge pull request #281 from 10up/fix/280-x-redirect-by-header
Browse files Browse the repository at this point in the history
Indiciate plugin as source of redirect.
  • Loading branch information
peterwilsoncc authored Aug 24, 2022
2 parents 163d0c6 + 1f4eb48 commit 1bdd248
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions inc/classes/class-srm-redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 1bdd248

Please sign in to comment.