mp-wp_genesis 1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Edit Link Categories Administration Panel.
mp-wp_genesis 4 *
mp-wp_genesis 5 * @package WordPress
mp-wp_genesis 6 * @subpackage Administration
mp-wp_genesis 7 */
mp-wp_genesis 8
mp-wp_genesis 9 /** WordPress Administration Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 // Handle bulk actions
mp-wp_genesis 13 if ( isset($_GET['action']) && isset($_GET['delete']) ) {
mp-wp_genesis 14 check_admin_referer('bulk-link-categories');
mp-wp_remove-all-... 15 $doaction = $_GET['action'];
mp-wp_genesis 16
mp-wp_genesis 17 if ( !current_user_can('manage_categories') )
mp-wp_genesis 18 wp_die(__('Cheatin’ uh?'));
mp-wp_genesis 19
mp-wp_genesis 20 if ( 'delete' == $doaction ) {
mp-wp_genesis 21 foreach( (array) $_GET['delete'] as $cat_ID ) {
mp-wp_genesis 22 $cat_name = get_term_field('name', $cat_ID, 'link_category');
mp-wp_genesis 23 $default_cat_id = get_option('default_link_category');
mp-wp_genesis 24
mp-wp_genesis 25 // Don't delete the default cats.
mp-wp_genesis 26 if ( $cat_ID == $default_cat_id )
mp-wp_genesis 27 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
mp-wp_genesis 28
mp-wp_genesis 29 wp_delete_term($cat_ID, 'link_category', array('default' => $default_cat_id));
mp-wp_genesis 30 }
mp-wp_genesis 31
mp-wp_genesis 32 $location = 'edit-link-categories.php';
mp-wp_genesis 33 if ( $referer = wp_get_referer() ) {
mp-wp_genesis 34 if ( false !== strpos($referer, 'edit-link-categories.php') )
mp-wp_genesis 35 $location = $referer;
mp-wp_genesis 36 }
mp-wp_genesis 37
mp-wp_genesis 38 $location = add_query_arg('message', 6, $location);
mp-wp_genesis 39 wp_redirect($location);
mp-wp_genesis 40 exit();
mp-wp_genesis 41 }
mp-wp_genesis 42 } elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 43 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 44 exit;
mp-wp_genesis 45 }
mp-wp_genesis 46
mp-wp_genesis 47 $title = __('Link Categories');
mp-wp_genesis 48
mp-wp_genesis 49 require_once ('admin-header.php');
mp-wp_genesis 50
mp-wp_genesis 51 $messages[1] = __('Category added.');
mp-wp_genesis 52 $messages[2] = __('Category deleted.');
mp-wp_genesis 53 $messages[3] = __('Category updated.');
mp-wp_genesis 54 $messages[4] = __('Category not added.');
mp-wp_genesis 55 $messages[5] = __('Category not updated.');
mp-wp_genesis 56 $messages[6] = __('Categories deleted.'); ?>
mp-wp_genesis 57
mp-wp_genesis 58 <div class="wrap nosubsub">
mp-wp_genesis 59 <?php screen_icon(); ?>
mp-wp_genesis 60 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 61 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 62 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
mp-wp_genesis 63 </h2>
mp-wp_genesis 64
mp-wp_genesis 65 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
mp-wp_genesis 66 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
mp-wp_genesis 67 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 68 endif; ?>
mp-wp_genesis 69
mp-wp_genesis 70 <form class="search-form" action="" method="get">
mp-wp_genesis 71 <p class="search-box">
mp-wp_genesis 72 <label class="hidden" for="link-category-search-input"><?php _e( 'Search Categories' ); ?>:</label>
mp-wp_genesis 73 <input type="text" class="search-input" id="link-category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 74 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
mp-wp_genesis 75 </p>
mp-wp_genesis 76 </form>
mp-wp_genesis 77 <br class="clear" />
mp-wp_genesis 78
mp-wp_genesis 79 <div id="col-container">
mp-wp_genesis 80
mp-wp_genesis 81 <div id="col-right">
mp-wp_genesis 82 <div class="col-wrap">
mp-wp_genesis 83 <form id="posts-filter" action="" method="get">
mp-wp_genesis 84 <div class="tablenav">
mp-wp_genesis 85
mp-wp_genesis 86 <?php
mp-wp_genesis 87 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
mp-wp_genesis 88 if ( empty($pagenum) )
mp-wp_genesis 89 $pagenum = 1;
mp-wp_genesis 90 if( ! isset( $catsperpage ) || $catsperpage < 0 )
mp-wp_genesis 91 $catsperpage = 20;
mp-wp_genesis 92
mp-wp_genesis 93 $page_links = paginate_links( array(
mp-wp_genesis 94 'base' => add_query_arg( 'pagenum', '%#%' ),
mp-wp_genesis 95 'format' => '',
mp-wp_genesis 96 'prev_text' => __('«'),
mp-wp_genesis 97 'next_text' => __('»'),
mp-wp_genesis 98 'total' => ceil(wp_count_terms('link_category') / $catsperpage),
mp-wp_genesis 99 'current' => $pagenum
mp-wp_genesis 100 ));
mp-wp_genesis 101
mp-wp_genesis 102 if ( $page_links )
mp-wp_genesis 103 echo "<div class='tablenav-pages'>$page_links</div>";
mp-wp_genesis 104 ?>
mp-wp_genesis 105
mp-wp_genesis 106 <div class="alignleft actions">
mp-wp_genesis 107 <select name="action">
mp-wp_genesis 108 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 109 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 110 </select>
mp-wp_genesis 111 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 112 <?php wp_nonce_field('bulk-link-categories'); ?>
mp-wp_genesis 113 </div>
mp-wp_genesis 114
mp-wp_genesis 115 <br class="clear" />
mp-wp_genesis 116 </div>
mp-wp_genesis 117
mp-wp_genesis 118 <div class="clear"></div>
mp-wp_genesis 119
mp-wp_genesis 120 <table class="widefat fixed" cellspacing="0">
mp-wp_genesis 121 <thead>
mp-wp_genesis 122 <tr>
mp-wp_genesis 123 <?php print_column_headers('edit-link-categories'); ?>
mp-wp_genesis 124 </tr>
mp-wp_genesis 125 </thead>
mp-wp_genesis 126 <tbody id="the-list" class="list:link-cat">
mp-wp_genesis 127 <?php
mp-wp_genesis 128 $start = ($pagenum - 1) * $catsperpage;
mp-wp_genesis 129 $args = array('offset' => $start, 'number' => $catsperpage, 'hide_empty' => 0);
mp-wp_genesis 130 if ( !empty( $_GET['s'] ) )
mp-wp_genesis 131 $args['search'] = $_GET['s'];
mp-wp_genesis 132
mp-wp_genesis 133 $categories = get_terms( 'link_category', $args );
mp-wp_genesis 134 if ( $categories ) {
mp-wp_genesis 135 $output = '';
mp-wp_genesis 136 foreach ( $categories as $category ) {
mp-wp_genesis 137 $output .= link_cat_row($category);
mp-wp_genesis 138 }
mp-wp_genesis 139 echo $output;
mp-wp_genesis 140 unset($category);
mp-wp_genesis 141 }
mp-wp_genesis 142
mp-wp_genesis 143 ?>
mp-wp_genesis 144 </tbody>
mp-wp_genesis 145 </table>
mp-wp_genesis 146
mp-wp_genesis 147 <br class="clear" />
mp-wp_genesis 148 </form>
mp-wp_genesis 149
mp-wp_genesis 150 <div class="form-wrap">
mp-wp_genesis 151 <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>
mp-wp_genesis 152 </div>
mp-wp_genesis 153
mp-wp_genesis 154
mp-wp_genesis 155 </div>
mp-wp_genesis 156 </div><!-- /col-right -->
mp-wp_genesis 157
mp-wp_genesis 158 <div id="col-left">
mp-wp_genesis 159 <div class="col-wrap">
mp-wp_genesis 160
mp-wp_genesis 161 <?php if ( current_user_can('manage_categories') ) {
mp-wp_genesis 162 $category = (object) array(); $category->parent = 0; do_action('add_link_category_form_pre', $category); ?>
mp-wp_genesis 163
mp-wp_genesis 164 <div class="form-wrap">
mp-wp_genesis 165 <h3><?php _e('Add Category'); ?></h3>
mp-wp_genesis 166 <form name="addcat" id="addcat" class="add:the-list: validate" method="post" action="link-category.php">
mp-wp_genesis 167 <input type="hidden" name="action" value="addcat" />
mp-wp_genesis 168 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-link-category'); ?>
mp-wp_genesis 169
mp-wp_genesis 170 <div class="form-field form-required">
mp-wp_genesis 171 <label for="name"><?php _e('Category name') ?></label>
mp-wp_genesis 172 <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
mp-wp_genesis 173 </div>
mp-wp_genesis 174
mp-wp_genesis 175 <div class="form-field">
mp-wp_genesis 176 <label for="slug"><?php _e('Category slug') ?></label>
mp-wp_genesis 177 <input name="slug" id="slug" type="text" value="" size="40" />
mp-wp_genesis 178 <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
mp-wp_genesis 179 </div>
mp-wp_genesis 180
mp-wp_genesis 181 <div class="form-field">
mp-wp_genesis 182 <label for="description"><?php _e('Description (optional)') ?></label>
mp-wp_genesis 183 <textarea name="description" id="description" rows="5" cols="40"></textarea>
mp-wp_genesis 184 </div>
mp-wp_genesis 185
mp-wp_genesis 186 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
mp-wp_genesis 187 <?php do_action('edit_link_category_form', $category); ?>
mp-wp_genesis 188 </form>
mp-wp_genesis 189 </div>
mp-wp_genesis 190
mp-wp_genesis 191 <?php } ?>
mp-wp_genesis 192
mp-wp_genesis 193 </div>
mp-wp_genesis 194 </div><!-- /col-left -->
mp-wp_genesis 195
mp-wp_genesis 196 </div><!-- /col-container -->
mp-wp_genesis 197 </div><!-- /wrap -->
mp-wp_genesis 198 <?php include('admin-footer.php'); ?>