source: trunk/www.guidonia.net/wp/wp-admin/edit-tags.php@ 44

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