| 1 |
<?php |
| 2 |
|
| 3 |
class Url_Action extends Red_Action { |
| 4 |
protected function redirect_to( $code, $target ) { |
| 5 |
add_filter( 'x_redirect_by', [ $this, 'x_redirect_by' ] ); |
| 6 |
|
| 7 |
$redirect = wp_redirect( $target, $code ); |
| 8 |
|
| 9 |
if ( $redirect ) { |
| 10 |
global $wp_version; |
| 11 |
|
| 12 |
if ( version_compare( $wp_version, '5.1', '<' ) ) { |
| 13 |
header( 'X-Redirect-Agent: redirection' ); |
| 14 |
} |
| 15 |
|
| 16 |
die(); |
| 17 |
} |
| 18 |
} |
| 19 |
|
| 20 |
public function process_after( $code, $target ) { |
| 21 |
$this->redirect_to( $code, $target ); |
| 22 |
} |
| 23 |
|
| 24 |
public function needs_target() { |
| 25 |
return true; |
| 26 |
} |
| 27 |
|
| 28 |
public function x_redirect_by() { |
| 29 |
return 'redirection'; |
| 30 |
} |
| 31 |
} |
| 32 |
|