raw
mp-wp_genesis           1 <?php
mp-wp_genesis 2 /**
mp-wp_genesis 3 * Categories Management 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 /** Load WordPress Bootstrap */
mp-wp_genesis 10 require_once('admin.php');
mp-wp_genesis 11
mp-wp_genesis 12 $title = __('Categories');
mp-wp_genesis 13
mp-wp_genesis 14 wp_reset_vars( array('action', 'cat') );
mp-wp_genesis 15
mp-wp_remove-all-... 16 if ( isset( $_GET['action'] ) && isset($_GET['delete']) && 'delete' == $_GET['action'] )
mp-wp_genesis 17 $action = 'bulk-delete';
mp-wp_genesis 18
mp-wp_genesis 19 switch($action) {
mp-wp_genesis 20
mp-wp_genesis 21 case 'addcat':
mp-wp_genesis 22
mp-wp_genesis 23 check_admin_referer('add-category');
mp-wp_genesis 24
mp-wp_genesis 25 if ( !current_user_can('manage_categories') )
mp-wp_genesis 26 wp_die(__('Cheatin&#8217; uh?'));
mp-wp_genesis 27
mp-wp_genesis 28 if( wp_insert_category($_POST ) ) {
mp-wp_genesis 29 wp_redirect('categories.php?message=1#addcat');
mp-wp_genesis 30 } else {
mp-wp_genesis 31 wp_redirect('categories.php?message=4#addcat');
mp-wp_genesis 32 }
mp-wp_genesis 33 exit;
mp-wp_genesis 34 break;
mp-wp_genesis 35
mp-wp_genesis 36 case 'delete':
mp-wp_genesis 37 $cat_ID = (int) $_GET['cat_ID'];
mp-wp_genesis 38 check_admin_referer('delete-category_' . $cat_ID);
mp-wp_genesis 39
mp-wp_genesis 40 if ( !current_user_can('manage_categories') )
mp-wp_genesis 41 wp_die(__('Cheatin&#8217; uh?'));
mp-wp_genesis 42
mp-wp_genesis 43 $cat_name = get_catname($cat_ID);
mp-wp_genesis 44
mp-wp_genesis 45 // Don't delete the default cats.
mp-wp_genesis 46 if ( $cat_ID == get_option('default_category') )
mp-wp_genesis 47 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
mp-wp_genesis 48
mp-wp_genesis 49 wp_delete_category($cat_ID);
mp-wp_genesis 50
mp-wp_genesis 51 wp_redirect('categories.php?message=2');
mp-wp_genesis 52 exit;
mp-wp_genesis 53
mp-wp_genesis 54 break;
mp-wp_genesis 55
mp-wp_genesis 56 case 'bulk-delete':
mp-wp_genesis 57 check_admin_referer('bulk-categories');
mp-wp_genesis 58
mp-wp_genesis 59 if ( !current_user_can('manage_categories') )
mp-wp_genesis 60 wp_die( __('You are not allowed to delete categories.') );
mp-wp_genesis 61
mp-wp_genesis 62 foreach ( (array) $_GET['delete'] as $cat_ID ) {
mp-wp_genesis 63 $cat_name = get_catname($cat_ID);
mp-wp_genesis 64
mp-wp_genesis 65 // Don't delete the default cats.
mp-wp_genesis 66 if ( $cat_ID == get_option('default_category') )
mp-wp_genesis 67 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
mp-wp_genesis 68
mp-wp_genesis 69 wp_delete_category($cat_ID);
mp-wp_genesis 70 }
mp-wp_genesis 71
mp-wp_genesis 72 $sendback = wp_get_referer();
mp-wp_genesis 73
mp-wp_genesis 74 wp_redirect($sendback);
mp-wp_genesis 75 exit();
mp-wp_genesis 76
mp-wp_genesis 77 break;
mp-wp_genesis 78 case 'edit':
mp-wp_genesis 79
mp-wp_genesis 80 $title = __('Edit Category');
mp-wp_genesis 81
mp-wp_genesis 82 require_once ('admin-header.php');
mp-wp_genesis 83 $cat_ID = (int) $_GET['cat_ID'];
mp-wp_genesis 84 $category = get_category_to_edit($cat_ID);
mp-wp_genesis 85 include('edit-category-form.php');
mp-wp_genesis 86
mp-wp_genesis 87 break;
mp-wp_genesis 88
mp-wp_genesis 89 case 'editedcat':
mp-wp_genesis 90 $cat_ID = (int) $_POST['cat_ID'];
mp-wp_genesis 91 check_admin_referer('update-category_' . $cat_ID);
mp-wp_genesis 92
mp-wp_genesis 93 if ( !current_user_can('manage_categories') )
mp-wp_genesis 94 wp_die(__('Cheatin&#8217; uh?'));
mp-wp_genesis 95
mp-wp_genesis 96 $location = 'categories.php';
mp-wp_genesis 97 if ( $referer = wp_get_original_referer() ) {
mp-wp_genesis 98 if ( false !== strpos($referer, 'categories.php') )
mp-wp_genesis 99 $location = $referer;
mp-wp_genesis 100 }
mp-wp_genesis 101
mp-wp_genesis 102 if ( wp_update_category($_POST) )
mp-wp_genesis 103 $location = add_query_arg('message', 3, $location);
mp-wp_genesis 104 else
mp-wp_genesis 105 $location = add_query_arg('message', 5, $location);
mp-wp_genesis 106
mp-wp_genesis 107 wp_redirect($location);
mp-wp_genesis 108
mp-wp_genesis 109 exit;
mp-wp_genesis 110 break;
mp-wp_genesis 111
mp-wp_genesis 112 default:
mp-wp_genesis 113
mp-wp_genesis 114 if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
mp-wp_genesis 115 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
mp-wp_genesis 116 exit;
mp-wp_genesis 117 }
mp-wp_genesis 118
mp-wp_genesis 119 require_once ('admin-header.php');
mp-wp_genesis 120
mp-wp_genesis 121 $messages[1] = __('Category added.');
mp-wp_genesis 122 $messages[2] = __('Category deleted.');
mp-wp_genesis 123 $messages[3] = __('Category updated.');
mp-wp_genesis 124 $messages[4] = __('Category not added.');
mp-wp_genesis 125 $messages[5] = __('Category not updated.');
mp-wp_genesis 126 ?>
mp-wp_genesis 127
mp-wp_genesis 128 <div class="wrap nosubsub">
mp-wp_genesis 129 <?php screen_icon(); ?>
mp-wp_genesis 130 <h2><?php echo wp_specialchars( $title );
mp-wp_genesis 131 if ( isset($_GET['s']) && $_GET['s'] )
mp-wp_genesis 132 printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
mp-wp_genesis 133 </h2>
mp-wp_genesis 134
mp-wp_genesis 135 <?php
mp-wp_genesis 136 if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
mp-wp_genesis 137 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
mp-wp_genesis 138 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
mp-wp_genesis 139 endif; ?>
mp-wp_genesis 140
mp-wp_genesis 141 <form class="search-form topmargin" action="" method="get">
mp-wp_genesis 142 <p class="search-box">
mp-wp_genesis 143 <label class="hidden" for="category-search-input"><?php _e('Search Categories'); ?>:</label>
mp-wp_genesis 144 <input type="text" class="search-input" id="category-search-input" name="s" value="<?php _admin_search_query(); ?>" />
mp-wp_genesis 145 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
mp-wp_genesis 146 </p>
mp-wp_genesis 147 </form>
mp-wp_genesis 148 <br class="clear" />
mp-wp_genesis 149
mp-wp_genesis 150 <div id="col-container">
mp-wp_genesis 151
mp-wp_genesis 152 <div id="col-right">
mp-wp_genesis 153 <div class="col-wrap">
mp-wp_genesis 154 <form id="posts-filter" action="" method="get">
mp-wp_genesis 155 <div class="tablenav">
mp-wp_genesis 156
mp-wp_genesis 157 <?php
mp-wp_genesis 158 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
mp-wp_genesis 159 if ( empty($pagenum) )
mp-wp_genesis 160 $pagenum = 1;
mp-wp_genesis 161 if( ! isset( $catsperpage ) || $catsperpage < 0 )
mp-wp_genesis 162 $catsperpage = 20;
mp-wp_genesis 163
mp-wp_genesis 164 $page_links = paginate_links( array(
mp-wp_genesis 165 'base' => add_query_arg( 'pagenum', '%#%' ),
mp-wp_genesis 166 'format' => '',
mp-wp_genesis 167 'prev_text' => __('&laquo;'),
mp-wp_genesis 168 'next_text' => __('&raquo;'),
mp-wp_genesis 169 'total' => ceil(wp_count_terms('category') / $catsperpage),
mp-wp_genesis 170 'current' => $pagenum
mp-wp_genesis 171 ));
mp-wp_genesis 172
mp-wp_genesis 173 if ( $page_links )
mp-wp_genesis 174 echo "<div class='tablenav-pages'>$page_links</div>";
mp-wp_genesis 175 ?>
mp-wp_genesis 176
mp-wp_genesis 177 <div class="alignleft actions">
mp-wp_genesis 178 <select name="action">
mp-wp_genesis 179 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
mp-wp_genesis 180 <option value="delete"><?php _e('Delete'); ?></option>
mp-wp_genesis 181 </select>
mp-wp_genesis 182 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
mp-wp_genesis 183 <?php wp_nonce_field('bulk-categories'); ?>
mp-wp_genesis 184 </div>
mp-wp_genesis 185
mp-wp_genesis 186 <br class="clear" />
mp-wp_genesis 187 </div>
mp-wp_genesis 188
mp-wp_genesis 189 <div class="clear"></div>
mp-wp_genesis 190
mp-wp_genesis 191 <table class="widefat fixed" cellspacing="0">
mp-wp_genesis 192 <thead>
mp-wp_genesis 193 <tr>
mp-wp_genesis 194 <?php print_column_headers('categories'); ?>
mp-wp_genesis 195 </tr>
mp-wp_genesis 196 </thead>
mp-wp_genesis 197 <tbody id="the-list" class="list:cat">
mp-wp_genesis 198 <?php
mp-wp_genesis 199 cat_rows(0, 0, 0, $pagenum, $catsperpage);
mp-wp_genesis 200 ?>
mp-wp_genesis 201 </tbody>
mp-wp_genesis 202 </table>
mp-wp_genesis 203
mp-wp_genesis 204 </form>
mp-wp_genesis 205
mp-wp_genesis 206 <div class="form-wrap">
mp-wp_genesis 207 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_catname(get_option('default_category')))) ?></p>
mp-wp_genesis 208 </div>
mp-wp_genesis 209
mp-wp_genesis 210 </div>
mp-wp_genesis 211 </div><!-- /col-right -->
mp-wp_genesis 212
mp-wp_genesis 213 <div id="col-left">
mp-wp_genesis 214 <div class="col-wrap">
mp-wp_genesis 215
mp-wp_genesis 216 <?php if ( current_user_can('manage_categories') ) { ?>
mp-wp_genesis 217 <?php $category = (object) array(); $category->parent = 0; do_action('add_category_form_pre', $category); ?>
mp-wp_genesis 218
mp-wp_genesis 219 <div class="form-wrap">
mp-wp_genesis 220 <h3><?php _e('Add Category'); ?></h3>
mp-wp_genesis 221 <form name="addcat" id="addcat" method="post" action="categories.php" class="add:the-list: validate">
mp-wp_genesis 222 <input type="hidden" name="action" value="addcat" />
mp-wp_genesis 223 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-category'); ?>
mp-wp_genesis 224
mp-wp_genesis 225 <div class="form-field form-required">
mp-wp_genesis 226 <label for="cat_name"><?php _e('Category Name') ?></label>
mp-wp_genesis 227 <input name="cat_name" id="cat_name" type="text" value="" size="40" aria-required="true" />
mp-wp_genesis 228 <p><?php _e('The name is used to identify the category almost everywhere, for example under the post or in the category widget.'); ?></p>
mp-wp_genesis 229 </div>
mp-wp_genesis 230
mp-wp_genesis 231 <div class="form-field">
mp-wp_genesis 232 <label for="category_nicename"><?php _e('Category Slug') ?></label>
mp-wp_genesis 233 <input name="category_nicename" id="category_nicename" type="text" value="" size="40" />
mp-wp_genesis 234 <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
mp-wp_genesis 235 </div>
mp-wp_genesis 236
mp-wp_genesis 237 <div class="form-field">
mp-wp_genesis 238 <label for="category_parent"><?php _e('Category Parent') ?></label>
mp-wp_genesis 239 <?php wp_dropdown_categories(array('hide_empty' => 0, 'name' => 'category_parent', 'orderby' => 'name', 'selected' => $category->parent, 'hierarchical' => true, 'show_option_none' => __('None'))); ?>
mp-wp_genesis 240 <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p>
mp-wp_genesis 241 </div>
mp-wp_genesis 242
mp-wp_genesis 243 <div class="form-field">
mp-wp_genesis 244 <label for="category_description"><?php _e('Description') ?></label>
mp-wp_genesis 245 <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea>
mp-wp_genesis 246 <p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p>
mp-wp_genesis 247 </div>
mp-wp_genesis 248
mp-wp_genesis 249 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Category'); ?>" /></p>
mp-wp_genesis 250 <?php do_action('edit_category_form', $category); ?>
mp-wp_genesis 251 </form></div>
mp-wp_genesis 252
mp-wp_genesis 253 <?php } ?>
mp-wp_genesis 254
mp-wp_genesis 255 </div>
mp-wp_genesis 256 </div><!-- /col-left -->
mp-wp_genesis 257
mp-wp_genesis 258 </div><!-- /col-container -->
mp-wp_genesis 259 </div><!-- /wrap -->
mp-wp_genesis 260
mp-wp_genesis 261 <?php
mp-wp_genesis 262 break;
mp-wp_genesis 263 }
mp-wp_genesis 264
mp-wp_genesis 265 include('admin-footer.php');
mp-wp_genesis 266
mp-wp_genesis 267 ?>