Bulk link category delete
git-svn-id: http://svn.automattic.com/wordpress/trunk@6849 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1c0cf5a6b6
commit
91f1b07cbf
|
@ -1,10 +1,33 @@
|
|||
<?php
|
||||
require_once('admin.php');
|
||||
|
||||
// Handle bulk deletes
|
||||
if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
|
||||
check_admin_referer('bulk-link-categories');
|
||||
|
||||
if ( !current_user_can('manage_categories') )
|
||||
wp_die(__('Cheatin’ uh?'));
|
||||
|
||||
foreach( (array) $_GET['delete'] as $cat_ID ) {
|
||||
$cat_name = get_term_field('name', $cat_ID, 'link_category');
|
||||
|
||||
// Don't delete the default cats.
|
||||
if ( $cat_ID == get_option('default_link_category') )
|
||||
wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
|
||||
|
||||
wp_delete_term($cat_ID, 'link_category');
|
||||
}
|
||||
|
||||
wp_redirect('edit-link-categories.php?message=6');
|
||||
exit();
|
||||
}
|
||||
|
||||
$title = __('Link Categories');
|
||||
$parent_file = 'edit.php';
|
||||
|
||||
wp_enqueue_script( 'admin-categories' );
|
||||
wp_enqueue_script('admin-forms');
|
||||
|
||||
require_once ('admin-header.php');
|
||||
|
||||
$messages[1] = __('Category added.');
|
||||
|
@ -12,6 +35,7 @@ $messages[2] = __('Category deleted.');
|
|||
$messages[3] = __('Category updated.');
|
||||
$messages[4] = __('Category not added.');
|
||||
$messages[5] = __('Category not updated.');
|
||||
$messages[6] = __('Categories deleted.');
|
||||
|
||||
if (isset($_GET['message'])) : ?>
|
||||
|
||||
|
@ -55,19 +79,19 @@ if ( $page_links )
|
|||
?>
|
||||
|
||||
<div style="float: left">
|
||||
<input type="button" value="<?php _e('Delete'); ?>" name="deleteit" />
|
||||
<input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" />
|
||||
<?php wp_nonce_field('bulk-link-categories'); ?>
|
||||
</div>
|
||||
|
||||
<br style="clear:both;" />
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<br style="clear:both;" />
|
||||
|
||||
<table class="widefat">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('deletetags'));" /></th>
|
||||
<th scope="col" style="text-align: center"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
|
||||
<th scope="col"><?php _e('Name') ?></th>
|
||||
<th scope="col"><?php _e('Description') ?></th>
|
||||
<th scope="col" width="90" style="text-align: center"><?php _e('Links') ?></th>
|
||||
|
@ -95,6 +119,7 @@ if ( $categories ) {
|
|||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<br style="clear:both;" />
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ function link_cat_row( $category ) {
|
|||
$category->count = number_format_i18n( $category->count );
|
||||
$count = ( $category->count > 0 ) ? "<a href='link-manager.php?cat_id=$category->term_id'>$category->count</a>" : $category->count;
|
||||
$output = "<tr id='link-cat-$category->term_id'$class>" .
|
||||
'<td style="text-align: center"> <input type="checkbox" name="delete_tags[]" value="' . $category->term_id . '" /></td>' .
|
||||
'<td style="text-align: center"> <input type="checkbox" name="delete[]" value="' . $category->term_id . '" /></td>' .
|
||||
"<td>$edit</td>
|
||||
<td>$category->description</td>
|
||||
<td align='center'>$count</td>";
|
||||
|
|
Loading…
Reference in New Issue