Changeset 15491 for trunk/wp-admin/edit-tags.php
- Timestamp:
- 08/11/2010 09:54:51 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/edit-tags.php (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-tags.php
r15441 r15491 10 10 require_once('./admin.php'); 11 11 12 wp_reset_vars( array('action', 'tag', 'taxonomy', 'post_type') ); 13 14 if ( empty($taxonomy) ) 15 $taxonomy = 'post_tag'; 16 17 if ( !taxonomy_exists($taxonomy) ) 18 wp_die(__('Invalid taxonomy')); 19 20 $tax = get_taxonomy($taxonomy); 21 22 if ( ! current_user_can($tax->cap->manage_terms) ) 23 wp_die(__('Cheatin’ uh?')); 12 require_once( './includes/default-list-tables.php' ); 13 14 $table = new WP_Terms_Table; 24 15 25 16 $title = $tax->labels->name; 26 27 if ( empty($post_type) || !in_array( $post_type, get_post_types( array('public' => true) ) ) )28 $post_type = 'post';29 17 30 18 if ( 'post' != $post_type ) { … … 36 24 } 37 25 38 if ( isset( $_ GET['action'] ) && isset($_GET['delete_tags']) && ( 'delete' == $_GET['action'] || 'delete' == $_GET['action2'] ) )26 if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' == $_REQUEST['action'] || 'delete' == $_REQUEST['action2'] ) ) 39 27 $action = 'bulk-delete'; 40 28 41 switch ($action) {29 switch ( $action ) { 42 30 43 31 case 'add-tag': 44 32 45 check_admin_referer( 'add-tag');46 47 if ( !current_user_can( $tax->cap->edit_terms) )48 wp_die( __('Cheatin’ uh?'));49 50 $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST);33 check_admin_referer( 'add-tag' ); 34 35 if ( !current_user_can( $tax->cap->edit_terms ) ) 36 wp_die( __( 'Cheatin’ uh?' ) ); 37 38 $ret = wp_insert_term( $_POST['tag-name'], $taxonomy, $_POST ); 51 39 $location = 'edit-tags.php?taxonomy=' . $taxonomy; 52 40 if ( 'post' != $post_type ) … … 54 42 55 43 if ( $referer = wp_get_original_referer() ) { 56 if ( false !== strpos( $referer, 'edit-tags.php') )44 if ( false !== strpos( $referer, 'edit-tags.php' ) ) 57 45 $location = $referer; 58 46 } 59 47 60 48 if ( $ret && !is_wp_error( $ret ) ) 61 $location = add_query_arg( 'message', 1, $location);62 else 63 $location = add_query_arg( 'message', 4, $location);64 wp_redirect( $location);49 $location = add_query_arg( 'message', 1, $location ); 50 else 51 $location = add_query_arg( 'message', 4, $location ); 52 wp_redirect( $location ); 65 53 exit; 66 54 break; … … 71 59 $location .= '&post_type=' . $post_type; 72 60 if ( $referer = wp_get_referer() ) { 73 if ( false !== strpos( $referer, 'edit-tags.php') )61 if ( false !== strpos( $referer, 'edit-tags.php' ) ) 74 62 $location = $referer; 75 63 } 76 64 77 if ( !isset( $_ GET['tag_ID'] ) ) {78 wp_redirect( $location);65 if ( !isset( $_REQUEST['tag_ID'] ) ) { 66 wp_redirect( $location ); 79 67 exit; 80 68 } 81 69 82 $tag_ID = (int) $_ GET['tag_ID'];83 check_admin_referer( 'delete-tag_' . $tag_ID);84 85 if ( !current_user_can( $tax->cap->delete_terms) )86 wp_die( __('Cheatin’ uh?'));87 88 wp_delete_term( $tag_ID, $taxonomy );89 90 $location = add_query_arg( 'message', 2, $location);91 wp_redirect( $location);70 $tag_ID = (int) $_REQUEST['tag_ID']; 71 check_admin_referer( 'delete-tag_' . $tag_ID ); 72 73 if ( !current_user_can( $tax->cap->delete_terms ) ) 74 wp_die( __( 'Cheatin’ uh?' ) ); 75 76 wp_delete_term( $tag_ID, $taxonomy ); 77 78 $location = add_query_arg( 'message', 2, $location ); 79 wp_redirect( $location ); 92 80 exit; 93 81 … … 95 83 96 84 case 'bulk-delete': 97 check_admin_referer( 'bulk-tags');98 99 if ( !current_user_can( $tax->cap->delete_terms) )100 wp_die( __('Cheatin’ uh?'));101 102 $tags = (array) $_ GET['delete_tags'];103 foreach ( $tags as $tag_ID ) {104 wp_delete_term( $tag_ID, $taxonomy );85 check_admin_referer( 'bulk-tags' ); 86 87 if ( !current_user_can( $tax->cap->delete_terms ) ) 88 wp_die( __( 'Cheatin’ uh?' ) ); 89 90 $tags = (array) $_REQUEST['delete_tags']; 91 foreach ( $tags as $tag_ID ) { 92 wp_delete_term( $tag_ID, $taxonomy ); 105 93 } 106 94 … … 109 97 $location .= '&post_type=' . $post_type; 110 98 if ( $referer = wp_get_referer() ) { 111 if ( false !== strpos( $referer, 'edit-tags.php') )99 if ( false !== strpos( $referer, 'edit-tags.php' ) ) 112 100 $location = $referer; 113 101 } 114 102 115 $location = add_query_arg( 'message', 6, $location);116 wp_redirect( $location);103 $location = add_query_arg( 'message', 6, $location ); 104 wp_redirect( $location ); 117 105 exit; 118 106 … … 122 110 $title = $tax->labels->edit_item; 123 111 124 require_once ('admin-header.php'); 125 $tag_ID = (int) $_GET['tag_ID']; 126 127 if ( !current_user_can($tax->cap->edit_terms) ) 128 wp_die( __('You are not allowed to edit this item.') ); 129 130 $tag = get_term($tag_ID, $taxonomy, OBJECT, 'edit'); 131 include('./edit-tag-form.php'); 112 require_once ( 'admin-header.php' ); 113 $tag_ID = (int) $_REQUEST['tag_ID']; 114 115 $tag = get_term( $tag_ID, $taxonomy, OBJECT, 'edit' ); 116 include( './edit-tag-form.php' ); 132 117 133 118 break; … … 135 120 case 'editedtag': 136 121 $tag_ID = (int) $_POST['tag_ID']; 137 check_admin_referer( 'update-tag_' . $tag_ID);138 139 if ( !current_user_can( $tax->cap->edit_terms) )140 wp_die( __('Cheatin’ uh?'));141 142 $ret = wp_update_term( $tag_ID, $taxonomy, $_POST);122 check_admin_referer( 'update-tag_' . $tag_ID ); 123 124 if ( !current_user_can( $tax->cap->edit_terms ) ) 125 wp_die( __( 'Cheatin’ uh?' ) ); 126 127 $ret = wp_update_term( $tag_ID, $taxonomy, $_POST ); 143 128 144 129 $location = 'edit-tags.php?taxonomy=' . $taxonomy; … … 147 132 148 133 if ( $referer = wp_get_original_referer() ) { 149 if ( false !== strpos( $referer, 'edit-tags.php') )134 if ( false !== strpos( $referer, 'edit-tags.php' ) ) 150 135 $location = $referer; 151 136 } 152 137 153 138 if ( $ret && !is_wp_error( $ret ) ) 154 $location = add_query_arg( 'message', 3, $location);155 else 156 $location = add_query_arg( 'message', 5, $location);157 158 wp_redirect( $location);139 $location = add_query_arg( 'message', 3, $location ); 140 else 141 $location = add_query_arg( 'message', 5, $location ); 142 143 wp_redirect( $location ); 159 144 exit; 160 145 break; … … 162 147 default: 163 148 164 if ( ! empty($_ GET['_wp_http_referer']) ) {149 if ( ! empty($_REQUEST['_wp_http_referer']) ) { 165 150 wp_redirect( remove_query_arg( array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI']) ) ); 166 151 exit; … … 209 194 210 195 require_once ('admin-header.php'); 196 197 if ( !current_user_can($tax->cap->edit_terms) ) 198 wp_die( __('You are not allowed to edit this item.') ); 211 199 212 200 $messages[1] = __('Item added.'); … … 222 210 <?php screen_icon(); ?> 223 211 <h2><?php echo esc_html( $title ); 224 if ( !empty($_ GET['s']) )225 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_ GET['s']) ) ); ?>212 if ( !empty($_REQUEST['s']) ) 213 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( stripslashes($_REQUEST['s']) ) ); ?> 226 214 </h2> 227 215 228 <?php if ( isset($_ GET['message']) && ( $msg = (int) $_GET['message'] ) ) : ?>216 <?php if ( isset($_REQUEST['message']) && ( $msg = (int) $_REQUEST['message'] ) ) : ?> 229 217 <div id="message" class="updated"><p><?php echo $messages[$msg]; ?></p></div> 230 218 <?php $_SERVER['REQUEST_URI'] = remove_query_arg(array('message'), $_SERVER['REQUEST_URI']); … … 247 235 <div id="col-right"> 248 236 <div class="col-wrap"> 249 <form id="posts-filter" action="" method=" get">237 <form id="posts-filter" action="" method="post"> 250 238 <input type="hidden" name="taxonomy" value="<?php echo esc_attr($taxonomy); ?>" /> 251 239 <input type="hidden" name="post_type" value="<?php echo esc_attr($post_type); ?>" /> 252 <div class="tablenav"> 253 <?php 254 $pagenum = isset( $_GET['pagenum'] ) ? absint( $_GET['pagenum'] ) : 0; 255 if ( empty($pagenum) ) 256 $pagenum = 1; 257 258 $tags_per_page = (int) get_user_option( 'edit_' . $taxonomy . '_per_page' ); 259 260 if ( empty($tags_per_page) || $tags_per_page < 1 ) 261 $tags_per_page = 20; 262 263 if ( 'post_tag' == $taxonomy ) { 264 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 265 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 266 } elseif ( 'category' == $taxonomy ) { 267 $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter 268 } else { 269 $tags_per_page = apply_filters( 'edit_' . $taxonomy . '_per_page', $tags_per_page ); 270 } 271 272 $searchterms = !empty($_GET['s']) ? trim(stripslashes($_GET['s'])) : ''; 273 274 $page_links = paginate_links( array( 275 'base' => add_query_arg( 'pagenum', '%#%' ), 276 'format' => '', 277 'prev_text' => __('«'), 278 'next_text' => __('»'), 279 'total' => ceil(wp_count_terms($taxonomy, array('search' => $searchterms)) / $tags_per_page), 280 'current' => $pagenum 281 )); 282 283 if ( $page_links ) 284 echo "<div class='tablenav-pages'>$page_links</div>"; 285 ?> 286 287 <div class="alignleft actions"> 288 <select name="action"> 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="doaction" id="doaction" class="button-secondary action" /> 293 <?php wp_nonce_field('bulk-tags'); ?> 294 </div> 295 296 <br class="clear" /> 297 </div> 298 299 <div class="clear"></div> 300 <table class="widefat tag fixed" cellspacing="0"> 301 <thead> 302 <tr> 303 <?php print_column_headers($current_screen); ?> 304 </tr> 305 </thead> 306 307 <tfoot> 308 <tr> 309 <?php print_column_headers($current_screen, false); ?> 310 </tr> 311 </tfoot> 312 313 <tbody id="the-list" class="list:tag"> 314 <?php tag_rows( $pagenum, $tags_per_page, $searchterms, $taxonomy ); ?> 315 </tbody> 316 </table> 317 318 <div class="tablenav"> 319 <?php 320 if ( $page_links ) 321 echo "<div class='tablenav-pages'>$page_links</div>"; 322 ?> 323 324 <div class="alignleft actions"> 325 <select name="action2"> 326 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option> 327 <option value="delete"><?php _e('Delete'); ?></option> 328 </select> 329 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 330 </div> 331 332 <br class="clear" /> 333 </div> 240 241 <?php $table->display_table(); ?> 334 242 335 243 <br class="clear" /> … … 359 267 <?php 360 268 361 if ( !is_ taxonomy_hierarchical($taxonomy) ) {269 if ( !is_null( $tax->labels->popular_items ) ) { 362 270 if ( current_user_can( $tax->cap->edit_terms ) ) 363 271 $tag_cloud = wp_tag_cloud( array( 'taxonomy' => $taxonomy, 'echo' => false, 'link' => 'edit' ) ); … … 441 349 </div><!-- /wrap --> 442 350 443 <?php inline_edit_term_row('edit-tags', $taxonomy); ?>351 <?php $table->inline_edit(); ?> 444 352 445 353 <?php
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)