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');
39 $cat_ID = (int) $_GET['cat_ID'];
40 check_admin_referer('delete-category_' . $cat_ID);
42 if ( !current_user_can('manage_categories') )
43 die (__('Cheatin’ uh?'));
45 $cat_name = get_catname($cat_ID);
47 // Don't delete the default cats.
48 if ( $cat_ID == get_option('default_category') )
49 die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
51 wp_delete_category($cat_ID);
53 wp_redirect('categories.php?message=2');
59 require_once ('admin-header.php');
60 $cat_ID = (int) $_GET['cat_ID'];
61 $category = get_category_to_edit($cat_ID);
65 <h2><?php _e('Edit Category') ?></h2>
66 <form name="editcat" action="categories.php" method="post">
67 <?php wp_nonce_field('update-category_' . $category->cat_ID); ?>
68 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
70 <th width="33%" scope="row"><?php _e('Category name:') ?></th>
71 <td width="67%"><input name="cat_name" type="text" value="<?php echo wp_specialchars($category->cat_name); ?>" size="40" /> <input type="hidden" name="action" value="editedcat" />
72 <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
75 <th scope="row"><?php _e('Category slug:') ?></th>
76 <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
79 <th scope="row"><?php _e('Category parent:') ?></th>
81 <select name='category_parent'>
82 <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
83 <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
87 <th scope="row"><?php _e('Description:') ?></th>
88 <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
91 <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> »" /></p>
93 <p><a href="categories.php"><?php _e('« Return to category list'); ?></a></p>
100 $cat_ID = (int) $_POST['cat_ID'];
101 check_admin_referer('update-category_' . $cat_ID);
103 if ( !current_user_can('manage_categories') )
104 die (__('Cheatin’ uh?'));
106 wp_update_category($_POST);
108 wp_redirect('categories.php?message=3');
113 require_once ('admin-header.php');
115 $messages[1] = __('Category added.');
116 $messages[2] = __('Category deleted.');
117 $messages[3] = __('Category updated.');
120 <?php if (isset($_GET['message'])) : ?>
121 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
125 <?php if ( current_user_can('manage_categories') ) : ?>
126 <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
128 <h2><?php _e('Categories') ?> </h2>
130 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
132 <th scope="col"><?php _e('ID') ?></th>
133 <th scope="col"><?php _e('Name') ?></th>
134 <th scope="col"><?php _e('Description') ?></th>
135 <th scope="col"><?php _e('# Posts') ?></th>
136 <th colspan="2"><?php _e('Action') ?></th>
143 <div id="ajax-response"></div>
147 <?php if ( current_user_can('manage_categories') ) : ?>
149 <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>
153 <h2><?php _e('Add New Category') ?></h2>
154 <form name="addcat" id="addcat" action="categories.php" method="post">
155 <?php wp_nonce_field('add-category'); ?>
156 <p><?php _e('Name:') ?><br />
157 <input type="text" name="cat_name" value="" /></p>
158 <p><?php _e('Category parent:') ?><br />
159 <select name='category_parent' class='postform'>
160 <option value='0'><?php _e('None') ?></option>
161 <?php wp_dropdown_cats(0); ?>
163 <p><?php _e('Description: (optional)') ?> <br />
164 <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
165 <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
174 include('admin-footer.php');