| 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 |
|