]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-admin/edit-tags.php
Wordpress 2.9.2-scripts
[autoinstalls/wordpress.git] / wp-admin / edit-tags.php
1 <?php
2 /**
3  * Edit Tags Administration Panel.
4  *
5  * @package WordPress
6  * @subpackage Administration
7  */
8
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
11
12 $title = __('Tags');
13
14 wp_reset_vars( array('action', 'tag', 'taxonomy') );
15
16 if ( empty($taxonomy) )
17         $taxonomy = 'post_tag';
18
19 if ( !is_taxonomy($taxonomy) )
20         wp_die(__('Invalid taxonomy'));
21
22 $parent_file = 'edit.php';
23 $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
24
25 if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
26         $action = 'bulk-delete';
27
28 switch($action) {
29
30 case 'add-tag':
31
32         check_admin_referer('add-tag');
33
34         if ( !current_user_can('manage_categories') )
35                 wp_die(__('Cheatin&#8217; uh?'));
36
37         $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST);
38         if ( $ret && !is_wp_error( $ret ) ) {
39                 wp_redirect('edit-tags.php?message=1#addtag');
40         } else {
41                 wp_redirect('edit-tags.php?message=4#addtag');
42         }
43         exit;
44 break;
45
46 case 'delete':
47         if ( !isset( $_GET['tag_ID'] ) ) {
48                 wp_redirect("edit-tags.php?taxonomy=$taxonomy");
49                 exit;
50         }
51
52         $tag_ID = (int) $_GET['tag_ID'];
53         check_admin_referer('delete-tag_' .  $tag_ID);
54
55         if ( !current_user_can('manage_categories') )
56                 wp_die(__('Cheatin&#8217; uh?'));
57
58         wp_delete_term( $tag_ID, $taxonomy);
59
60         $location = 'edit-tags.php';
61         if ( $referer = wp_get_referer() ) {
62                 if ( false !== strpos($referer, 'edit-tags.php') )
63                         $location = $referer;
64         }
65
66         $location = add_query_arg('message', 2, $location);
67         wp_redirect($location);
68         exit;
69
70 break;
71
72 case 'bulk-delete':
73         check_admin_referer('bulk-tags');
74
75         if ( !current_user_can('manage_categories') )
76                 wp_die(__('Cheatin&#8217; uh?'));
77
78         $tags = (array) $_GET['delete_tags'];
79         foreach( $tags as $tag_ID ) {
80                 wp_delete_term( $tag_ID, $taxonomy);
81         }
82
83         $location = 'edit-tags.php';
84         if ( $referer = wp_get_referer() ) {
85                 if ( false !== strpos($referer, 'edit-tags.php') )
86                         $location = $referer;
87         }
88
89         $location = add_query_arg('message', 6, $location);
90         wp_redirect($location);
91         exit;
92
93 break;
94
95 case 'edit':
96         $title = __('Edit Tag');
97
98         require_once ('admin-header.php');
99         $tag_ID = (int) $_GET['tag_ID'];
100
101         $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit');
102         include('edit-tag-form.php');
103
104 break;
105
106 case 'editedtag':
107         $tag_ID = (int) $_POST['tag_ID'];
108         check_admin_referer('update-tag_' . $tag_ID);
109
110         if ( !current_user_can('manage_categories') )
111                 wp_die(__('Cheatin&#8217; uh?'));
112
113         $ret = wp_update_term($tag_ID, $taxonomy, $_POST);
114
115         $location = 'edit-tags.php';
116         if ( $referer = wp_get_original_referer() ) {
117                 if ( false !== strpos($referer, 'edit-tags.php') )
118                         $location = $referer;
119         }
120
121         if ( $ret && !is_wp_error( $ret ) )
122                 $location = add_query_arg('message', 3, $location);
123         else
124                 $location = add_query_arg('message', 5, $location);
125
126         wp_redirect($location);
127         exit;
128 break;
129
130 default:
131
132 if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
133          wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
134          exit;
135 }
136
137 $can_manage = current_user_can('manage_categories');
138
139 wp_enqueue_script('admin-tags');
140 if ( $can_manage )
141         wp_enqueue_script('inline-edit-tax');
142
143 require_once ('admin-header.php');
144
145 $messages[1] = __('Tag added.');
146 $messages[2] = __('Tag deleted.');
147 $messages[3] = __('Tag updated.');
148 $messages[4] = __('Tag not added.');
149 $messages[5] = __('Tag not updated.');
150 $messages[6] = __('Tags deleted.'); ?>
151
152 <div class="wrap nosubsub">
153 <?php screen_icon(); ?>
154 <h2><?php echo esc_html( $title );
155 if ( isset($_GET['s']) && $_GET['s'] )
156         printf( '<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?>
157 </h2>
158
159 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
160 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
161 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
162 endif; ?>
163 <div id="ajax-response"></div>
164
165 <form class="search-form" action="" method="get">
166 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
167 <p class="search-box">
168         <label class="screen-reader-text" for="tag-search-input"><?php _e( 'Search Tags' ); ?>:</label>
169         <input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
170         <input type="submit" value="<?php esc_attr_e( 'Search Tags' ); ?>" class="button" />
171 </p>
172 </form>
173 <br class="clear" />
174
175 <div id="col-container">
176
177 <div id="col-right">
178 <div class="col-wrap">
179 <form id="posts-filter" action="" method="get">
180 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
181 <div class="tablenav">
182 <?php
183 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
184 if ( empty($pagenum) )
185         $pagenum = 1;
186
187 $tags_per_page = (int) get_user_option( 'edit_tags_per_page', 0, false );
188 if ( empty($tags_per_page) || $tags_per_page < 1 )
189         $tags_per_page = 20;
190 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page );
191 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter
192
193 $page_links = paginate_links( array(
194         'base' => add_query_arg( 'pagenum', '%#%' ),
195         'format' => '',
196         'prev_text' => __('&laquo;'),
197         'next_text' => __('&raquo;'),
198         'total' => ceil(wp_count_terms($taxonomy) / $tags_per_page),
199         'current' => $pagenum
200 ));
201
202 if ( $page_links )
203         echo "<div class='tablenav-pages'>$page_links</div>";
204 ?>
205
206 <div class="alignleft actions">
207 <select name="action">
208 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
209 <option value="delete"><?php _e('Delete'); ?></option>
210 </select>
211 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
212 <?php wp_nonce_field('bulk-tags'); ?>
213 </div>
214
215 <br class="clear" />
216 </div>
217
218 <div class="clear"></div>
219
220 <table class="widefat tag fixed" cellspacing="0">
221         <thead>
222         <tr>
223 <?php print_column_headers('edit-tags'); ?>
224         </tr>
225         </thead>
226
227         <tfoot>
228         <tr>
229 <?php print_column_headers('edit-tags', false); ?>
230         </tr>
231         </tfoot>
232
233         <tbody id="the-list" class="list:tag">
234 <?php
235
236 $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '';
237
238 $count = tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy );
239 ?>
240         </tbody>
241 </table>
242
243 <div class="tablenav">
244 <?php
245 if ( $page_links )
246         echo "<div class='tablenav-pages'>$page_links</div>";
247 ?>
248
249 <div class="alignleft actions">
250 <select name="action2">
251 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
252 <option value="delete"><?php _e('Delete'); ?></option>
253 </select>
254 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
255 </div>
256
257 <br class="clear" />
258 </div>
259
260 <br class="clear" />
261 </form>
262 </div>
263 </div><!-- /col-right -->
264
265 <div id="col-left">
266 <div class="col-wrap">
267
268 <div class="tagcloud">
269 <h3><?php _e('Popular Tags'); ?></h3>
270 <?php
271 if ( $can_manage )
272         wp_tag_cloud(array('taxonomy' => $taxonomy, 'link' => 'edit'));
273 else
274         wp_tag_cloud(array('taxonomy' => $taxonomy));
275 ?>
276 </div>
277
278 <?php if ( $can_manage ) {
279         do_action('add_tag_form_pre'); ?>
280
281 <div class="form-wrap">
282 <h3><?php _e('Add a New Tag'); ?></h3>
283 <form id="addtag" method="post" action="edit-tags.php" class="validate">
284 <input type="hidden" name="action" value="add-tag" />
285 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" />
286 <?php wp_nonce_field('add-tag'); ?>
287
288 <div class="form-field form-required">
289         <label for="tag-name"><?php _e('Tag name') ?></label>
290         <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" />
291         <p><?php _e('The name is how the tag appears on your site.'); ?></p>
292 </div>
293
294 <div class="form-field">
295         <label for="slug"><?php _e('Tag slug') ?></label>
296         <input name="slug" id="slug" type="text" value="" size="40" />
297         <p><?php _e('The &#8220;slug&#8221; is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
298 </div>
299
300 <div class="form-field">
301         <label for="description"><?php _e('Description') ?></label>
302         <textarea name="description" id="description" rows="5" cols="40"></textarea>
303     <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p>
304 </div>
305
306 <p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php esc_attr_e('Add Tag'); ?>" /></p>
307 <?php do_action('add_tag_form'); ?>
308 </form></div>
309 <?php } ?>
310
311 </div>
312 </div><!-- /col-left -->
313
314 </div><!-- /col-container -->
315 </div><!-- /wrap -->
316
317 <?php inline_edit_term_row('edit-tags'); ?>
318
319 <?php
320 break;
321 }
322
323 include('admin-footer.php');
324
325 ?>