2 require_once('admin.php');
5 $parent_file = 'edit.php';
7 wp_reset_vars(array('action', 'tag'));
9 if ( isset($_GET['deleteit']) && isset($_GET['delete_tags']) )
10 $action = 'bulk-delete';
16 check_admin_referer('add-tag');
18 if ( !current_user_can('manage_categories') )
19 wp_die(__('Cheatin’ uh?'));
21 $ret = wp_insert_term($_POST['name'], 'post_tag', $_POST);
22 if ( $ret && !is_wp_error( $ret ) ) {
23 wp_redirect('edit-tags.php?message=1#addtag');
25 wp_redirect('edit-tags.php?message=4#addtag');
31 $tag_ID = (int) $_GET['tag_ID'];
32 check_admin_referer('delete-tag_' . $tag_ID);
34 if ( !current_user_can('manage_categories') )
35 wp_die(__('Cheatin’ uh?'));
37 wp_delete_term( $tag_ID, 'post_tag');
39 wp_redirect('edit-tags.php?message=2');
45 check_admin_referer('bulk-tags');
47 if ( !current_user_can('manage_categories') )
48 wp_die(__('Cheatin’ uh?'));
50 $tags = $_GET['delete_tags'];
51 foreach( (array) $tags as $tag_ID ) {
52 wp_delete_term( $tag_ID, 'post_tag');
55 $location = 'edit-tags.php';
56 if ( $referer = wp_get_referer() ) {
57 if ( false !== strpos($referer, 'edit-tags.php') )
61 $location = add_query_arg('message', 6, $location);
62 wp_redirect($location);
69 require_once ('admin-header.php');
70 $tag_ID = (int) $_GET['tag_ID'];
72 $tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit');
73 include('edit-tag-form.php');
78 $tag_ID = (int) $_POST['tag_ID'];
79 check_admin_referer('update-tag_' . $tag_ID);
81 if ( !current_user_can('manage_categories') )
82 wp_die(__('Cheatin’ uh?'));
84 $ret = wp_update_term($tag_ID, 'post_tag', $_POST);
86 $location = 'edit-tags.php';
87 if ( $referer = wp_get_original_referer() ) {
88 if ( false !== strpos($referer, 'edit-tags.php') )
92 if ( $ret && !is_wp_error( $ret ) )
93 $location = add_query_arg('message', 3, $location);
95 $location = add_query_arg('message', 5, $location);
97 wp_redirect($location);
103 if ( !empty($_GET['_wp_http_referer']) ) {
104 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
108 wp_enqueue_script( 'admin-tags' );
109 wp_enqueue_script('admin-forms');
111 require_once ('admin-header.php');
113 $messages[1] = __('Tag added.');
114 $messages[2] = __('Tag deleted.');
115 $messages[3] = __('Tag updated.');
116 $messages[4] = __('Tag not added.');
117 $messages[5] = __('Tag not updated.');
118 $messages[6] = __('Tags deleted.');
121 <?php if (isset($_GET['message'])) : ?>
122 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
123 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
128 <form id="posts-filter" action="" method="get">
129 <?php if ( current_user_can('manage_categories') ) : ?>
130 <h2><?php printf(__('Manage Tags (<a href="%s">add new</a>)'), '#addtag') ?> </h2>
132 <h2><?php _e('Manage Tags') ?> </h2>
136 <label class="hidden" for="post-search-input"><?php _e( 'Search Tags' ); ?>:</label>
137 <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
138 <input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" />
143 <div class="tablenav">
146 $pagenum = absint( $_GET['pagenum'] );
147 if ( empty($pagenum) )
149 if( !$tagsperpage || $tagsperpage < 0 )
152 $page_links = paginate_links( array(
153 'base' => add_query_arg( 'pagenum', '%#%' ),
155 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage),
156 'current' => $pagenum
160 echo "<div class='tablenav-pages'>$page_links</div>";
163 <div class="alignleft">
164 <input type="submit" value="<?php _e('Delete'); ?>" name="deleteit" class="button-secondary delete" />
165 <?php wp_nonce_field('bulk-tags'); ?>
173 <table class="widefat">
176 <th scope="col" class="check-column"><input type="checkbox" /></th>
177 <th scope="col"><?php _e('Name') ?></th>
178 <th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th>
181 <tbody id="the-list" class="list:tag">
184 $searchterms = trim( $_GET['s'] );
186 $count = tag_rows( $pagenum, $tagsperpage, $searchterms );
192 <div class="tablenav">
196 echo "<div class='tablenav-pages'>$page_links</div>";
204 <?php if ( current_user_can('manage_categories') ) : ?>
207 <?php include('edit-tag-form.php'); ?>
215 include('admin-footer.php');