Wordpress 2.3.2
[autoinstalls/wordpress.git] / wp-admin / categories.php
1 <?php
2 require_once('admin.php');
3
4 $title = __('Categories');
5 $parent_file = 'edit.php';
6
7 wp_reset_vars(array('action', 'cat'));
8
9 switch($action) {
10
11 case 'addcat':
12
13         check_admin_referer('add-category');
14
15         if ( !current_user_can('manage_categories') )
16                 wp_die(__('Cheatin&#8217; uh?'));
17
18         if( wp_insert_category($_POST ) ) {
19                 wp_redirect('categories.php?message=1#addcat');
20         } else {
21                 wp_redirect('categories.php?message=4#addcat');
22         }
23         exit;
24 break;
25
26 case 'delete':
27         $cat_ID = (int) $_GET['cat_ID'];
28         check_admin_referer('delete-category_' .  $cat_ID);
29
30         if ( !current_user_can('manage_categories') )
31                 wp_die(__('Cheatin&#8217; uh?'));
32
33         $cat_name = get_catname($cat_ID);
34
35         // Don't delete the default cats.
36     if ( $cat_ID == get_option('default_category') )
37                 wp_die(sprintf(__("Can&#8217;t delete the <strong>%s</strong> category: this is the default one"), $cat_name));
38
39         wp_delete_category($cat_ID);
40
41         wp_redirect('categories.php?message=2');
42         exit;
43
44 break;
45
46 case 'edit':
47
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');
52
53 break;
54
55 case 'editedcat':
56         $cat_ID = (int) $_POST['cat_ID'];
57         check_admin_referer('update-category_' . $cat_ID);
58
59         if ( !current_user_can('manage_categories') )
60                 wp_die(__('Cheatin&#8217; uh?'));
61
62         if ( wp_update_category($_POST) )
63                 wp_redirect('categories.php?message=3');
64         else
65                 wp_redirect('categories.php?message=5');
66
67         exit;
68 break;
69
70 default:
71
72 wp_enqueue_script( 'admin-categories' );
73 require_once ('admin-header.php');
74
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.');
80 ?>
81
82 <?php if (isset($_GET['message'])) : ?>
83 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
84 <?php endif; ?>
85
86 <div class="wrap">
87 <?php if ( current_user_can('manage_categories') ) : ?>
88         <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
89 <?php else : ?>
90         <h2><?php _e('Categories') ?> </h2>
91 <?php endif; ?>
92 <table class="widefat">
93         <thead>
94         <tr>
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>
100         </tr>
101         </thead>
102         <tbody id="the-list">
103 <?php
104 cat_rows();
105 ?>
106         </tbody>
107 </table>
108
109 </div>
110
111 <?php if ( current_user_can('manage_categories') ) : ?>
112 <div class="wrap">
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>
115 </div>
116
117 <?php include('edit-category-form.php'); ?>
118
119 <?php endif; ?>
120
121 <?php
122 break;
123 }
124
125 include('admin-footer.php');
126
127 ?>