- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-terms-list-table.php
r41684 r42343 39 39 global $post_type, $taxonomy, $action, $tax; 40 40 41 parent::__construct( array( 42 'plural' => 'tags', 43 'singular' => 'tag', 44 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 45 ) ); 41 parent::__construct( 42 array( 43 'plural' => 'tags', 44 'singular' => 'tag', 45 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, 46 ) 47 ); 46 48 47 49 $action = $this->screen->action; … … 49 51 $taxonomy = $this->screen->taxonomy; 50 52 51 if ( empty( $taxonomy ) ) 53 if ( empty( $taxonomy ) ) { 52 54 $taxonomy = 'post_tag'; 53 54 if ( ! taxonomy_exists( $taxonomy ) ) 55 } 56 57 if ( ! taxonomy_exists( $taxonomy ) ) { 55 58 wp_die( __( 'Invalid taxonomy.' ) ); 59 } 56 60 57 61 $tax = get_taxonomy( $taxonomy ); 58 62 59 63 // @todo Still needed? Maybe just the show_ui part. 60 if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) )64 if ( empty( $post_type ) || ! in_array( $post_type, get_post_types( array( 'show_ui' => true ) ) ) ) { 61 65 $post_type = 'post'; 62 63 } 64 65 /** 66 66 } 67 68 } 69 70 /** 67 71 * @return bool 68 72 */ … … 106 110 } 107 111 108 $search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : '';112 $search = ! empty( $_REQUEST['s'] ) ? trim( wp_unslash( $_REQUEST['s'] ) ) : ''; 109 113 110 114 $args = array( 111 115 'search' => $search, 112 'page' => $this->get_pagenum(),116 'page' => $this->get_pagenum(), 113 117 'number' => $tags_per_page, 114 118 ); 115 119 116 if ( ! empty( $_REQUEST['orderby'] ) )120 if ( ! empty( $_REQUEST['orderby'] ) ) { 117 121 $args['orderby'] = trim( wp_unslash( $_REQUEST['orderby'] ) ); 118 119 if ( !empty( $_REQUEST['order'] ) ) 122 } 123 124 if ( ! empty( $_REQUEST['order'] ) ) { 120 125 $args['order'] = trim( wp_unslash( $_REQUEST['order'] ) ); 126 } 121 127 122 128 $this->callback_args = $args; 123 129 124 $this->set_pagination_args( array( 125 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), 126 'per_page' => $tags_per_page, 127 ) ); 128 } 129 130 /** 131 * 130 $this->set_pagination_args( 131 array( 132 'total_items' => wp_count_terms( $this->screen->taxonomy, compact( 'search' ) ), 133 'per_page' => $tags_per_page, 134 ) 135 ); 136 } 137 138 /** 132 139 * @return bool 133 140 */ … … 144 151 145 152 /** 146 *147 153 * @return array 148 154 */ … … 158 164 159 165 /** 160 *161 166 * @return string 162 167 */ 163 168 public function current_action() { 164 if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) 169 if ( isset( $_REQUEST['action'] ) && isset( $_REQUEST['delete_tags'] ) && ( 'delete' === $_REQUEST['action'] || 'delete' === $_REQUEST['action2'] ) ) { 165 170 return 'bulk-delete'; 171 } 166 172 167 173 return parent::current_action(); … … 169 175 170 176 /** 171 *172 177 * @return array 173 178 */ … … 190 195 191 196 /** 192 *193 197 * @return array 194 198 */ … … 199 203 'slug' => 'slug', 200 204 'posts' => 'count', 201 'links' => 'count' 205 'links' => 'count', 202 206 ); 203 207 } … … 208 212 $taxonomy = $this->screen->taxonomy; 209 213 210 $args = wp_parse_args( $this->callback_args, array( 211 'page' => 1, 212 'number' => 20, 213 'search' => '', 214 'hide_empty' => 0 215 ) ); 214 $args = wp_parse_args( 215 $this->callback_args, array( 216 'page' => 1, 217 'number' => 20, 218 'search' => '', 219 'hide_empty' => 0, 220 ) 221 ); 216 222 217 223 $page = $args['page']; … … 269 275 foreach ( $terms as $key => $term ) { 270 276 271 if ( $count >= $end ) 277 if ( $count >= $end ) { 272 278 break; 273 274 if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) 279 } 280 281 if ( $term->parent != $parent && empty( $_REQUEST['s'] ) ) { 275 282 continue; 283 } 276 284 277 285 // If the page starts in a subtree, print the parents. 278 286 if ( $count == $start && $term->parent > 0 && empty( $_REQUEST['s'] ) ) { 279 287 $my_parents = $parent_ids = array(); 280 $p = $term->parent;288 $p = $term->parent; 281 289 while ( $p ) { 282 $my_parent = get_term( $p, $taxonomy );290 $my_parent = get_term( $p, $taxonomy ); 283 291 $my_parents[] = $my_parent; 284 $p = $my_parent->parent;285 if ( in_array( $p, $parent_ids ) ) // Prevent parent loops.292 $p = $my_parent->parent; 293 if ( in_array( $p, $parent_ids ) ) { // Prevent parent loops. 286 294 break; 295 } 287 296 $parent_ids[] = $p; 288 297 } … … 304 313 ++$count; 305 314 306 unset( $terms[ $key] );307 308 if ( isset( $children[ $term->term_id] ) && empty( $_REQUEST['s'] ) )315 unset( $terms[ $key ] ); 316 317 if ( isset( $children[ $term->term_id ] ) && empty( $_REQUEST['s'] ) ) { 309 318 $this->_rows( $taxonomy, $terms, $children, $start, $per_page, $count, $term->term_id, $level + 1 ); 319 } 310 320 } 311 321 } … … 318 328 public function single_row( $tag, $level = 0 ) { 319 329 global $taxonomy; 320 330 $tag = sanitize_term( $tag, $taxonomy ); 321 331 322 332 $this->level = $level; … … 419 429 420 430 $taxonomy = $this->screen->taxonomy; 421 $tax = get_taxonomy( $taxonomy );422 $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI'];431 $tax = get_taxonomy( $taxonomy ); 432 $uri = wp_doing_ajax() ? wp_get_referer() : $_SERVER['REQUEST_URI']; 423 433 424 434 $edit_link = add_query_arg( … … 522 532 523 533 $ptype_object = get_post_type_object( $this->screen->post_type ); 524 if ( ! $ptype_object->show_ui ) 534 if ( ! $ptype_object->show_ui ) { 525 535 return $count; 536 } 526 537 527 538 if ( $tax->query_var ) { 528 539 $args = array( $tax->query_var => $tag->slug ); 529 540 } else { 530 $args = array( 'taxonomy' => $tax->name, 'term' => $tag->slug ); 531 } 532 533 if ( 'post' != $this->screen->post_type ) 541 $args = array( 542 'taxonomy' => $tax->name, 543 'term' => $tag->slug, 544 ); 545 } 546 547 if ( 'post' != $this->screen->post_type ) { 534 548 $args['post_type'] = $this->screen->post_type; 535 536 if ( 'attachment' === $this->screen->post_type ) 537 return "<a href='" . esc_url ( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; 538 539 return "<a href='" . esc_url ( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; 549 } 550 551 if ( 'attachment' === $this->screen->post_type ) { 552 return "<a href='" . esc_url( add_query_arg( $args, 'upload.php' ) ) . "'>$count</a>"; 553 } 554 555 return "<a href='" . esc_url( add_query_arg( $args, 'edit.php' ) ) . "'>$count</a>"; 540 556 } 541 557 … … 546 562 public function column_links( $tag ) { 547 563 $count = number_format_i18n( $tag->count ); 548 if ( $count ) 564 if ( $count ) { 549 565 $count = "<a href='link-manager.php?cat_id=$tag->term_id'>$count</a>"; 566 } 550 567 return $count; 551 568 } … … 580 597 $tax = get_taxonomy( $this->screen->taxonomy ); 581 598 582 if ( ! current_user_can( $tax->cap->edit_terms ) ) 599 if ( ! current_user_can( $tax->cap->edit_terms ) ) { 583 600 return; 601 } 584 602 ?> 585 603 … … 594 612 <span class="input-text-wrap"><input type="text" name="name" class="ptitle" value="" /></span> 595 613 </label> 596 <?php if ( ! global_terms_enabled() ) { ?>614 <?php if ( ! global_terms_enabled() ) { ?> 597 615 <label> 598 616 <span class="title"><?php _e( 'Slug' ); ?></span> … … 603 621 <?php 604 622 605 $core_columns = array( 'cb' => true, 'description' => true, 'name' => true, 'slug' => true, 'posts' => true ); 623 $core_columns = array( 624 'cb' => true, 625 'description' => true, 626 'name' => true, 627 'slug' => true, 628 'posts' => true, 629 ); 606 630 607 631 list( $columns ) = $this->get_column_info(); 608 632 609 foreach ( $columns as $column_name => $column_display_name ) { 610 if ( isset( $core_columns[$column_name] ) ) 611 continue; 612 613 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ 614 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); 615 } 633 foreach ( $columns as $column_name => $column_display_name ) { 634 if ( isset( $core_columns[ $column_name ] ) ) { 635 continue; 636 } 637 638 /** This action is documented in wp-admin/includes/class-wp-posts-list-table.php */ 639 do_action( 'quick_edit_custom_box', $column_name, 'edit-tags', $this->screen->taxonomy ); 640 } 616 641 617 642 ?>
Note: See TracChangeset
for help on using the changeset viewer.