+// Handle bulk actions
+if ( isset($_GET['action']) && isset($_GET['delete']) ) {
+ check_admin_referer('bulk-link-categories');
+ $doaction = $_GET['action'] ? $_GET['action'] : $_GET['action2'];
+
+ if ( !current_user_can('manage_categories') )
+ wp_die(__('Cheatin’ uh?'));
+
+ if ( 'delete' == $doaction ) {
+ foreach( (array) $_GET['delete'] as $cat_ID ) {
+ $cat_name = get_term_field('name', $cat_ID, 'link_category');
+ $default_cat_id = get_option('default_link_category');
+
+ // Don't delete the default cats.
+ if ( $cat_ID == $default_cat_id )
+ 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', array('default' => $default_cat_id));
+ }
+
+ $location = 'edit-link-categories.php';
+ if ( $referer = wp_get_referer() ) {
+ if ( false !== strpos($referer, 'edit-link-categories.php') )
+ $location = $referer;
+ }
+
+ $location = add_query_arg('message', 6, $location);
+ wp_redirect($location);
+ exit();
+ }
+} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
+ wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
+ exit;
+}
+
+$title = __('Link Categories');
+
+wp_enqueue_script('admin-categories');
+if ( current_user_can('manage_categories') )
+ wp_enqueue_script('inline-edit-tax');