| 1 |
<?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?> |
| 2 |
<div class="wrap" id="add" <?php if ($hidden) echo ' style="display: none"' ?>> |
| 3 |
<h2><?php _e ('Add new redirection', 'redirection') ?></h2> |
| 4 |
|
| 5 |
<div id="added" style="display: none" class="updated-red"> |
| 6 |
<p><?php _e ('Your redirection has been added.', 'redirection'); ?></p> |
| 7 |
</div> |
| 8 |
|
| 9 |
<form method="post" action="<?php echo admin_url( 'admin-ajax.php' ); ?>" id="new-redirection"> |
| 10 |
<table width="100%"> |
| 11 |
<tr> |
| 12 |
<th align="right" width="100"><?php _e ('Source URL', 'redirection') ?>:</th> |
| 13 |
<td><input type="text" name="source" style="width: 95%" id="old"/></td> |
| 14 |
</tr> |
| 15 |
<tr> |
| 16 |
<th align="right"><?php _e ('Match', 'redirection') ?>:</th> |
| 17 |
<td> |
| 18 |
<select name="match"> |
| 19 |
<?php echo $this->select (Red_Match::all ()); ?> |
| 20 |
</select> |
| 21 |
|
| 22 |
<strong><?php _e ('Action', 'redirection'); ?>:</strong> |
| 23 |
<select name="red_action" onchange="return change_add_redirect (this)"> |
| 24 |
<?php echo $this->select (Red_Item::actions (), 'url'); ?> |
| 25 |
</select> |
| 26 |
|
| 27 |
<label><?php _e ('Regular expression', 'redirection'); ?>: <input id="regex" type="checkbox" name="regex"/></label> |
| 28 |
</td> |
| 29 |
</tr> |
| 30 |
<tr id="target"> |
| 31 |
<th align="right"><?php _e ('Target URL', 'redirection') ?>:</th> |
| 32 |
<td><input type="text" name="target" style="width: 95%"/></td> |
| 33 |
</tr> |
| 34 |
<?php if (!isset($group)) : ?> |
| 35 |
<tr> |
| 36 |
<th><?php _e ('Group', 'redirection'); ?>:</th> |
| 37 |
<td><select name="group"><?php echo $this->select (Red_Group::get_for_select (), isset ($_GET['group']) ? intval ($_GET['group']) : 0)?></select></td> |
| 38 |
</tr> |
| 39 |
<?php endif; ?> |
| 40 |
<tr> |
| 41 |
<th></th> |
| 42 |
<td> |
| 43 |
<input class="button-primary" type="submit" name="add" value="<?php _e ('Add Redirection', 'redirection') ?>" id="submit"/> |
| 44 |
<?php if (isset($group)) : ?> |
| 45 |
<input type="hidden" name="group" value="<?php echo esc_attr( $group ) ?>"/> |
| 46 |
<?php endif; ?> |
| 47 |
|
| 48 |
<input type="hidden" name="action" value="red_redirect_add"/> |
| 49 |
<input type="hidden" name="_ajax_nonce" value="<?php echo wp_create_nonce( 'redirection-redirect_add' ); ?>"/> |
| 50 |
|
| 51 |
<div id="error"></div> |
| 52 |
</td> |
| 53 |
</tr> |
| 54 |
</table> |
| 55 |
</form> |
| 56 |
</div> |
| 57 |
|
| 58 |
<script type="text/javascript" charset="utf-8"> |
| 59 |
jQuery( '#new-redirection' ).ajaxForm( { |
| 60 |
beforeSubmit: function () { |
| 61 |
jQuery( '#loading' ).show (); |
| 62 |
}, |
| 63 |
success: function( response ) { |
| 64 |
jQuery( '#loading' ).hide (); |
| 65 |
|
| 66 |
if ( response.indexOf( 'fade error' ) != -1 ) |
| 67 |
jQuery( '#error' ).html (response); |
| 68 |
else { |
| 69 |
<?php if ( isset( $add_to_screen ) ) : ?> |
| 70 |
jQuery( '#items' ).append( response ); |
| 71 |
<?php endif; ?> |
| 72 |
|
| 73 |
jQuery( '#error' ).hide(); |
| 74 |
jQuery( '#added' ).show(); |
| 75 |
jQuery( '#none' ).hide(); |
| 76 |
|
| 77 |
redirection.edit_items( 'redirect' ); |
| 78 |
} |
| 79 |
} |
| 80 |
}); |
| 81 |
</script> |
| 82 |
|