2 require_once('admin.php');
4 $title = __('Categories');
5 $parent_file = 'edit.php';
7 wp_reset_vars(array('action', 'cat'));
13 check_admin_referer('add-category');
15 if ( !current_user_can('manage_categories') )
16 wp_die(__('Cheatin’ uh?'));
18 if( wp_insert_category($_POST ) ) {
19 wp_redirect('categories.php?message=1#addcat');
21 wp_redirect('categories.php?message=4#addcat');
27 $cat_ID = (int) $_GET['cat_ID'];
28 check_admin_referer('delete-category_' . $cat_ID);
30 if ( !current_user_can('manage_categories') )
31 wp_die(__('Cheatin’ uh?'));
33 $cat_name = get_catname($cat_ID);
35 // Don't delete the default cats.
36 if ( $cat_ID == get_option('default_category') )
37 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
39 wp_delete_category($cat_ID);
41 wp_redirect('categories.php?message=2');
48 require_once ('admin-header.php');
49 $cat_ID = (int) $_GET['cat_ID'];
50 $category = get_category_to_edit($cat_ID);
51 include('edit-category-form.php');
56 $cat_ID = (int) $_POST['cat_ID'];
57 check_admin_referer('update-category_' . $cat_ID);
59 if ( !current_user_can('manage_categories') )
60 wp_die(__('Cheatin’ uh?'));
62 if ( wp_update_category($_POST) )
63 wp_redirect('categories.php?message=3');
65 wp_redirect('categories.php?message=5');
72 wp_enqueue_script( 'admin-categories' );
73 require_once ('admin-header.php');
75 $messages[1] = __('Category added.');
76 $messages[2] = __('Category deleted.');
77 $messages[3] = __('Category updated.');
78 $messages[4] = __('Category not added.');
79 $messages[5] = __('Category not updated.');
82 <?php if (isset($_GET['message'])) : ?>
83 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
87 <?php if ( current_user_can('manage_categories') ) : ?>
88 <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
90 <h2><?php _e('Categories') ?> </h2>
92 <table class="widefat">
95 <th scope="col" style="text-align: center"><?php _e('ID') ?></th>
96 <th scope="col"><?php _e('Name') ?></th>
97 <th scope="col"><?php _e('Description') ?></th>
98 <th scope="col" width="90" style="text-align: center"><?php _e('Posts') ?></th>
99 <th colspan="2" style="text-align: center"><?php _e('Action') ?></th>
102 <tbody id="the-list">
111 <?php if ( current_user_can('manage_categories') ) : ?>
113 <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>
114 <p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p>
117 <?php include('edit-category-form.php'); ?>
125 include('admin-footer.php');