Projects : mp-wp : mp-wp_genesis
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 ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) |
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’ 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’ 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’ 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 | $title = __('Edit Tag'); |
76 | |
77 | require_once ('admin-header.php'); |
78 | $tag_ID = (int) $_GET['tag_ID']; |
79 | |
80 | $tag = get_term($tag_ID, 'post_tag', OBJECT, 'edit'); |
81 | include('edit-tag-form.php'); |
82 | |
83 | break; |
84 | |
85 | case 'editedtag': |
86 | $tag_ID = (int) $_POST['tag_ID']; |
87 | check_admin_referer('update-tag_' . $tag_ID); |
88 | |
89 | if ( !current_user_can('manage_categories') ) |
90 | wp_die(__('Cheatin’ uh?')); |
91 | |
92 | $ret = wp_update_term($tag_ID, 'post_tag', $_POST); |
93 | |
94 | $location = 'edit-tags.php'; |
95 | if ( $referer = wp_get_original_referer() ) { |
96 | if ( false !== strpos($referer, 'edit-tags.php') ) |
97 | $location = $referer; |
98 | } |
99 | |
100 | if ( $ret && !is_wp_error( $ret ) ) |
101 | $location = add_query_arg('message', 3, $location); |
102 | else |
103 | $location = add_query_arg('message', 5, $location); |
104 | |
105 | wp_redirect($location); |
106 | exit; |
107 | break; |
108 | |
109 | default: |
110 | |
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']) ) ); |
113 | exit; |
114 | } |
115 | |
116 | $can_manage = current_user_can('manage_categories'); |
117 | |
118 | wp_enqueue_script('admin-tags'); |
119 | if ( $can_manage ) |
120 | wp_enqueue_script('inline-edit-tax'); |
121 | |
122 | require_once ('admin-header.php'); |
123 | |
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.'); ?> |
130 | |
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']) ) ); ?> |
136 | </h2> |
137 | |
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']); |
141 | endif; ?> |
142 | |
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" /> |
148 | </p> |
149 | </form> |
150 | <br class="clear" /> |
151 | |
152 | <div id="col-container"> |
153 | |
154 | <div id="col-right"> |
155 | <div class="col-wrap"> |
156 | <form id="posts-filter" action="" method="get"> |
157 | <div class="tablenav"> |
158 | <?php |
159 | $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; |
160 | if ( empty($pagenum) ) |
161 | $pagenum = 1; |
162 | |
163 | $tagsperpage = apply_filters("tagsperpage",20); |
164 | |
165 | $page_links = paginate_links( array( |
166 | 'base' => add_query_arg( 'pagenum', '%#%' ), |
167 | 'format' => '', |
168 | 'prev_text' => __('«'), |
169 | 'next_text' => __('»'), |
170 | 'total' => ceil(wp_count_terms('post_tag') / $tagsperpage), |
171 | 'current' => $pagenum |
172 | )); |
173 | |
174 | if ( $page_links ) |
175 | echo "<div class='tablenav-pages'>$page_links</div>"; |
176 | ?> |
177 | |
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> |
182 | </select> |
183 | <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> |
184 | <?php wp_nonce_field('bulk-tags'); ?> |
185 | </div> |
186 | |
187 | <br class="clear" /> |
188 | </div> |
189 | |
190 | <div class="clear"></div> |
191 | |
192 | <table class="widefat tag fixed" cellspacing="0"> |
193 | <thead> |
194 | <tr> |
195 | <?php print_column_headers('edit-tags'); ?> |
196 | </tr> |
197 | </thead> |
198 | |
199 | <tfoot> |
200 | <tr> |
201 | <?php print_column_headers('edit-tags', false); ?> |
202 | </tr> |
203 | </tfoot> |
204 | |
205 | <tbody id="the-list" class="list:tag"> |
206 | <?php |
207 | |
208 | $searchterms = isset( $_GET['s'] ) ? trim( $_GET['s'] ) : ''; |
209 | |
210 | $count = tag_rows( $pagenum, $tagsperpage, $searchterms ); |
211 | ?> |
212 | </tbody> |
213 | </table> |
214 | |
215 | <div class="tablenav"> |
216 | <?php |
217 | if ( $page_links ) |
218 | echo "<div class='tablenav-pages'>$page_links</div>"; |
219 | ?> |
220 | |
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> |
225 | </select> |
226 | <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> |
227 | </div> |
228 | |
229 | <br class="clear" /> |
230 | </div> |
231 | |
232 | <br class="clear" /> |
233 | </form> |
234 | </div> |
235 | </div><!-- /col-right --> |
236 | |
237 | <div id="col-left"> |
238 | <div class="col-wrap"> |
239 | |
240 | <div class="tagcloud"> |
241 | <h3><?php _e('Popular Tags'); ?></h3> |
242 | <?php |
243 | if ( $can_manage ) |
244 | wp_tag_cloud(array('link' => 'edit')); |
245 | else |
246 | wp_tag_cloud(); |
247 | ?> |
248 | </div> |
249 | |
250 | <?php if ( $can_manage ) { |
251 | do_action('add_tag_form_pre'); ?> |
252 | |
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'); ?> |
259 | |
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> |
264 | </div> |
265 | |
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> |
270 | </div> |
271 | |
272 | <p class="submit"><input type="submit" class="button" name="submit" value="<?php _e('Add Tag'); ?>" /></p> |
273 | <?php do_action('add_tag_form'); ?> |
274 | </form></div> |
275 | <?php } ?> |
276 | |
277 | </div> |
278 | </div><!-- /col-left --> |
279 | |
280 | </div><!-- /col-container --> |
281 | </div><!-- /wrap --> |
282 | |
283 | <script type="text/javascript"> |
284 | /* <![CDATA[ */ |
285 | (function($){ |
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); |
291 | } |
292 | }); |
293 | }); |
294 | })(jQuery); |
295 | /* ]]> */ |
296 | </script> |
297 | |
298 | <?php inline_edit_term_row('edit-tags'); ?> |
299 | |
300 | <?php |
301 | break; |
302 | } |
303 | |
304 | include('admin-footer.php'); |
305 | |
306 | ?> |