equal
deleted
inserted
replaced
32 |
32 |
33 exit; |
33 exit; |
34 break; |
34 break; |
35 |
35 |
36 case 'delete': |
36 case 'delete': |
|
37 if ( !isset( $_GET['cat_ID'] ) ) { |
|
38 wp_redirect('categories.php'); |
|
39 exit; |
|
40 } |
|
41 |
37 $cat_ID = (int) $_GET['cat_ID']; |
42 $cat_ID = (int) $_GET['cat_ID']; |
38 check_admin_referer('delete-category_' . $cat_ID); |
43 check_admin_referer('delete-category_' . $cat_ID); |
39 |
44 |
40 if ( !current_user_can('manage_categories') ) |
45 if ( !current_user_can('manage_categories') ) |
41 wp_die(__('Cheatin’ uh?')); |
46 wp_die(__('Cheatin’ uh?')); |
42 |
47 |
43 $cat_name = get_cat_name($cat_ID); |
|
44 |
|
45 // Don't delete the default cats. |
48 // Don't delete the default cats. |
46 if ( $cat_ID == get_option('default_category') ) |
49 if ( $cat_ID == get_option('default_category') ) |
47 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); |
50 wp_die( sprintf( __("Can’t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) ); |
48 |
51 |
49 wp_delete_category($cat_ID); |
52 wp_delete_category($cat_ID); |
50 |
53 |
51 wp_safe_redirect( add_query_arg( 'message', 2, wp_get_referer() ) ); |
54 wp_safe_redirect( add_query_arg( 'message', 2, wp_get_referer() ) ); |
52 exit; |
55 exit; |
57 check_admin_referer('bulk-categories'); |
60 check_admin_referer('bulk-categories'); |
58 |
61 |
59 if ( !current_user_can('manage_categories') ) |
62 if ( !current_user_can('manage_categories') ) |
60 wp_die( __('You are not allowed to delete categories.') ); |
63 wp_die( __('You are not allowed to delete categories.') ); |
61 |
64 |
62 foreach ( (array) $_GET['delete'] as $cat_ID ) { |
65 $cats = (array) $_GET['delete']; |
63 $cat_name = get_cat_name($cat_ID); |
66 $default_cat = get_option('default_category'); |
64 |
67 foreach ( $cats as $cat_ID ) { |
65 // Don't delete the default cats. |
68 $cat_ID = (int) $cat_ID; |
66 if ( $cat_ID == get_option('default_category') ) |
69 |
67 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name)); |
70 // Don't delete the default cat. |
|
71 if ( $cat_ID == $default_cat ) |
|
72 wp_die( sprintf( __("Can’t delete the <strong>%s</strong> category: this is the default one"), get_cat_name($cat_ID) ) ); |
68 |
73 |
69 wp_delete_category($cat_ID); |
74 wp_delete_category($cat_ID); |
70 } |
75 } |
71 |
76 |
72 wp_safe_redirect( wp_get_referer() ); |
77 wp_safe_redirect( wp_get_referer() ); |
73 exit(); |
78 exit; |
74 |
79 |
75 break; |
80 break; |
76 case 'edit': |
81 case 'edit': |
77 |
82 |
78 $title = __('Edit Category'); |
83 $title = __('Edit Category'); |
159 <?php |
164 <?php |
160 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
165 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
161 if ( empty($pagenum) ) |
166 if ( empty($pagenum) ) |
162 $pagenum = 1; |
167 $pagenum = 1; |
163 |
168 |
164 $cats_per_page = get_user_option('categories_per_page'); |
169 $cats_per_page = (int) get_user_option( 'categories_per_page', 0, false ); |
165 if ( empty($cats_per_page) ) |
170 if ( empty( $cats_per_page ) || $cats_per_page < 1 ) |
166 $cats_per_page = 20; |
171 $cats_per_page = 20; |
167 $cats_per_page = apply_filters('edit_categories_per_page', $cats_per_page); |
172 $cats_per_page = apply_filters( 'edit_categories_per_page', $cats_per_page ); |
168 |
173 |
169 if ( !empty($_GET['s']) ) |
174 if ( !empty($_GET['s']) ) |
170 $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s']))); |
175 $num_cats = count(get_categories(array('hide_empty' => 0, 'search' => $_GET['s']))); |
171 else |
176 else |
172 $num_cats = wp_count_terms('category'); |
177 $num_cats = wp_count_terms('category'); |
278 </div> |
283 </div> |
279 |
284 |
280 <div class="form-field"> |
285 <div class="form-field"> |
281 <label for="category_description"><?php _e('Description') ?></label> |
286 <label for="category_description"><?php _e('Description') ?></label> |
282 <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea> |
287 <textarea name="category_description" id="category_description" rows="5" cols="40"></textarea> |
283 <p><?php _e('The description is not prominent by default, however some themes may show it.'); ?></p> |
288 <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> |
284 </div> |
289 </div> |
285 |
290 |
286 <p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Category'); ?>" /></p> |
291 <p class="submit"><input type="submit" class="button" name="submit" value="<?php esc_attr_e('Add Category'); ?>" /></p> |
287 <?php do_action('edit_category_form', $category); ?> |
292 <?php do_action('edit_category_form', $category); ?> |
288 </form></div> |
293 </form></div> |