PluginProbe
Redirection / 2.7
Redirection v2.7
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 / matches / url.php

url.php in Redirection 2.7, at matches/url.php

33 lines 685 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class URL_Match extends Red_Match {
4 function name () {
5 return __( 'URL only', 'redirection' );
6 }
7
8 public function save( array $details, $no_target_url = false ) {
9 if ( ! isset( $details['action_data'] ) || strlen( $details['action_data'] ) === 0 ) {
10 $details['action_data'] = '/';
11 }
12
13 if ( $no_target_url ) {
14 return null;
15 }
16
17 return $this->sanitize_url( $details['action_data'] );
18 }
19
20 function get_target( $url, $matched_url, $regex ) {
21 $target = $this->url;
22 if ( $regex ) {
23 $target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url );
24 }
25
26 if ( $target === '' ) {
27 return $matched_url;
28 }
29
30 return $target;
31 }
32 }
33