| 1 |
<?php |
| 2 |
/** |
| 3 |
* Redirection |
| 4 |
* |
| 5 |
* @package Redirection |
| 6 |
* @author John Godley |
| 7 |
* @copyright Copyright (C) John Godley |
| 8 |
**/ |
| 9 |
|
| 10 |
/* |
| 11 |
============================================================================================================ |
| 12 |
This software is provided "as is" and any express or implied warranties, including, but not limited to, the |
| 13 |
implied warranties of merchantibility and fitness for a particular purpose are disclaimed. In no event shall |
| 14 |
the copyright owner or contributors be liable for any direct, indirect, incidental, special, exemplary, or |
| 15 |
consequential damages (including, but not limited to, procurement of substitute goods or services; loss of |
| 16 |
use, data, or profits; or business interruption) however caused and on any theory of liability, whether in |
| 17 |
contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of |
| 18 |
this software, even if advised of the possibility of such damage. |
| 19 |
|
| 20 |
For full license details see license.txt |
| 21 |
============================================================================================================ */ |
| 22 |
|
| 23 |
class URL_Match extends Red_Match { |
| 24 |
function name () { |
| 25 |
return __( 'URL only', 'redirection' ); |
| 26 |
} |
| 27 |
|
| 28 |
function show() { |
| 29 |
?> |
| 30 |
<?php if ( $this->action->can_perform_action() ) : ?> |
| 31 |
<tr> |
| 32 |
<th><a target="_blank" href="<?php echo esc_url( $this->url ) ?>"><?php _e( 'Target URL', 'redirection' ); ?>:</a></th> |
| 33 |
<td> |
| 34 |
<input style="width: 95%" type="text" name="target" value="<?php echo esc_attr( $this->url ); ?>"/> |
| 35 |
</td> |
| 36 |
</tr> |
| 37 |
<?php endif; ?> |
| 38 |
<?php if ( $this->action->can_change_code() ) : ?> |
| 39 |
<tr class="advanced"> |
| 40 |
<th><?php _e( 'HTTP Code', 'redirection' ); ?>:</th> |
| 41 |
<td> |
| 42 |
<select name="action_code"> |
| 43 |
<?php $this->action->display_actions(); ?> |
| 44 |
</select> |
| 45 |
</td> |
| 46 |
</tr> |
| 47 |
<?php endif; |
| 48 |
} |
| 49 |
|
| 50 |
function save( $details ) { |
| 51 |
if ( !isset( $details['target'] ) || strlen( $details['target'] ) == 0 ) |
| 52 |
$details['target'] = '/'; |
| 53 |
|
| 54 |
return array( 'url' => $details['target'] ); |
| 55 |
} |
| 56 |
|
| 57 |
function get_target( $url, $matched_url, $regex ) { |
| 58 |
$target = $this->url; |
| 59 |
if ( $regex ) |
| 60 |
$target = preg_replace( '@'.str_replace( '@', '\\@', $matched_url ).'@', $this->url, $url ); |
| 61 |
|
| 62 |
if ( $target == '' ) |
| 63 |
return $matched_url; |
| 64 |
return $target; |
| 65 |
} |
| 66 |
} |
| 67 |
|