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 if ( !current_user_can('manage_categories') )
29 die (__('Cheatin’ uh?'));
31 wp_insert_category($_POST);
33 header('Location: categories.php?message=1#addcat');
38 check_admin_referer();
40 if ( !current_user_can('manage_categories') )
41 die (__('Cheatin’ uh?'));
43 $cat_ID = (int) $_GET['cat_ID'];
44 $cat_name = get_catname($cat_ID);
47 die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
49 wp_delete_category($cat_ID);
51 header('Location: categories.php?message=2');
57 require_once ('admin-header.php');
58 $cat_ID = (int) $_GET['cat_ID'];
59 $category = get_category_to_edit($cat_ID);
63 <h2><?php _e('Edit Category') ?></h2>
64 <form name="editcat" action="categories.php" method="post">
65 <table class="editform" width="100%" cellspacing="2" cellpadding="5">
67 <th width="33%" scope="row"><?php _e('Category name:') ?></th>
68 <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" />
69 <input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" /></td>
72 <th scope="row"><?php _e('Category slug:') ?></th>
73 <td><input name="category_nicename" type="text" value="<?php echo wp_specialchars($category->category_nicename); ?>" size="40" /></td>
76 <th scope="row"><?php _e('Category parent:') ?></th>
78 <select name='category_parent'>
79 <option value='0' <?php if (!$category->category_parent) echo " selected='selected'"; ?>><?php _e('None') ?></option>
80 <?php wp_dropdown_cats($category->cat_ID, $category->category_parent); ?>
84 <th scope="row"><?php _e('Description:') ?></th>
85 <td><textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo wp_specialchars($category->category_description, 1); ?></textarea></td>
88 <p class="submit"><input type="submit" name="submit" value="<?php _e('Edit category') ?> »" /></p>
90 <p><a href="categories.php"><?php _e('« Return to category list'); ?></a></p>
97 if ( !current_user_can('manage_categories') )
98 die (__('Cheatin’ uh?'));
100 wp_update_category($_POST);
102 header('Location: categories.php?message=3');
107 require_once ('admin-header.php');
109 $messages[1] = __('Category added.');
110 $messages[2] = __('Category deleted.');
111 $messages[3] = __('Category updated.');
114 <?php if (isset($_GET['message'])) : ?>
115 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
119 <?php if ( current_user_can('manage_categories') ) : ?>
120 <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
122 <h2><?php _e('Categories') ?> </h2>
124 <table id="the-list-x" width="100%" cellpadding="3" cellspacing="3">
126 <th scope="col"><?php _e('ID') ?></th>
127 <th scope="col"><?php _e('Name') ?></th>
128 <th scope="col"><?php _e('Description') ?></th>
129 <th scope="col"><?php _e('# Posts') ?></th>
130 <th colspan="2"><?php _e('Action') ?></th>
137 <div id="ajax-response"></div>
141 <?php if ( current_user_can('manage_categories') ) : ?>
143 <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>
147 <h2><?php _e('Add New Category') ?></h2>
148 <form name="addcat" id="addcat" action="categories.php" method="post">
150 <p><?php _e('Name:') ?><br />
151 <input type="text" name="cat_name" value="" /></p>
152 <p><?php _e('Category parent:') ?><br />
153 <select name='category_parent' class='postform'>
154 <option value='0'><?php _e('None') ?></option>
155 <?php wp_dropdown_cats(0); ?>
157 <p><?php _e('Description: (optional)') ?> <br />
158 <textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
159 <p class="submit"><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="<?php _e('Add Category »') ?>" /></p>
168 include('admin-footer.php');