diff --git a/wp-admin/categories.php b/wp-admin/categories.php index a0b8638f27..bd76bdf264 100644 --- a/wp-admin/categories.php +++ b/wp-admin/categories.php @@ -6,6 +6,9 @@ $parent_file = 'edit.php'; wp_reset_vars(array('action', 'cat')); +if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) + $action = 'bulk-delete'; + switch($action) { case 'addcat': @@ -43,6 +46,29 @@ case 'delete': break; +case 'bulk-delete': + check_admin_referer('bulk-categories'); + + if ( !current_user_can('manage_categories') ) + wp_die( __('You are not allowed to delete categories.') ); + + foreach ( (array) $_GET['delete'] as $cat_ID ) { + $cat_name = get_catname($cat_ID); + + // Don't delete the default cats. + if ( $cat_ID == get_option('default_category') ) + wp_die(sprintf(__("Can’t delete the %s category: this is the default one"), $cat_name)); + + wp_delete_category($cat_ID); + } + + $sendback = wp_get_referer(); + $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback); + + wp_redirect($sendback); + exit(); + +break; case 'edit': require_once ('admin-header.php'); @@ -70,6 +96,8 @@ break; default: wp_enqueue_script( 'admin-categories' ); +wp_enqueue_script('admin-forms'); + require_once ('admin-header.php'); $messages[1] = __('Category added.'); @@ -101,22 +129,22 @@ $messages[5] = __('Category not updated.');
- + +

-
- + - + @@ -125,6 +153,7 @@ cat_rows(); ?>
+