|
1 | 1 | <?php |
2 | 2 | require_once('admin.php'); |
3 | 3 |
|
| 4 | +// Handle bulk deletes |
| 5 | +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) { |
| 6 | + check_admin_referer('bulk-link-categories'); |
| 7 | + |
| 8 | + if ( !current_user_can('manage_categories') ) |
| 9 | + wp_die(__('Cheatin’ uh?')); |
| 10 | + |
| 11 | + foreach( (array) $_GET['delete'] as $cat_ID ) { |
| 12 | + $cat_name = get_term_field('name', $cat_ID, 'link_category'); |
| 13 | + |
| 14 | + // Don't delete the default cats. |
| 15 | + if ( $cat_ID == get_option('default_link_category') ) |
| 16 | + wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); |
| 17 | + |
| 18 | + wp_delete_term($cat_ID, 'link_category'); |
| 19 | + } |
| 20 | + |
| 21 | + wp_redirect('edit-link-categories.php?message=6'); |
| 22 | + exit(); |
| 23 | +} |
| 24 | + |
4 | 25 | $title = __('Link Categories'); |
5 | 26 | $parent_file = 'edit.php'; |
6 | 27 |
|
7 | 28 | wp_enqueue_script( 'admin-categories' ); |
| 29 | +wp_enqueue_script('admin-forms'); |
| 30 | + |
8 | 31 | require_once ('admin-header.php'); |
9 | 32 |
|
10 | 33 | $messages[1] = __('Category added.'); |
11 | 34 | $messages[2] = __('Category deleted.'); |
12 | 35 | $messages[3] = __('Category updated.'); |
13 | 36 | $messages[4] = __('Category not added.'); |
14 | 37 | $messages[5] = __('Category not updated.'); |
| 38 | +$messages[6] = __('Categories deleted.'); |
15 | 39 |
|
16 | 40 | if (isset($_GET['message'])) : ?> |
17 | 41 |
|
|
55 | 79 | ?> |
56 | 80 |
|
57 | 81 | <div style="float: left"> |
58 | | -<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" /> |
| 82 | +<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" /> |
| 83 | +<?php wp_nonce_field('bulk-link-categories'); ?> |
59 | 84 | </div> |
60 | 85 |
|
61 | 86 | <br style="clear:both;" /> |
62 | 87 | </div> |
63 | | -</form> |
64 | 88 |
|
65 | 89 | <br style="clear:both;" /> |
66 | 90 |
|
67 | 91 | <table class="widefat"> |
68 | 92 | <thead> |
69 | 93 | <tr> |
70 | | - <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('deletetags'));" /></th> |
| 94 | + <th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th> |
71 | 95 | <th scope="col"><?php _e('Name') ?></th> |
72 | 96 | <th scope="col"><?php _e('Description') ?></th> |
73 | 97 | <th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th> |
|
95 | 119 | ?> |
96 | 120 | </tbody> |
97 | 121 | </table> |
| 122 | +</form> |
98 | 123 |
|
99 | 124 | <br style="clear:both;" /> |
100 | 125 |
|
|
0 commit comments