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

51 lines 892 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 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 function get_target( $requested_url, $source_url, Red_Source_Flags $flags ) {
25 $target = $this->url;
26 if ( $flags->is_regex() ) {
27 $target = $this->get_target_regex_url( $source_url, $target, $requested_url, $flags );
28 }
29
30 if ( $target === '' ) {
31 return $matched_url;
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