root/trunk/wp-admin/edit-tags.php

Revision 8682, 5.0 kB (checked in by ryan, 1 week ago)

Merge crazyhorse management pages. see #7552

  • Property svn:eol-style set to native
Line 
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'));
15
16 if ( $_GET['action'] == 'delete' && isset($_GET['delete_tags']) )
17     $action = 'bulk-delete';
18
19 switch($action) {
20
21 case 'addtag':
22
23     check_admin_referer('add-tag');
24
25     if ( !current_user_can('manage_categories') )
26         wp_die(__('Cheatin&#8217; uh?'));
27
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');
31     } else {
32         wp_redirect('edit-tags.php?message=4#addtag');
33     }
34     exit;
35 break;
36
37 case 'delete':
38     $tag_ID = (int) $_GET['tag_ID'];
39     check_admin_referer('delete-tag_' $tag_ID);
40
41     if ( !current_user_can('manage_categories') )
42         wp_die(__('Cheatin&#8217; uh?'));
43
44     wp_delete_term( $tag_ID, 'post_tag');
45
46     wp_redirect('edit-tags.php?message=2');
47     exit;
48
49 break;
50
51 case 'bulk-delete':
52     check_admin_referer('bulk-tags');
53
54     if ( !current_user_can('manage_categories') )
55         wp_die(__('Cheatin&#8217; uh?'));
56
57     $tags = $_GET['delete_tags'];
58     foreach( (array) $tags as $tag_ID ) {
59         wp_delete_term( $tag_ID, 'post_tag');
60     }
61
62     $location = 'edit-tags.php';
63     if ( $referer = wp_get_referer() ) {
64         if ( false !== strpos($referer, 'edit-tags.php') )
65             $location = $referer;
66     }
67
68     $location = add_query_arg('message', 6, $location);
69     wp_redirect($location);
70     exit;
71
72 break;
73
74 case 'edit':
75
76     require_once ('admin-header.php');
77     $tag_ID = (int) $_GET['tag_ID'];
78
79     $tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit');
80     include('edit-tag-form.php');
81
82 break;
83
84 case 'editedtag':
85     $tag_ID = (int) $_POST['tag_ID'];
86     check_admin_referer('update-tag_' . $tag_ID);
87
88     if ( !current_user_can('manage_categories') )
89         wp_die(__('Cheatin&#8217; uh?'));
90
91     $ret = wp_update_term($tag_ID, 'post_tag', $_POST);
92
93     $location = 'edit-tags.php';
94     if ( $referer = wp_get_original_referer() ) {
95         if ( false !== strpos($referer, 'edit-tags.php') )
96             $location = $referer;
97     }
98
99     if ( $ret && !is_wp_error( $ret ) )
100         $location = add_query_arg('message', 3, $location);
101     else
102         $location = add_query_arg('message', 5, $location);
103
104     wp_redirect($location);
105     exit;
106 break;
107
108 default:
109
110 if ( !empty($_GET['_wp_http_referer']) ) {
111      wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
112      exit;
113 }
114
115 wp_enqueue_script( 'admin-tags' );
116 wp_enqueue_script('admin-forms');
117
118 require_once ('admin-header.php');
119
120 $messages[1] = __('Tag added.');
121 $messages[2] = __('Tag deleted.');
122 $messages[3] = __('Tag updated.');
123 $messages[4] = __('Tag not added.');
124 $messages[5] = __('Tag not updated.');
125 $messages[6] = __('Tags deleted.');
126 ?>
127
128 <?php if (isset($_GET['message'])) : ?>
129 <div id="message" class="updated fade"><p><?php echo $messages[$_GET['message']]; ?></p></div>
130 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']);
131 endif; ?>
132
133 <div class="wrap">
134
135 <form id="posts-filter" action="" method="get">
136     <h2><?php printf( current_user_can('manage_categories') ? __('Tags (<a href="%s">Add New</a>)') : __('Manage Tags'), '#addtag' ); ?></h2>
137
138 <p id="post-search">
139     <label class="hidden" for="post-search-input"><?php _e( 'Search Tags' ); ?>:</label>
140     <input type="text" id="post-search-input" name="s" value="<?php echo attribute_escape(stripslashes($_GET['s'])); ?>" />
141     <input type="submit" value="<?php _e( 'Search Tags' ); ?>" class="button" />
142 </p>
143
144 <br class="clear" />
145
146 <div class="tablenav">
147
148 <?php
149 $pagenum = absint( $_GET['pagenum'] );
150 if ( empty($pagenum) )
151     $pagenum = 1;
152 if( !$tagsperpage || $tagsperpage < 0 )
153     $tagsperpage = 20;
154
155 $page_links = paginate_links( array(
156     'base' => add_query_arg( 'pagenum', '%#%' ),
157     'format' => '',
158     'total' => ceil(wp_count_terms('post_tag') / $tagsperpage),
159     'current' => $pagenum
160 ));
161
162 if ( $page_links )
163     echo "<div class='tablenav-pages'>$page_links</div>";
164 ?>
165
166 <div class="alignleft">
167 <select name="action">
168 <option value="" selected><?php _e('Actions'); ?></option>
169 <option value="delete"><?php _e('Delete'); ?></option>
170 </select>
171 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" class="button-secondary action" />
172 <?php wp_nonce_field('bulk-tags'); ?>
173 </div>
174
175 <br class="clear" />
176 </div>
177
178 <br class="clear" />
179
180 <table class="widefat">
181     <thead>
182     <tr>
183     <th scope="col" class="check-column"><input type="checkbox" /></th>
184         <th scope="col"><?php _e('Name') ?></th>
185         <th scope="col" class="num" style="width: 90px"><?php _e('Posts') ?></th>
186     </tr>
187     </thead>
188     <tbody id="the-list" class="list:tag">
189 <?php
190
191 $searchterms = trim( $_GET['s'] );
192
193 $count = tag_rows( $pagenum, $tagsperpage, $searchterms );
194 ?>
195     </tbody>
196 </table>
197 </form>
198
199 <div class="tablenav">
200
201 <?php
202 if ( $page_links )
203     echo "<div class='tablenav-pages'>$page_links</div>";
204 ?>
205 <br class="clear" />
206 </div>
207 <br class="clear" />
208
209 </div>
210
211 <?php if ( current_user_can('manage_categories') ) : ?>
212
213 <br />
214 <?php include('edit-tag-form.php'); ?>
215
216 <?php endif; ?>
217
218 <?php
219 break;
220 }
221
222 include('admin-footer.php');
223
224 ?>
225
Note: See TracBrowser for help on using the browser.