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

60 lines 984 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Match the URL only.
5 */
6 class URL_Match extends Red_Match {
7 /**
8 * URL
9 *
10 * @var String
11 */
12 public $url = '';
13
14 public function name() {
15 return __( 'URL only', 'redirection' );
16 }
17
18 public function save( array $details, $no_target_url = false ) {
19 $data = isset( $details['url'] ) ? $details['url'] : '';
20
21 if ( strlen( $data ) === 0 ) {
22 $data = '/';
23 }
24
25 if ( $no_target_url ) {
26 return null;
27 }
28
29 return $this->sanitize_url( $data );
30 }
31
32 public function is_match( $url ) {
33 return true;
34 }
35
36 public function get_target_url( $original_url, $matched_url, Red_Source_Flags $flag, $is_matched ) {
37 $target = $this->url;
38
39 if ( $flag->is_regex() ) {
40 $target = $this->get_target_regex_url( $matched_url, $target, $original_url, $flag );
41 }
42
43 return $target;
44 }
45
46 public function get_data() {
47 if ( $this->url ) {
48 return [
49 'url' => $this->url,
50 ];
51 }
52
53 return null;
54 }
55
56 public function load( $values ) {
57 $this->url = $values;
58 }
59 }
60