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