Changeset 21914 for trunk/wp-admin/includes/class-wp-terms-list-table.php
- Timestamp:
- 09/19/2012 12:43:31 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/class-wp-terms-list-table.php
r21323 r21914 12 12 var $callback_args; 13 13 14 function __construct() { 15 global $post_type, $taxonomy, $tax; 16 17 wp_reset_vars( array( 'action', 'taxonomy', 'post_type' ) ); 18 19 if ( empty( $taxonomy ) ) 20 $taxonomy = 'post_tag'; 21 22 if ( !taxonomy_exists( $taxonomy ) ) 23 wp_die( __( 'Invalid taxonomy' ) ); 24 25 $tax = get_taxonomy( $taxonomy ); 26 27 if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) 28 $post_type = 'post'; 14 function __construct( $args = array() ) { 15 global $post_type, $taxonomy, $action, $tax; 29 16 30 17 parent::__construct( array( 31 18 'plural' => 'tags', 32 19 'singular' => 'tag', 20 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 33 21 ) ); 22 23 $action = $this->screen->action; 24 $post_type = $this->screen->post_type; 25 $taxonomy = $this->screen->taxonomy; 26 27 if ( empty( $taxonomy ) ) 28 $taxonomy = 'post_tag'; 29 30 if ( ! taxonomy_exists( $taxonomy ) ) 31 wp_die( __( 'Invalid taxonomy' ) ); 32 33 $tax = get_taxonomy( $taxonomy ); 34 35 // @todo Still needed? Maybe just the show_ui part. 36 if ( empty( $post_type ) || !in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) 37 $post_type = 'post'; 38 34 39 } 35 40 36 41 function ajax_user_can() { 37 global $tax; 38 39 return current_user_can( $tax->cap->manage_terms ); 42 return current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->manage_terms ); 40 43 } 41 44 42 45 function prepare_items() { 43 global $taxonomy; 44 45 $tags_per_page = $this->get_items_per_page( 'edit_' . $taxonomy . '_per_page' ); 46 47 if ( 'post_tag' == $taxonomy ) { 46 $tags_per_page = $this->get_items_per_page( 'edit_' . $this->screen->taxonomy . '_per_page' ); 47 48 if ( 'post_tag' == $this->screen->taxonomy ) { 48 49 $tags_per_page = apply_filters( 'edit_tags_per_page', $tags_per_page ); 49 50 $tags_per_page = apply_filters( 'tagsperpage', $tags_per_page ); // Old filter 50 } elseif ( 'category' == $t axonomy ) {51 } elseif ( 'category' == $this->screen->taxonomy ) { 51 52 $tags_per_page = apply_filters( 'edit_categories_per_page', $tags_per_page ); // Old filter 52 53 } … … 69 70 70 71 $this->set_pagination_args( array( 71 'total_items' => wp_count_terms( $t axonomy, compact( 'search' ) ),72 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), 72 73 'per_page' => $tags_per_page, 73 74 ) ); … … 94 95 95 96 function get_columns() { 96 global $taxonomy, $post_type;97 98 97 $columns = array( 99 98 'cb' => '<input type="checkbox" />', … … 103 102 ); 104 103 105 if ( 'link_category' == $t axonomy ) {104 if ( 'link_category' == $this->screen->taxonomy ) { 106 105 $columns['links'] = __( 'Links' ); 107 106 } else { 108 $post_type_object = get_post_type_object( $ post_type );107 $post_type_object = get_post_type_object( $this->screen->post_type ); 109 108 $columns['posts'] = $post_type_object ? $post_type_object->labels->name : __( 'Posts' ); 110 109 } … … 124 123 125 124 function display_rows_or_placeholder() { 126 global $taxonomy;125 $taxonomy = $this->screen->taxonomy; 127 126 128 127 $args = wp_parse_args( $this->callback_args, array( … … 232 231 233 232 function column_cb( $tag ) { 234 global $taxonomy, $tax; 235 236 $default_term = get_option( 'default_' . $taxonomy ); 237 238 if ( current_user_can( $tax->cap->delete_terms ) && $tag->term_id != $default_term ) 233 $default_term = get_option( 'default_' . $this->screen->taxonomy ); 234 235 if ( current_user_can( get_taxonomy( $this->screen->taxonomy )->cap->delete_terms ) && $tag->term_id != $default_term ) 239 236 return '<label class="screen-reader-text" for="cb-select-' . $tag->term_id . '">' . sprintf( __( 'Select %s' ), $tag->name ) . '</label>' 240 237 . '<input type="checkbox" name="delete_tags[]" value="' . $tag->term_id . '" id="cb-select-' . $tag->term_id . '" />'; … … 244 241 245 242 function column_name( $tag ) { 246 global $taxonomy, $tax, $post_type; 243 $taxonomy = $this->screen->taxonomy; 244 $tax = get_taxonomy( $taxonomy ); 247 245 248 246 $default_term = get_option( 'default_' . $taxonomy ); … … 251 249 $name = apply_filters( 'term_name', $pad . ' ' . $tag->name, $tag ); 252 250 $qe_data = get_term( $tag->term_id, $taxonomy, OBJECT, 'edit' ); 253 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $ post_type ) );251 $edit_link = esc_url( get_edit_term_link( $tag->term_id, $taxonomy, $this->screen->post_type ) ); 254 252 255 253 $out = '<strong><a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $name ) ) . '">' . $name . '</a></strong><br />'; … … 285 283 286 284 function column_posts( $tag ) { 287 global $taxonomy, $post_type;288 289 285 $count = number_format_i18n( $tag->count ); 290 286 291 $tax = get_taxonomy( $t axonomy );292 293 $ptype_object = get_post_type_object( $ post_type );287 $tax = get_taxonomy( $this->screen->taxonomy ); 288 289 $ptype_object = get_post_type_object( $this->screen->post_type ); 294 290 if ( ! $ptype_object->show_ui ) 295 291 return $count; … … 301 297 } 302 298 303 if ( 'post' != $ post_type )304 $args['post_type'] = $ post_type;299 if ( 'post' != $this->screen->post_type ) 300 $args['post_type'] = $this->screen->post_type; 305 301 306 302 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; … … 315 311 316 312 function column_default( $tag, $column_name ) { 317 $screen = get_current_screen(); 318 319 return apply_filters( "manage_{$screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); 313 return apply_filters( "manage_{$this->screen->taxonomy}_custom_column", '', $column_name, $tag->term_id ); 320 314 } 321 315 … … 326 320 */ 327 321 function inline_edit() { 328 global $post_type, $tax;322 $tax = get_taxonomy( $this->screen->taxonomy ); 329 323 330 324 if ( ! current_user_can( $tax->cap->edit_terms ) ) … … 359 353 continue; 360 354 361 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $t ax->name);355 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); 362 356 } 363 357 … … 371 365 <span class="error" style="display:none;"></span> 372 366 <?php wp_nonce_field( 'taxinlineeditnonce', '_inline_edit', false ); ?> 373 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $t ax->name); ?>" />374 <input type="hidden" name="post_type" value="<?php echo esc_attr( $ post_type ); ?>" />367 <input type="hidden" name="taxonomy" value="<?php echo esc_attr( $this->screen->taxonomy ); ?>" /> 368 <input type="hidden" name="post_type" value="<?php echo esc_attr( $this->screen->post_type ); ?>" /> 375 369 <br class="clear" /> 376 370 </p>
Note: See TracChangeset
for help on using the changeset viewer.