PluginProbe
Redirection / 4.4
Redirection v4.4
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / actions / url.php

url.php in Redirection 4.4, at actions/url.php

32 lines 588 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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