| 1 |
<?php |
| 2 |
|
| 3 |
class URL_Match extends Red_Match { |
| 4 |
function name () { |
| 5 |
return __( 'URL only', 'redirection' ); |
| 6 |
} |
| 7 |
|
| 8 |
public function save( array $details, $no_target_url = false ) { |
| 9 |
if ( ! isset( $details['action_data'] ) || strlen( $details['action_data'] ) === 0 ) { |
| 10 |
$details['action_data'] = '/'; |
| 11 |
} |
| 12 |
|
| 13 |
if ( $no_target_url ) { |
| 14 |
return null; |
| 15 |
} |
| 16 |
|
| 17 |
return $this->sanitize_url( $details['action_data'] ); |
| 18 |
} |
| 19 |
|
| 20 |
function get_target( $url, $matched_url, $regex ) { |
| 21 |
$target = $this->url; |
| 22 |
if ( $regex ) { |
| 23 |
$target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url ); |
| 24 |
} |
| 25 |
|
| 26 |
if ( $target === '' ) { |
| 27 |
return $matched_url; |
| 28 |
} |
| 29 |
|
| 30 |
return $target; |
| 31 |
} |
| 32 |
} |
| 33 |
|