WordPress 3.0 beta 1 documentation kindly provided to you by Hay Kranen
| [ Index ] |
PHP Cross Reference of WordPress 3.0 beta 1 |
|
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
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 wp_reset_vars( array('action', 'tag', 'taxonomy', 'post_type') ); 13 14 if ( empty($taxonomy) ) 15 $taxonomy = 'post_tag'; 16 17 if ( !is_taxonomy($taxonomy) ) 18 wp_die(__('Invalid taxonomy')); 19 20 $tax = get_taxonomy($taxonomy); 21 22 $title = $tax->label; 23 24 if ( empty($post_type) || !in_array( $post_type, get_post_types( array('public' => true) ) ) ) 25 $post_type = 'post'; 26 27 if ( 'post' != $post_type ) { 28 $parent_file = "edit.php?post_type=$post_type"; 29 $submenu_file = "edit-tags.php?taxonomy=$taxonomy&post_type=$post_type"; 30 } else { 31 $parent_file = 'edit.php'; 32 $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; 33 } 34 35 if ( isset( $_GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) ) 36 $action = 'bulk-delete'; 37 38 switch($action) { 39 40 case 'add-tag': 41 42 check_admin_referer('add-tag'); 43 44 if ( !current_user_can($tax->edit_cap) ) 45 wp_die(__('Cheatin’ uh?')); 46 47 $ret = wp_insert_term($_POST['tag-name'], $taxonomy, $_POST); 48 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 49 if ( 'post' != $post_type ) 50 $location .= '&post_type=' . $post_type; 51 52 if ( $referer = wp_get_original_referer() ) { 53 if ( false !== strpos($referer, 'edit-tags.php') ) 54 $location = $referer; 55 } 56 57 if ( $ret && !is_wp_error( $ret ) ) 58 $location = add_query_arg('message', 1, $location); 59 else 60 $location = add_query_arg('message', 4, $location); 61 wp_redirect($location); 62 exit; 63 break; 64 65 case 'delete': 66 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 67 if ( 'post' != $post_type ) 68 $location .= '&post_type=' . $post_type; 69 if ( $referer = wp_get_referer() ) { 70 if ( false !== strpos($referer, 'edit-tags.php') ) 71 $location = $referer; 72 } 73 74 if ( !isset( $_GET['tag_ID'] ) ) { 75 wp_redirect($location); 76 exit; 77 } 78 79 $tag_ID = (int) $_GET['tag_ID']; 80 check_admin_referer('delete-tag_' . $tag_ID); 81 82 if ( !current_user_can($tax->delete_cap) ) 83 wp_die(__('Cheatin’ uh?')); 84 85 wp_delete_term( $tag_ID, $taxonomy); 86 87 $location = add_query_arg('message', 2, $location); 88 wp_redirect($location); 89 exit; 90 91 break; 92 93 case 'bulk-delete': 94 check_admin_referer('bulk-tags'); 95 96 if ( !current_user_can($tax->delete_cap) ) 97 wp_die(__('Cheatin’ uh?')); 98 99 $tags = (array) $_GET['delete_tags']; 100 foreach( $tags as $tag_ID ) { 101 wp_delete_term( $tag_ID, $taxonomy); 102 } 103 104 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 105 if ( 'post' != $post_type ) 106 $location .= '&post_type=' . $post_type; 107 if ( $referer = wp_get_referer() ) { 108 if ( false !== strpos($referer, 'edit-tags.php') ) 109 $location = $referer; 110 } 111 112 $location = add_query_arg('message', 6, $location); 113 wp_redirect($location); 114 exit; 115 116 break; 117 118 case 'edit': 119 $title = sprintf(_x('Edit %s', '%s: singular taxonomy name'), $tax->singular_label); 120 121 require_once ('admin-header.php'); 122 $tag_ID = (int) $_GET['tag_ID']; 123 124 $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit'); 125 include ('edit-tag-form.php'); 126 127 break; 128 129 case 'editedtag': 130 $tag_ID = (int) $_POST['tag_ID']; 131 check_admin_referer('update-tag_' . $tag_ID); 132 133 if ( !current_user_can($tax->edit_cap) ) 134 wp_die(__('Cheatin’ uh?')); 135 136 $ret = wp_update_term($tag_ID, $taxonomy, $_POST); 137 138 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 139 if ( 'post' != $post_type ) 140 $location .= '&post_type=' . $post_type; 141 142 if ( $referer = wp_get_original_referer() ) { 143 if ( false !== strpos($referer, 'edit-tags.php') ) 144 $location = $referer; 145 } 146 147 if ( $ret && !is_wp_error( $ret ) ) 148 $location = add_query_arg('message', 3, $location); 149 else 150 $location = add_query_arg('message', 5, $location); 151 152 wp_redirect($location); 153 exit; 154 break; 155 156 default: 157 158 if ( ! empty($_GET['_wp_http_referer']) ) { 159 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 160 exit; 161 } 162 163 wp_enqueue_script('admin-tags'); 164 if ( current_user_can($tax->edit_cap) ) 165 wp_enqueue_script('inline-edit-tax'); 166 167 require_once ('admin-header.php'); 168 169 $messages[1] = __('Item added.'); 170 $messages[2] = __('Item deleted.'); 171 $messages[3] = __('Item updated.'); 172 $messages[4] = __('Item not added.'); 173 $messages[5] = __('Item not updated.'); 174 $messages[6] = __('Items deleted.'); 175 176 ?> 177 178 <div class="wrap nosubsub"> 179 <?php screen_icon(); ?> 180 <h2><?php echo esc_html( $title ); 181 if ( !empty($_GET['s']) ) 182 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_GET['s']) ) ); ?> 183 </h2> 184 185 <?php if ( isset($_GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?> 186 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div> 187 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); 188 endif; ?> 189 <div id="ajax-response"></div> 190 191 <form class="search-form" action="" method="get"> 192 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 193 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 194 <p class="search-box"> 195 <label class="screen-reader-text" for="tag-search-input"><?php printf(_x('Search %s', '%s: plural taxonomy name'), $tax->label); ?>:</label> 196 <input type="text" id="tag-search-input" name="s" value="<?php _admin_search_query(); ?>" /> 197 <input type="submit" value="<?php echo esc_attr( sprintf(_x('Search %s', '%s: plural taxonomy name'), $tax->label) ); ?>" class="button" /> 198 </p> 199 </form> 200 <br class="clear" /> 201 202 <div id="col-container"> 203 204 <div id="col-right"> 205 <div class="col-wrap"> 206 <form id="posts-filter" action="" method="get"> 207 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 208 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 209 <div class="tablenav"> 210 <?php 211 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; 212 if ( empty($pagenum) ) 213 $pagenum = 1; 214 215 if ( 'post_tag' == $taxonomy ) 216 $tags_per_page = (int) get_user_option( 'edit_tags_per_page' ); 217 elseif ( 'category' == $taxonomy ) 218 $tags_per_page = (int) get_user_option( 'categories_per_page' ); 219 else 220 $tags_per_page = (int) get_user_option( 'edit_' . $taxonomy . '_per_page' ); 221 222 if ( empty($tags_per_page) || $tags_per_page < 1 ) 223 $tags_per_page = 20; 224 225 if ( 'post_tag' == $taxonomy ) { 226 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 227 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 228 } elseif ( 'category' == $taxonomy ) { 229 $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter 230 } else { 231 $tags_per_page = apply_filters( 'edit_' . $taxonomy . '_per_page', $tags_per_page ); 232 } 233 234 $searchterms = !empty($_GET['s']) ? trim(stripslashes($_GET['s'])) : ''; 235 236 $page_links = paginate_links( array( 237 'base' => add_query_arg( 'pagenum', '%#%' ), 238 'format' => '', 239 'prev_text' => __('«'), 240 'next_text' => __('»'), 241 'total' => ceil(wp_count_terms($taxonomy, array('search' => $searchterms)) / $tags_per_page), 242 'current' => $pagenum 243 )); 244 245 if ( $page_links ) 246 echo "<div class='tablenav-pages'>$page_links</div>"; 247 ?> 248 249 <div class="alignleft actions"> 250 <select name="action"> 251 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 252 <option value="delete"><?php _e('Delete'); ?></option> 253 </select> 254 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 255 <?php wp_nonce_field('bulk-tags'); ?> 256 </div> 257 258 <br class="clear" /> 259 </div> 260 261 <div class="clear"></div> 262 <?php $table_type = ('category' == $taxonomy ? 'categories' : 'edit-tags'); ?> 263 <table class="widefat tag fixed" cellspacing="0"> 264 <thead> 265 <tr> 266 <?php print_column_headers($table_type); ?> 267 </tr> 268 </thead> 269 270 <tfoot> 271 <tr> 272 <?php print_column_headers($table_type, false); ?> 273 </tr> 274 </tfoot> 275 276 <tbody id="the-list" class="list:tag"> 277 <?php tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); ?> 278 </tbody> 279 </table> 280 281 <div class="tablenav"> 282 <?php 283 if ( $page_links ) 284 echo "<div class='tablenav-pages'>$page_links</div>"; 285 ?> 286 287 <div class="alignleft actions"> 288 <select name="action2"> 289 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 290 <option value="delete"><?php _e('Delete'); ?></option> 291 </select> 292 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 293 </div> 294 295 <br class="clear" /> 296 </div> 297 298 <br class="clear" /> 299 </form> 300 301 <?php if ( 'category' == $taxonomy ) : ?> 302 <div class="form-wrap"> 303 <p><?php printf(__('<strong>Note:</strong><br />Deleting a category does not delete the posts in that category. Instead, posts that were only assigned to the deleted category are set to the category <strong>%s</strong>.'), apply_filters('the_category', get_cat_name(get_option('default_category')))) ?></p> 304 <p><?php printf(__('Categories can be selectively converted to tags using the <a href="%s">category to tag converter</a>.'), 'admin.php?import=wp-cat2tag') ?></p> 305 </div> 306 <?php elseif ( 'post_tag' == $taxonomy ) : ?> 307 <div class="form-wrap"> 308 <p><?php printf(__('Tags can be selectively converted to categories using the <a href="%s">tag to category converter</a>'), 'admin.php?import=wp-cat2tag&step=3') ;?>.</p> 309 </div> 310 <?php endif; 311 do_action('after-' . $taxonomy . '-table', $taxonomy); 312 ?> 313 314 </div> 315 </div><!-- /col-right --> 316 317 <div id="col-left"> 318 <div class="col-wrap"> 319 320 <?php 321 if ( current_user_can( $tax->edit_cap ) ) 322 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); 323 else 324 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false ) ); 325 326 if ( $tag_cloud ) : 327 ?> 328 <div class="tagcloud"> 329 <h3><?php printf(_x('Popular %s', '%s: plural taxonomy name'), $tax->label); ?></h3> 330 <?php echo $tag_cloud; unset( $tag_cloud ); ?> 331 </div> 332 <?php 333 endif; 334 335 if ( current_user_can($tax->edit_cap) ) { 336 if ( 'category' == $taxonomy ) 337 do_action('add_category_form_pre', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_pre_add_form 338 else 339 do_action('add_tag_form_pre', $taxonomy); // Back compat hook. Applies to all Taxonomies -not- categories 340 do_action($taxonomy . '_pre_add_form', $taxonomy); 341 ?> 342 343 <div class="form-wrap"> 344 <h3><?php printf(_x('Add a New %s', '%s: singular taxonomy name'), $tax->singular_label); ?></h3> 345 <form id="addtag" method="post" action="edit-tags.php" class="validate"> 346 <input type="hidden" name="action" value="add-tag" /> 347 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 348 <?php wp_nonce_field('add-tag'); ?> 349 350 <div class="form-field form-required"> 351 <label for="tag-name"><?php echo _x('Name', 'Taxonomy Name'); ?></label> 352 <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true" /> 353 <p><?php _e('The name is how it appears on your site.'); ?></p> 354 </div> 355 <?php if ( !is_multisite() ) : ?> 356 <div class="form-field"> 357 <label for="tag-slug"><?php echo _x('Slug', 'Taxonomy Slug'); ?></label> 358 <input name="slug" id="tag-slug" type="text" value="" size="40" /> 359 <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> 360 </div> 361 <?php endif; // is_multisite() ?> 362 <?php if ( is_taxonomy_hierarchical($taxonomy) ) : ?> 363 <div class="form-field"> 364 <label for="parent"><?php echo _x('Parent', 'Taxonomy Parent'); ?></label> 365 <?php wp_dropdown_categories(array('hide_empty' => 0, 'hide_if_empty' => false, 'taxonomy' => $taxonomy, 'name' => 'parent', 'orderby' => 'name', 'hierarchical' => true, 'show_option_none' => __('None'))); ?> 366 <?php if ( 'category' == $taxonomy ) : // @todo: Generic text for hierarchical taxonomies ?> 367 <p><?php _e('Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and under that have children categories for Bebop and Big Band. Totally optional.'); ?></p> 368 <?php endif; ?> 369 </div> 370 <?php endif; // is_taxonomy_hierarchical() ?> 371 <div class="form-field"> 372 <label for="tag-description"><?php echo _x('Description', 'Taxonomy Description'); ?></label> 373 <textarea name="description" id="tag-description" rows="5" cols="40"></textarea> 374 <p><?php _e('The description is not prominent by default; however, some themes may show it.'); ?></p> 375 </div> 376 377 <?php 378 if ( ! is_taxonomy_hierarchical($taxonomy) ) 379 do_action('add_tag_form_fields', $taxonomy); 380 do_action($taxonomy . '_add_form_fields', $taxonomy); 381 ?> 382 <p class="submit"><input type="submit" class="button" name="submit" id="submit" value="<?php echo esc_attr(sprintf(_x('Add %s', '%s: singular taxonomy name'), $tax->singular_label)); ?>" /></p> 383 <?php 384 if ( 'category' == $taxonomy ) 385 do_action('edit_category_form', (object)array('parent' => 0) ); // Back compat hook. Deprecated in preference to $taxonomy_add_form 386 else 387 do_action('add_tag_form', $taxonomy); // Back compat hook. Applies to all Taxonomies -not- categories 388 do_action($taxonomy . '_add_form', $taxonomy); 389 ?> 390 </form></div> 391 <?php } ?> 392 393 </div> 394 </div><!-- /col-left --> 395 396 </div><!-- /col-container --> 397 </div><!-- /wrap --> 398 399 <?php inline_edit_term_row('edit-tags', $taxonomy); ?> 400 401 <?php 402 break; 403 } 404 405 include ('admin-footer.php'); 406 407 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Apr 5 14:26:09 2010 | Cross-referenced by PHPXref 0.7 |