2 require_once('admin.php');
4 $title = __('Categories');
5 $parent_file = 'edit.php';
8 $wpvarstoreset = array('action','cat');
9 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
10 $wpvar = $wpvarstoreset[$i];
11 if (!isset($$wpvar)) {
12 if (empty($_POST["$wpvar"])) {
13 if (empty($_GET["$wpvar"])) {
16 $$wpvar = $_GET["$wpvar"];
19 $$wpvar = $_POST["$wpvar"];
28 check_admin_referer('add-category');
30 if ( !current_user_can('manage_categories') )
31 die (__('Cheatin’ uh?'));
33 wp_insert_category($_POST);
35 wp_redirect('categories.php?message=1#addcat');
40 $cat_ID = (int) $_GET['cat_ID'];
41 check_admin_referer('delete-category_' . $cat_ID);
43 if ( !current_user_can('manage_categories') )
44 die (__('Cheatin’ uh?'));
46 $cat_name = get_catname($cat_ID);
48 // Don't delete the default cats.
49 if ( $cat_ID == get_option('default_category') )
50 die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
52 wp_delete_category($cat_ID);
54 wp_redirect('categories.php?message=2');
60 require_once ('admin-header.php');
61 $cat_ID = (int) $_GET['cat_ID'];
62 $category = get_category_to_edit($cat_ID);
66 <h2><?php _e('Edit Category') ?></h2>
67 <form name="editcat" action="categories.php" method="post">
68 <?php wp_nonce_field('update-category_' . $category->cat_ID); ?>
69 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
71 <th width="33%" scope="row"><?php _e('Category name:') ?></th>
72 <td width="67%"><input name="cat_name" type="text" value="<?php echo attribute_escape($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
73 <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
76 <th scope="row"><?php _e('Category slug:') ?></th>
77 <td><input name="category_nicename" type="text" value="<?php echo attribute_escape($category->category_nicename); ?>" size="40" /></td>
80 <th scope="row"><?php _e('Category parent:') ?></th>
82 <select name='category_parent'>
83 <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
84 <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
88 <th scope="row"><?php _e('Description:') ?></th>
89 <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description); ?></textarea></td>
92 <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> »" /></p>
94 <p><a href="categories.php"><?php _e('« Return to category list'); ?></a></p>
101 $cat_ID = (int) $_POST['cat_ID'];
102 check_admin_referer('update-category_' . $cat_ID);
104 if ( !current_user_can('manage_categories') )
105 die (__('Cheatin’ uh?'));
107 wp_update_category($_POST);
109 wp_redirect('categories.php?message=3');
115 require_once ('admin-header.php');
117 $messages[1] = __('Category added.');
118 $messages[2] = __('Category deleted.');
119 $messages[3] = __('Category updated.');
122 <?php if (isset($_GET['message'])) : ?>
123 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
127 <?php if ( current_user_can('manage_categories') ) : ?>
128 <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
130 <h2><?php _e('Categories') ?> </h2>
132 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
134 <th scope="col"><?php _e('ID') ?></th>
135 <th scope="col"><?php _e('Name') ?></th>
136 <th scope="col"><?php _e('Description') ?></th>
137 <th scope="col"><?php _e('# Posts') ?></th>
138 <th colspan="2"><?php _e('Action') ?></th>
145 <div id="ajax-response"></div>
149 <?php if ( current_user_can('manage_categories') ) : ?>
151 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete posts from that category, it will just set them back to the default category <strong>%s</strong>.'), get_catname(get_option('default_category'))) ?></p>
155 <h2><?php _e('Add New Category') ?></h2>
156 <form name="addcat" id="addcat" action="categories.php" method="post">
157 <?php wp_nonce_field('add-category'); ?>
158 <p><?php _e('Name:') ?><br />
159 <input type="text" name="cat_name" value="" /></p>
160 <p><?php _e('Category parent:') ?><br />
161 <select name='category_parent' class='postform'>
162 <option value='0'><?php _e('None') ?></option>
163 <?php wp_dropdown_cats(0); ?>
165 <p><?php _e('Description: (optional)') ?> <br />
166 <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
167 <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
176 include('admin-footer.php');