Skip to content

Commit c75599d

Browse files
committed
Bulk link category delete
git-svn-id: https://develop.svn.wordpress.org/trunk@6849 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 87147df commit c75599d

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

wp-admin/edit-link-categories.php

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,41 @@
11
<?php
22
require_once('admin.php');
33

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&#8217; 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&#8217;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+
425
$title = __('Link Categories');
526
$parent_file = 'edit.php';
627

728
wp_enqueue_script( 'admin-categories' );
29+
wp_enqueue_script('admin-forms');
30+
831
require_once ('admin-header.php');
932

1033
$messages[1] = __('Category added.');
1134
$messages[2] = __('Category deleted.');
1235
$messages[3] = __('Category updated.');
1336
$messages[4] = __('Category not added.');
1437
$messages[5] = __('Category not updated.');
38+
$messages[6] = __('Categories deleted.');
1539

1640
if (isset($_GET['message'])) : ?>
1741

@@ -55,19 +79,19 @@
5579
?>
5680

5781
<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'); ?>
5984
</div>
6085

6186
<br style="clear:both;" />
6287
</div>
63-
</form>
6488

6589
<br style="clear:both;" />
6690

6791
<table class="widefat">
6892
<thead>
6993
<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>
7195
<th scope="col"><?php _e('Name') ?></th>
7296
<th scope="col"><?php _e('Description') ?></th>
7397
<th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
@@ -95,6 +119,7 @@
95119
?>
96120
</tbody>
97121
</table>
122+
</form>
98123

99124
<br style="clear:both;" />
100125

wp-admin/includes/template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function link_cat_row( $category ) {
8181
$category->count = number_format_i18n( $category->count );
8282
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
8383
$output = "<tr id='link-cat-$category->term_id'$class>" .
84-
'<td style="text-align: center"> <input type="checkbox" name="delete_tags[]" value="' . $category->term_id . '" /></td>' .
84+
'<td style="text-align: center"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></td>' .
8585
"<td>$edit</td>
8686
<td>$category->description</td>
8787
<td align='center'>$count</td>";

0 commit comments

Comments
 (0)