PluginProbe
Redirection / 4.3
Redirection v4.3
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 4.3, at matches/url.php

51 lines 920 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 public $url = false;
5
6 public function name() {
7 return __( 'URL only', 'redirection' );
8 }
9
10 public function save( array $details, $no_target_url = false ) {
11 $data = isset( $details['url'] ) ? $details['url'] : '';
12
13 if ( strlen( $data ) === 0 ) {
14 $data = '/';
15 }
16
17 if ( $no_target_url ) {
18 return null;
19 }
20
21 return $this->sanitize_url( $data );
22 }
23
24 public function is_match( $url ) {
25 return true;
26 }
27
28 public function get_target_url( $requested_url, $source_url, Red_Source_Flags $flags, $matched ) {
29 $target = $this->url;
30 if ( $flags->is_regex() ) {
31 $target = $this->get_target_regex_url( $source_url, $target, $requested_url, $flags );
32 }
33
34 return $target;
35 }
36
37 public function get_data() {
38 if ( $this->url ) {
39 return array(
40 'url' => $this->url,
41 );
42 }
43
44 return '';
45 }
46
47 public function load( $values ) {
48 $this->url = $values;
49 }
50 }
51