2 require_once('admin.php');
5 if ( isset($_GET['deleteit']) && isset($_GET['delete']) ) {
6 check_admin_referer('bulk-link-categories');
8 if ( !current_user_can('manage_categories') )
9 wp_die(__('Cheatin’ uh?'));
11 foreach( (array) $_GET['delete'] as $cat_ID ) {
12 $cat_name = get_term_field('name', $cat_ID, 'link_category');
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));
18 wp_delete_term($cat_ID, 'link_category');
21 $location = 'edit-link-categories.php';
22 if ( $referer = wp_get_referer() ) {
23 if ( false !== strpos($referer, 'edit-link-categories.php') )
27 $location = add_query_arg('message', 6, $location);
28 wp_redirect($location);
30 } elseif ( !empty($_GET['_wp_http_referer']) ) {
31 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
35 $title = __('Link Categories');
36 $parent_file = 'edit.php';
38 wp_enqueue_script( 'admin-categories' );
39 wp_enqueue_script('admin-forms');
41 require_once ('admin-header.php');
43 $messages[1] = __('Category added.');
44 $messages[2] = __('Category deleted.');
45 $messages[3] = __('Category updated.');
46 $messages[4] = __('Category not added.');
47 $messages[5] = __('Category not updated.');
48 $messages[6] = __('Categories deleted.');
50 if (isset($_GET['message'])) : ?>
51 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
52 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
57 <form id="posts-filter" action="" method="get">
58 <?php if ( current_user_can('manage_categories') ) : ?>
59 <h2><?php printf(__('Manage Link Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
61 <h2><?php _e('Manage Link Categories') ?> </h2>
65 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
66 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
71 <div class="tablenav">
74 $pagenum = absint( $_GET['pagenum'] );
75 if ( empty($pagenum) )
77 if( !$catsperpage || $catsperpage < 0 )
80 $page_links = paginate_links( array(
81 'base' => add_query_arg( 'pagenum', '%#%' ),
83 'total' => ceil(wp_count_terms('link_category') / $catsperpage),
88 echo "<div class='tablenav-pages'>$page_links</div>";
91 <div class="alignleft">
92 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
93 <?php wp_nonce_field('bulk-link-categories'); ?>
101 <table class="widefat">
104 <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
105 <th scope="col"><?php _e('Name') ?></th>
106 <th scope="col"><?php _e('Description') ?></th>
107 <th scope="col" class="num" style="width: 90px;"><?php _e('Links') ?></th>
110 <tbody id="the-list" class="list:link-cat">
112 $start = ($pagenum - 1) * $catsperpage;
113 $args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
114 if ( !empty( $_GET['s'] ) )
115 $args['search'] = $_GET['s'];
117 $categories = get_terms( 'link_category', $args );
120 foreach ( $categories as $category ) {
121 $category = sanitize_term($category, 'link_category', 'display');
122 $output .= link_cat_row($category);
124 $output = apply_filters('cat_rows', $output);
134 <div class="tablenav">
138 echo "<div class='tablenav-pages'>$page_links</div>";
146 <?php if ( current_user_can('manage_categories') ) : ?>
148 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the links in that category. Instead, links that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), get_term_field('name', get_option('default_link_category'), 'link_category')) ?></p>
151 <?php include('edit-link-category-form.php'); ?>
155 <?php include('admin-footer.php'); ?>