| 1 |
<?php |
| 2 |
|
| 3 |
class URL_Match extends Red_Match { |
| 4 |
function name () { |
| 5 |
return __( 'URL only', 'redirection' ); |
| 6 |
} |
| 7 |
|
| 8 |
function show() { |
| 9 |
?> |
| 10 |
<?php if ( $this->action->can_perform_action() ) : ?> |
| 11 |
<tr> |
| 12 |
<th><a target="_blank" href="<?php echo esc_url( $this->url ) ?>"><?php _e( 'Target URL', 'redirection' ); ?>:</a></th> |
| 13 |
<td> |
| 14 |
<input style="width: 95%" type="text" name="target" value="<?php echo esc_attr( $this->url ); ?>"/> |
| 15 |
</td> |
| 16 |
</tr> |
| 17 |
<?php endif; ?> |
| 18 |
<?php if ( $this->action->can_change_code() ) : ?> |
| 19 |
<tr class="advanced"> |
| 20 |
<th><?php _e( 'HTTP Code', 'redirection' ); ?>:</th> |
| 21 |
<td> |
| 22 |
<select name="action_code"> |
| 23 |
<?php $this->action->display_actions(); ?> |
| 24 |
</select> |
| 25 |
</td> |
| 26 |
</tr> |
| 27 |
<?php endif; |
| 28 |
} |
| 29 |
|
| 30 |
function save( $details ) { |
| 31 |
if ( ! isset( $details['target'] ) || strlen( $details['target'] ) === 0 ) |
| 32 |
$details['target'] = '/'; |
| 33 |
|
| 34 |
return array( 'url' => $this->sanitize_url( $details['target'] ) ); |
| 35 |
} |
| 36 |
|
| 37 |
function get_target( $url, $matched_url, $regex ) { |
| 38 |
$target = $this->url; |
| 39 |
if ( $regex ) |
| 40 |
$target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url ); |
| 41 |
|
| 42 |
if ( $target === '' ) |
| 43 |
return $matched_url; |
| 44 |
return $target; |
| 45 |
} |
| 46 |
} |
| 47 |
|