3 * Edit Tags Administration Panel.
6 * @subpackage Administration
9 /** WordPress Administration Bootstrap */
10 require_once('admin.php');
14 wp_reset_vars( array('action', 'tag') );
16 if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )
17 $action = 'bulk-delete';
23 check_admin_referer('add-tag');
25 if ( !current_user_can('manage_categories') )
26 wp_die(__('Cheatin’ uh?'));
28 $ret = wp_insert_term($_POST['name'], 'post_tag', $_POST);
29 if ( $ret && !is_wp_error( $ret ) ) {
30 wp_redirect('edit-tags.php?message=1#addtag');
32 wp_redirect('edit-tags.php?message=4#addtag');
38 $tag_ID = (int) $_GET['tag_ID'];
39 check_admin_referer('delete-tag_' . $tag_ID);
41 if ( !current_user_can('manage_categories') )
42 wp_die(__('Cheatin’ uh?'));
44 wp_delete_term( $tag_ID, 'post_tag');
46 wp_redirect('edit-tags.php?message=2');
52 check_admin_referer('bulk-tags');
54 if ( !current_user_can('manage_categories') )
55 wp_die(__('Cheatin’ uh?'));
57 $tags = $_GET['delete_tags'];
58 foreach( (array) $tags as $tag_ID ) {
59 wp_delete_term( $tag_ID, 'post_tag');
62 $location = 'edit-tags.php';
63 if ( $referer = wp_get_referer() ) {
64 if ( false !== strpos($referer, 'edit-tags.php') )
68 $location = add_query_arg('message', 6, $location);
69 wp_redirect($location);
75 $title = __('Edit Tag');
77 require_once ('admin-header.php');
78 $tag_ID = (int) $_GET['tag_ID'];
80 $tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit');
81 include('edit-tag-form.php');
86 $tag_ID = (int) $_POST['tag_ID'];
87 check_admin_referer('update-tag_' . $tag_ID);
89 if ( !current_user_can('manage_categories') )
90 wp_die(__('Cheatin’ uh?'));
92 $ret = wp_update_term($tag_ID, 'post_tag', $_POST);
94 $location = 'edit-tags.php';
95 if ( $referer = wp_get_original_referer() ) {
96 if ( false !== strpos($referer, 'edit-tags.php') )
100 if ( $ret && !is_wp_error( $ret ) )
101 $location = add_query_arg('message', 3, $location);
103 $location = add_query_arg('message', 5, $location);
105 wp_redirect($location);
111 if ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
112 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) );
116 $can_manage = current_user_can('manage_categories');
118 wp_enqueue_script('admin-tags');
120 wp_enqueue_script('inline-edit-tax');
122 require_once ('admin-header.php');
124 $messages[1] = __('Tag added.');
125 $messages[2] = __('Tag deleted.');
126 $messages[3] = __('Tag updated.');
127 $messages[4] = __('Tag not added.');
128 $messages[5] = __('Tag not updated.');
129 $messages[6] = __('Tags deleted.'); ?>
131 <div class="wrap nosubsub">
132 <?php screen_icon(); ?>
133 <h2><?php echo wp_specialchars( $title );
134 if ( isset($_GET['s']) && $_GET['s'] )
135 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( stripslashes($_GET['s']) ) ); ?>
138 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>
139 <div id="message" class="updated fade"><p><?php echo $messages[$msg]; ?></p></div>
140 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
143 <form class="search-form" action="" method="get">
144 <p class="search-box">
145 <label class="hidden" for="tag-search-input"><?php _e( 'Search Tags' ); ?>:</label>
146 <input type="text" class="search-input" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" />
147 <input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" />
152 <div id="col-container">
155 <div class="col-wrap">
156 <form id="posts-filter" action="" method="get">
157 <div class="tablenav">
159 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0;
160 if ( empty($pagenum) )
163 $tagsperpage = apply_filters("tagsperpage",20);
165 $page_links = paginate_links( array(
166 'base' => add_query_arg( 'pagenum', '%#%' ),
168 'prev_text' => __('«'),
169 'next_text' => __('»'),
170 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage),
171 'current' => $pagenum
175 echo "<div class='tablenav-pages'>$page_links</div>";
178 <div class="alignleft actions">
179 <select name="action">
180 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
181 <option value="delete"><?php _e('Delete'); ?></option>
183 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
184 <?php wp_nonce_field('bulk-tags'); ?>
190 <div class="clear"></div>
192 <table class="widefat tag fixed" cellspacing="0">
195 <?php print_column_headers('edit-tags'); ?>
201 <?php print_column_headers('edit-tags', false); ?>
205 <tbody id="the-list" class="list:tag">
208 $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : '';
210 $count = tag_rows( $pagenum, $tagsperpage, $searchterms );
215 <div class="tablenav">
218 echo "<div class='tablenav-pages'>$page_links</div>";
221 <div class="alignleft actions">
222 <select name="action2">
223 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
224 <option value="delete"><?php _e('Delete'); ?></option>
226 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
235 </div><!-- /col-right -->
238 <div class="col-wrap">
240 <div class="tagcloud">
241 <h3><?php _e('Popular Tags'); ?></h3>
244 wp_tag_cloud(array('link' => 'edit'));
250 <?php if ( $can_manage ) {
251 do_action('add_tag_form_pre'); ?>
253 <div class="form-wrap">
254 <h3><?php _e('Add a New Tag'); ?></h3>
255 <div id="ajax-response"></div>
256 <form name="addtag" id="addtag" method="post" action="edit-tags.php" class="add:the-list: validate">
257 <input type="hidden" name="action" value="addtag" />
258 <?php wp_original_referer_field(true, 'previous'); wp_nonce_field('add-tag'); ?>
260 <div class="form-field form-required">
261 <label for="name"><?php _e('Tag name') ?></label>
262 <input name="name" id="name" type="text" value="" size="40" aria-required="true" />
263 <p><?php _e('The name is how the tag appears on your site.'); ?></p>
266 <div class="form-field">
267 <label for="slug"><?php _e('Tag slug') ?></label>
268 <input name="slug" id="slug" type="text" value="" size="40" />
269 <p><?php _e('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and hyphens.'); ?></p>
272 <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Tag'); ?>" /></p>
273 <?php do_action('add_tag_form'); ?>
278 </div><!-- /col-left -->
280 </div><!-- /col-container -->
283 <script type="text/javascript">
286 $(document).ready(function(){
287 $('#doaction, #doaction2').click(function(){
288 if ( $('select[name^="action"]').val() == 'delete' ) {
289 var m = '<?php echo js_escape(__("You are about to delete the selected tags.\n 'Cancel' to stop, 'OK' to delete.")); ?>';
290 return showNotice.warn(m);
298 <?php inline_edit_term_row('edit-tags'); ?>
304 include('admin-footer.php');