root/tags/1_0-rc1/wp-admin/categories.php

Revision 599, 3.6 kB (checked in by donncha, 3 years ago)

WP Merge

  • Property svn:eol-style set to native
Line 
1 <?php
2 require_once('admin.php');
3
4 $title = __('Categories');
5 $parent_file = 'edit.php';
6
7 $wpvarstoreset = array('action','cat');
8 for ($i=0; $i<count($wpvarstoreset); $i += 1) {
9     $wpvar = $wpvarstoreset[$i];
10     if (!isset($$wpvar)) {
11         if (empty($_POST["$wpvar"])) {
12             if (empty($_GET["$wpvar"])) {
13                 $$wpvar = '';
14             } else {
15                 $$wpvar = $_GET["$wpvar"];
16             }
17         } else {
18             $$wpvar = $_POST["$wpvar"];
19         }
20     }
21 }
22
23 switch($action) {
24
25 case 'addcat':
26
27     check_admin_referer('add-category');
28
29     if ( !current_user_can('manage_categories') )
30         die (__('Cheatin&#8217; uh?'));
31
32     wp_insert_category($_POST);
33
34     wp_redirect('categories.php?message=1#addcat');
35 break;
36
37 case 'delete':
38     $cat_ID = (int) $_GET['cat_ID'];
39     check_admin_referer('delete-category_' $cat_ID);
40
41     if ( !current_user_can('manage_categories') )
42         die (__('Cheatin&#8217; uh?'));
43
44     $cat_name = get_catname($cat_ID);
45
46     // Don't delete the default cats.
47     if ( $cat_ID == get_option('default_category') )
48         die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one"), $cat_name));
49
50     if ( $cat_ID == get_option('default_link_category') )
51         die(sprintf(__("Can't delete the <strong>%s</strong> category: this is the default one for bookmarks"), $cat_name));
52
53     wp_delete_category($cat_ID);
54
55     wp_redirect('categories.php?message=2');
56
57 break;
58
59 case 'edit':
60
61     require_once ('admin-header.php');
62     $cat_ID = (int) $_GET['cat_ID'];
63     $category = get_category_to_edit($cat_ID);
64     include('edit-category-form.php');
65
66 break;
67
68 case 'editedcat':
69     $cat_ID = (int) $_POST['cat_ID'];
70     check_admin_referer('update-category_' . $cat_ID);
71
72     if ( !current_user_can('manage_categories') )
73         die (__('Cheatin&#8217; uh?'));
74
75     wp_update_category($_POST);
76
77     wp_redirect('categories.php?message=3');
78 break;
79
80 default:
81
82 wp_enqueue_script( 'admin-categories' );
83 require_once ('admin-header.php');
84
85 $messages[1] = __('Category added.');
86 $messages[2] = __('Category deleted.');
87 $messages[3] = __('Category updated.');
88 ?>
89
90 <?php if (isset($_GET['message'])) : ?>
91 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
92 <?php endif; ?>
93
94 <div class="wrap">
95 <?php if ( current_user_can('manage_categories') ) : ?>
96     <h2><?php printf(__('Categories (<a href="%s">add new</a>)'), '#addcat') ?> </h2>
97 <?php else : ?>
98     <h2><?php _e('Categories') ?> </h2>
99 <?php endif; ?>
100 <table class="widefat">
101     <thead>
102     <tr>
103         <th scope="col"><?php _e('ID') ?></th>
104         <th scope="col" style="text-align: left"><?php _e('Name') ?></th>
105         <th scope="col" style="text-align: left"><?php _e('Description') ?></th>
106         <th scope="col" width="90"><?php _e('Posts') ?></th>
107         <th scope="col" width="90"><?php _e('Bookmarks') ?></th>
108         <th colspan="2"><?php _e('Action') ?></th>
109     </tr>
110     </thead>
111     <tbody id="the-list">
112 <?php
113 cat_rows();
114 ?>
115     </tbody>
116 </table>
117
118 </div>
119
120 <?php if ( current_user_can('manage_categories') ) : ?>
121 <div class="wrap">
122 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts and bookmarks in that category.  Instead, posts in the deleted category are set to the category <strong>%s</strong> and bookmarks are set to <strong>%s</strong>.'), get_catname(get_option('default_category')), get_catname(get_option('default_link_category'))) ?></p>
123 <p><?php _e('<strong>Also Note:</strong><br />Categories will appear on your blog once you have posted something in them. Empty categories remain invisible.'); ?></p>
124 </div>
125
126 <?php include('edit-category-form.php'); ?>
127 <?php endif; ?>
128
129 <?php
130 break;
131 }
132
133 include('admin-footer.php');
134
135 ?>
136
Note: See TracBrowser for help on using the browser.