2 require_once('admin.php');
4 $title = __('Categories');
5 $parent_file = 'edit.php';
7 wp_reset_vars(array('action', 'cat'));
9 if ( isset($_GET['deleteit']) && isset($_GET['delete']) )
10 $action = 'bulk-delete';
16 check_admin_referer('add-category');
18 if ( !current_user_can('manage_categories') )
19 wp_die(__('Cheatin’ uh?'));
21 if( wp_insert_category($_POST ) ) {
22 wp_redirect('categories.php?message=1#addcat');
24 wp_redirect('categories.php?message=4#addcat');
30 $cat_ID = (int) $_GET['cat_ID'];
31 check_admin_referer('delete-category_' . $cat_ID);
33 if ( !current_user_can('manage_categories') )
34 wp_die(__('Cheatin’ uh?'));
36 $cat_name = get_catname($cat_ID);
38 // Don't delete the default cats.
39 if ( $cat_ID == get_option('default_category') )
40 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
42 wp_delete_category($cat_ID);
44 wp_redirect('categories.php?message=2');
50 check_admin_referer('bulk-categories');
52 if ( !current_user_can('manage_categories') )
53 wp_die( __('You are not allowed to delete categories.') );
55 foreach ( (array) $_GET['delete'] as $cat_ID ) {
56 $cat_name = get_catname($cat_ID);
58 // Don't delete the default cats.
59 if ( $cat_ID == get_option('default_category') )
60 wp_die(sprintf(__("Can’t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
62 wp_delete_category($cat_ID);
65 $sendback = wp_get_referer();
66 $sendback = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $sendback);
68 wp_redirect($sendback);
74 require_once ('admin-header.php');
75 $cat_ID = (int) $_GET['cat_ID'];
76 $category = get_category_to_edit($cat_ID);
77 include('edit-category-form.php');
82 $cat_ID = (int) $_POST['cat_ID'];
83 check_admin_referer('update-category_' . $cat_ID);
85 if ( !current_user_can('manage_categories') )
86 wp_die(__('Cheatin’ uh?'));
88 if ( wp_update_category($_POST) )
89 wp_redirect('categories.php?message=3');
91 wp_redirect('categories.php?message=5');
98 if ( !empty($_GET['_wp_http_referer']) ) {
99 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
103 wp_enqueue_script( 'admin-categories' );
104 wp_enqueue_script('admin-forms');
106 require_once ('admin-header.php');
108 $messages[1] = __('Category added.');
109 $messages[2] = __('Category deleted.');
110 $messages[3] = __('Category updated.');
111 $messages[4] = __('Category not added.');
112 $messages[5] = __('Category not updated.');
115 <?php if (isset($_GET['message'])) : ?>
116 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
117 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
121 <form id="posts-filter" action="" method="get">
122 <?php if ( current_user_can('manage_categories') ) : ?>
123 <h2><?php printf(__('Manage Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
125 <h2><?php _e('Manage Categories') ?> </h2>
129 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
130 <input type="submit" value="<?php _e( 'Search Categories' ); ?>" class="button" />
135 <div class="tablenav">
137 <div class="alignleft">
138 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
139 <?php wp_nonce_field('bulk-categories'); ?>
147 <table class="widefat">
150 <th scope="col" class="check-column"><input type="checkbox" onclick="checkAll(document.getElementById('posts-filter'));" /></th>
151 <th scope="col"><?php _e('Name') ?></th>
152 <th scope="col"><?php _e('Description') ?></th>
153 <th scope="col" class="num"><?php _e('Posts') ?></th>
156 <tbody id="the-list" class="list:cat">
164 <div class="tablenav">
171 <?php if ( current_user_can('manage_categories') ) : ?>
173 <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>
174 <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>
177 <?php include('edit-category-form.php'); ?>
185 include('admin-footer.php');