Changeset 42343 for trunk/src/wp-admin/includes/class-wp-list-table.php
- 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-list-table.php
r42151 r42343 92 92 * @var array 93 93 */ 94 protected $compat_methods = array( 'set_pagination_args', 'get_views', 'get_bulk_actions', 'bulk_actions', 95 'row_actions', 'months_dropdown', 'view_switcher', 'comments_bubble', 'get_items_per_page', 'pagination', 96 'get_sortable_columns', 'get_column_info', 'get_table_classes', 'display_tablenav', 'extra_tablenav', 97 'single_row_columns' ); 94 protected $compat_methods = array( 95 'set_pagination_args', 96 'get_views', 97 'get_bulk_actions', 98 'bulk_actions', 99 'row_actions', 100 'months_dropdown', 101 'view_switcher', 102 'comments_bubble', 103 'get_items_per_page', 104 'pagination', 105 'get_sortable_columns', 106 'get_column_info', 107 'get_table_classes', 108 'display_tablenav', 109 'extra_tablenav', 110 'single_row_columns', 111 ); 98 112 99 113 /** … … 123 137 */ 124 138 public function __construct( $args = array() ) { 125 $args = wp_parse_args( $args, array( 126 'plural' => '', 127 'singular' => '', 128 'ajax' => false, 129 'screen' => null, 130 ) ); 139 $args = wp_parse_args( 140 $args, array( 141 'plural' => '', 142 'singular' => '', 143 'ajax' => false, 144 'screen' => null, 145 ) 146 ); 131 147 132 148 $this->screen = convert_to_screen( $args['screen'] ); … … 134 150 add_filter( "manage_{$this->screen->id}_columns", array( $this, 'get_columns' ), 0 ); 135 151 136 if ( ! $args['plural'] )152 if ( ! $args['plural'] ) { 137 153 $args['plural'] = $this->screen->base; 138 139 $args['plural'] = sanitize_key( $args['plural'] ); 154 } 155 156 $args['plural'] = sanitize_key( $args['plural'] ); 140 157 $args['singular'] = sanitize_key( $args['singular'] ); 141 158 … … 150 167 $this->modes = array( 151 168 'list' => __( 'List View' ), 152 'excerpt' => __( 'Excerpt View' ) 169 'excerpt' => __( 'Excerpt View' ), 153 170 ); 154 171 } … … 239 256 /** 240 257 * Prepares the list of items for displaying. 258 * 241 259 * @uses WP_List_Table::set_pagination_args() 242 260 * … … 256 274 */ 257 275 protected function set_pagination_args( $args ) { 258 $args = wp_parse_args( $args, array( 259 'total_items' => 0, 260 'total_pages' => 0, 261 'per_page' => 0, 262 ) ); 263 264 if ( !$args['total_pages'] && $args['per_page'] > 0 ) 276 $args = wp_parse_args( 277 $args, array( 278 'total_items' => 0, 279 'total_pages' => 0, 280 'per_page' => 0, 281 ) 282 ); 283 284 if ( ! $args['total_pages'] && $args['per_page'] > 0 ) { 265 285 $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] ); 286 } 266 287 267 288 // Redirect if page number is invalid and headers are not already sent. … … 288 309 } 289 310 290 if ( isset( $this->_pagination_args[ $key] ) ) {291 return $this->_pagination_args[ $key];311 if ( isset( $this->_pagination_args[ $key ] ) ) { 312 return $this->_pagination_args[ $key ]; 292 313 } 293 314 } … … 301 322 */ 302 323 public function has_items() { 303 return ! empty( $this->items );324 return ! empty( $this->items ); 304 325 } 305 326 … … 322 343 */ 323 344 public function search_box( $text, $input_id ) { 324 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() )345 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { 325 346 return; 347 } 326 348 327 349 $input_id = $input_id . '-search-input'; 328 350 329 if ( ! empty( $_REQUEST['orderby'] ) ) 351 if ( ! empty( $_REQUEST['orderby'] ) ) { 330 352 echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; 331 if ( ! empty( $_REQUEST['order'] ) ) 353 } 354 if ( ! empty( $_REQUEST['order'] ) ) { 332 355 echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; 333 if ( ! empty( $_REQUEST['post_mime_type'] ) ) 356 } 357 if ( ! empty( $_REQUEST['post_mime_type'] ) ) { 334 358 echo '<input type="hidden" name="post_mime_type" value="' . esc_attr( $_REQUEST['post_mime_type'] ) . '" />'; 335 if ( ! empty( $_REQUEST['detached'] ) ) 359 } 360 if ( ! empty( $_REQUEST['detached'] ) ) { 336 361 echo '<input type="hidden" name="detached" value="' . esc_attr( $_REQUEST['detached'] ) . '" />'; 362 } 337 363 ?> 338 364 <p class="search-box"> … … 375 401 $views = apply_filters( "views_{$this->screen->id}", $views ); 376 402 377 if ( empty( $views ) ) 403 if ( empty( $views ) ) { 378 404 return; 405 } 379 406 380 407 $this->screen->render_screen_reader_content( 'heading_views' ); … … 385 412 } 386 413 echo implode( " |</li>\n", $views ) . "</li>\n"; 387 echo "</ul>";414 echo '</ul>'; 388 415 } 389 416 … … 424 451 */ 425 452 $this->_actions = apply_filters( "bulk_actions-{$this->screen->id}", $this->_actions ); 426 $two = '';453 $two = ''; 427 454 } else { 428 455 $two = '2'; 429 456 } 430 457 431 if ( empty( $this->_actions ) ) 458 if ( empty( $this->_actions ) ) { 432 459 return; 460 } 433 461 434 462 echo '<label for="bulk-action-selector-' . esc_attr( $which ) . '" class="screen-reader-text">' . __( 'Select bulk action' ) . '</label>'; … … 456 484 */ 457 485 public function current_action() { 458 if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) 486 if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { 459 487 return false; 460 461 if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) 488 } 489 490 if ( isset( $_REQUEST['action'] ) && -1 != $_REQUEST['action'] ) { 462 491 return $_REQUEST['action']; 463 464 if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) 492 } 493 494 if ( isset( $_REQUEST['action2'] ) && -1 != $_REQUEST['action2'] ) { 465 495 return $_REQUEST['action2']; 496 } 466 497 467 498 return false; … … 479 510 protected function row_actions( $actions, $always_visible = false ) { 480 511 $action_count = count( $actions ); 481 $i = 0;482 483 if ( ! $action_count )512 $i = 0; 513 514 if ( ! $action_count ) { 484 515 return ''; 516 } 485 517 486 518 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; … … 488 520 ++$i; 489 521 ( $i == $action_count ) ? $sep = '' : $sep = ' | '; 490 $out .= "<span class='$action'>$link$sep</span>";522 $out .= "<span class='$action'>$link$sep</span>"; 491 523 } 492 524 $out .= '</div>'; … … 529 561 } 530 562 531 $months = $wpdb->get_results( $wpdb->prepare( " 563 $months = $wpdb->get_results( 564 $wpdb->prepare( 565 " 532 566 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 533 567 FROM $wpdb->posts … … 535 569 $extra_checks 536 570 ORDER BY post_date DESC 537 ", $post_type ) ); 571 ", $post_type 572 ) 573 ); 538 574 539 575 /** … … 549 585 $month_count = count( $months ); 550 586 551 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) )587 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { 552 588 return; 589 } 553 590 554 591 $m = isset( $_GET['m'] ) ? (int) $_GET['m'] : 0; … … 558 595 <option<?php selected( $m, 0 ); ?> value="0"><?php _e( 'All dates' ); ?></option> 559 596 <?php 560 foreach ( $months as $arc_row ) { 561 if ( 0 == $arc_row->year ) 562 continue; 563 564 $month = zeroise( $arc_row->month, 2 ); 565 $year = $arc_row->year; 566 567 printf( "<option %s value='%s'>%s</option>\n", 568 selected( $m, $year . $month, false ), 569 esc_attr( $arc_row->year . $month ), 570 /* translators: 1: month name, 2: 4-digit year */ 571 sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) 572 ); 573 } 597 foreach ( $months as $arc_row ) { 598 if ( 0 == $arc_row->year ) { 599 continue; 600 } 601 602 $month = zeroise( $arc_row->month, 2 ); 603 $year = $arc_row->year; 604 605 printf( 606 "<option %s value='%s'>%s</option>\n", 607 selected( $m, $year . $month, false ), 608 esc_attr( $arc_row->year . $month ), 609 /* translators: 1: month name, 2: 4-digit year */ 610 sprintf( __( '%1$s %2$d' ), $wp_locale->get_month( $month ), $year ) 611 ); 612 } 574 613 ?> 575 614 </select> … … 589 628 <div class="view-switch"> 590 629 <?php 591 foreach ( $this->modes as $mode => $title ) { 592 $classes = array( 'view-' . $mode ); 593 if ( $current_mode === $mode ) 594 $classes[] = 'current'; 595 printf( 596 "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", 597 esc_url( add_query_arg( 'mode', $mode ) ), 598 implode( ' ', $classes ), 599 $title 600 ); 601 } 630 foreach ( $this->modes as $mode => $title ) { 631 $classes = array( 'view-' . $mode ); 632 if ( $current_mode === $mode ) { 633 $classes[] = 'current'; 634 } 635 printf( 636 "<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n", 637 esc_url( add_query_arg( 'mode', $mode ) ), 638 implode( ' ', $classes ), 639 $title 640 ); 641 } 602 642 ?> 603 643 </div> … … 617 657 618 658 $approved_comments_number = number_format_i18n( $approved_comments ); 619 $pending_comments_number = number_format_i18n( $pending_comments );659 $pending_comments_number = number_format_i18n( $pending_comments ); 620 660 621 661 $approved_only_phrase = sprintf( _n( '%s comment', '%s comments', $approved_comments ), $approved_comments_number ); 622 $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number );623 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number );662 $approved_phrase = sprintf( _n( '%s approved comment', '%s approved comments', $approved_comments ), $approved_comments_number ); 663 $pending_phrase = sprintf( _n( '%s pending comment', '%s pending comments', $pending_comments ), $pending_comments_number ); 624 664 625 665 // No comments at all. 626 666 if ( ! $approved_comments && ! $pending_comments ) { 627 printf( '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', 667 printf( 668 '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>', 628 669 __( 'No comments' ) 629 670 ); 630 // Approved comments have different display depending on some conditions.671 // Approved comments have different display depending on some conditions. 631 672 } elseif ( $approved_comments ) { 632 printf( '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 633 esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'approved' ), admin_url( 'edit-comments.php' ) ) ), 673 printf( 674 '<a href="%s" class="post-com-count post-com-count-approved"><span class="comment-count-approved" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 675 esc_url( 676 add_query_arg( 677 array( 678 'p' => $post_id, 679 'comment_status' => 'approved', 680 ), admin_url( 'edit-comments.php' ) 681 ) 682 ), 634 683 $approved_comments_number, 635 684 $pending_comments ? $approved_phrase : $approved_only_phrase 636 685 ); 637 686 } else { 638 printf( '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', 687 printf( 688 '<span class="post-com-count post-com-count-no-comments"><span class="comment-count comment-count-no-comments" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', 639 689 $approved_comments_number, 640 690 $pending_comments ? __( 'No approved comments' ) : __( 'No comments' ) … … 643 693 644 694 if ( $pending_comments ) { 645 printf( '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 646 esc_url( add_query_arg( array( 'p' => $post_id, 'comment_status' => 'moderated' ), admin_url( 'edit-comments.php' ) ) ), 695 printf( 696 '<a href="%s" class="post-com-count post-com-count-pending"><span class="comment-count-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></a>', 697 esc_url( 698 add_query_arg( 699 array( 700 'p' => $post_id, 701 'comment_status' => 'moderated', 702 ), admin_url( 'edit-comments.php' ) 703 ) 704 ), 647 705 $pending_comments_number, 648 706 $pending_phrase 649 707 ); 650 708 } else { 651 printf( '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', 709 printf( 710 '<span class="post-com-count post-com-count-pending post-com-count-no-pending"><span class="comment-count comment-count-no-pending" aria-hidden="true">%s</span><span class="screen-reader-text">%s</span></span>', 652 711 $pending_comments_number, 653 712 $approved_comments ? __( 'No pending comments' ) : __( 'No comments' ) … … 666 725 $pagenum = isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 0; 667 726 668 if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) 727 if ( isset( $this->_pagination_args['total_pages'] ) && $pagenum > $this->_pagination_args['total_pages'] ) { 669 728 $pagenum = $this->_pagination_args['total_pages']; 729 } 670 730 671 731 return max( 1, $pagenum ); … … 683 743 protected function get_items_per_page( $option, $default = 20 ) { 684 744 $per_page = (int) get_user_option( $option ); 685 if ( empty( $per_page ) || $per_page < 1 ) 745 if ( empty( $per_page ) || $per_page < 1 ) { 686 746 $per_page = $default; 747 } 687 748 688 749 /** … … 714 775 } 715 776 716 $total_items = $this->_pagination_args['total_items'];717 $total_pages = $this->_pagination_args['total_pages'];777 $total_items = $this->_pagination_args['total_items']; 778 $total_pages = $this->_pagination_args['total_pages']; 718 779 $infinite_scroll = false; 719 780 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { … … 727 788 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items ), number_format_i18n( $total_items ) ) . '</span>'; 728 789 729 $current = $this->get_pagenum();790 $current = $this->get_pagenum(); 730 791 $removable_query_args = wp_removable_query_args(); 731 792 … … 741 802 $disable_first = $disable_last = $disable_prev = $disable_next = false; 742 803 743 if ( $current == 1 ) {804 if ( $current == 1 ) { 744 805 $disable_first = true; 745 $disable_prev = true;746 }806 $disable_prev = true; 807 } 747 808 if ( $current == 2 ) { 748 809 $disable_first = true; 749 810 } 750 if ( $current == $total_pages ) {811 if ( $current == $total_pages ) { 751 812 $disable_last = true; 752 813 $disable_next = true; 753 }814 } 754 815 if ( $current == $total_pages - 1 ) { 755 816 $disable_last = true; … … 759 820 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">«</span>'; 760 821 } else { 761 $page_links[] = sprintf( "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 822 $page_links[] = sprintf( 823 "<a class='first-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 762 824 esc_url( remove_query_arg( 'paged', $current_url ) ), 763 825 __( 'First page' ), … … 769 831 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">‹</span>'; 770 832 } else { 771 $page_links[] = sprintf( "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 772 esc_url( add_query_arg( 'paged', max( 1, $current-1 ), $current_url ) ), 833 $page_links[] = sprintf( 834 "<a class='prev-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 835 esc_url( add_query_arg( 'paged', max( 1, $current - 1 ), $current_url ) ), 773 836 __( 'Previous page' ), 774 837 '‹' … … 780 843 $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page' ) . '</span><span id="table-paging" class="paging-input"><span class="tablenav-paging-text">'; 781 844 } else { 782 $html_current_page = sprintf( "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", 845 $html_current_page = sprintf( 846 "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' /><span class='tablenav-paging-text'>", 783 847 '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page' ) . '</label>', 784 848 $current, … … 787 851 } 788 852 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); 789 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after;853 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging' ), $html_current_page, $html_total_pages ) . $total_pages_after; 790 854 791 855 if ( $disable_next ) { 792 856 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">›</span>'; 793 857 } else { 794 $page_links[] = sprintf( "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 795 esc_url( add_query_arg( 'paged', min( $total_pages, $current+1 ), $current_url ) ), 858 $page_links[] = sprintf( 859 "<a class='next-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 860 esc_url( add_query_arg( 'paged', min( $total_pages, $current + 1 ), $current_url ) ), 796 861 __( 'Next page' ), 797 862 '›' … … 802 867 $page_links[] = '<span class="tablenav-pages-navspan" aria-hidden="true">»</span>'; 803 868 } else { 804 $page_links[] = sprintf( "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 869 $page_links[] = sprintf( 870 "<a class='last-page' href='%s'><span class='screen-reader-text'>%s</span><span aria-hidden='true'>%s</span></a>", 805 871 esc_url( add_query_arg( 'paged', $total_pages, $current_url ) ), 806 872 __( 'Last page' ), … … 863 929 protected function get_default_primary_column_name() { 864 930 $columns = $this->get_columns(); 865 $column = '';931 $column = ''; 866 932 867 933 if ( empty( $columns ) ) { … … 919 985 * @param string $context Screen ID for specific list table, e.g. 'plugins'. 920 986 */ 921 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );987 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); 922 988 923 989 if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { … … 949 1015 950 1016 $columns = get_column_headers( $this->screen ); 951 $hidden = get_hidden_columns( $this->screen );1017 $hidden = get_hidden_columns( $this->screen ); 952 1018 953 1019 $sortable_columns = $this->get_sortable_columns(); … … 966 1032 $sortable = array(); 967 1033 foreach ( $_sortable as $id => $data ) { 968 if ( empty( $data ) ) 1034 if ( empty( $data ) ) { 969 1035 continue; 1036 } 970 1037 971 1038 $data = (array) $data; 972 if ( ! isset( $data[1] ) )1039 if ( ! isset( $data[1] ) ) { 973 1040 $data[1] = false; 974 975 $sortable[$id] = $data; 976 } 977 978 $primary = $this->get_primary_column_name(); 1041 } 1042 1043 $sortable[ $id ] = $data; 1044 } 1045 1046 $primary = $this->get_primary_column_name(); 979 1047 $this->_column_headers = array( $columns, $hidden, $sortable, $primary ); 980 1048 … … 991 1059 public function get_column_count() { 992 1060 list ( $columns, $hidden ) = $this->get_column_info(); 993 $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );1061 $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); 994 1062 return count( $columns ) - count( $hidden ); 995 1063 } … … 1024 1092 if ( ! empty( $columns['cb'] ) ) { 1025 1093 static $cb_counter = 1; 1026 $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>'1094 $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All' ) . '</label>' 1027 1095 . '<input id="cb-select-all-' . $cb_counter . '" type="checkbox" />'; 1028 1096 $cb_counter++; … … 1036 1104 } 1037 1105 1038 if ( 'cb' === $column_key ) 1106 if ( 'cb' === $column_key ) { 1039 1107 $class[] = 'check-column'; 1040 elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) )1108 } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { 1041 1109 $class[] = 'num'; 1110 } 1042 1111 1043 1112 if ( $column_key === $primary ) { … … 1045 1114 } 1046 1115 1047 if ( isset( $sortable[ $column_key] ) ) {1048 list( $orderby, $desc_first ) = $sortable[ $column_key];1116 if ( isset( $sortable[ $column_key ] ) ) { 1117 list( $orderby, $desc_first ) = $sortable[ $column_key ]; 1049 1118 1050 1119 if ( $current_orderby === $orderby ) { 1051 $order = 'asc' === $current_order ? 'desc' : 'asc';1120 $order = 'asc' === $current_order ? 'desc' : 'asc'; 1052 1121 $class[] = 'sorted'; 1053 1122 $class[] = $current_order; 1054 1123 } else { 1055 $order = $desc_first ? 'desc' : 'asc';1124 $order = $desc_first ? 'desc' : 'asc'; 1056 1125 $class[] = 'sortable'; 1057 1126 $class[] = $desc_first ? 'asc' : 'desc'; … … 1061 1130 } 1062 1131 1063 $tag = ( 'cb' === $column_key ) ? 'td' : 'th';1132 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; 1064 1133 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; 1065 $id = $with_id ? "id='$column_key'" : '';1066 1067 if ( ! empty( $class ) )1134 $id = $with_id ? "id='$column_key'" : ''; 1135 1136 if ( ! empty( $class ) ) { 1068 1137 $class = "class='" . join( ' ', $class ) . "'"; 1138 } 1069 1139 1070 1140 echo "<$tag $scope $id $class>$column_display_name</$tag>"; … … 1091 1161 </thead> 1092 1162 1093 <tbody id="the-list"<?php 1094 if ( $singular ) { 1095 echo " data-wp-lists='list:$singular'"; 1096 } ?>> 1163 <tbody id="the-list" 1164 <?php 1165 if ( $singular ) { 1166 echo " data-wp-lists='list:$singular'"; 1167 } 1168 ?> 1169 > 1097 1170 <?php $this->display_rows_or_placeholder(); ?> 1098 1171 </tbody> … … 1133 1206 <div class="tablenav <?php echo esc_attr( $which ); ?>"> 1134 1207 1135 <?php if ( $this->has_items() ) : ?>1208 <?php if ( $this->has_items() ) : ?> 1136 1209 <div class="alignleft actions bulkactions"> 1137 1210 <?php $this->bulk_actions( $which ); ?> 1138 1211 </div> 1139 <?php endif; 1212 <?php 1213 endif; 1140 1214 $this->extra_tablenav( $which ); 1141 1215 $this->pagination( $which ); … … 1177 1251 */ 1178 1252 public function display_rows() { 1179 foreach ( $this->items as $item ) 1253 foreach ( $this->items as $item ) { 1180 1254 $this->single_row( $item ); 1255 } 1181 1256 } 1182 1257 … … 1195 1270 1196 1271 /** 1197 *1198 1272 * @param object $item 1199 1273 * @param string $column_name … … 1202 1276 1203 1277 /** 1204 *1205 1278 * @param object $item 1206 1279 */ … … 1249 1322 echo call_user_func( array( $this, 'column_' . $column_name ), $item ); 1250 1323 echo $this->handle_row_actions( $item, $column_name, $primary ); 1251 echo "</td>";1324 echo '</td>'; 1252 1325 } else { 1253 1326 echo "<td $attributes>"; 1254 1327 echo $this->column_default( $item, $column_name ); 1255 1328 echo $this->handle_row_actions( $item, $column_name, $primary ); 1256 echo "</td>";1329 echo '</td>'; 1257 1330 } 1258 1331 } … … 1271 1344 protected function handle_row_actions( $item, $column_name, $primary ) { 1272 1345 return $column_name === $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details' ) . '</span></button>' : ''; 1273 }1346 } 1274 1347 1275 1348 /** … … 1299 1372 } 1300 1373 if ( isset( $this->_pagination_args['total_pages'] ) ) { 1301 $response['total_pages'] = $this->_pagination_args['total_pages'];1374 $response['total_pages'] = $this->_pagination_args['total_pages']; 1302 1375 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); 1303 1376 } … … 1308 1381 /** 1309 1382 * Send required variables to JavaScript land 1310 *1311 1383 */ 1312 1384 public function _js_vars() { … … 1316 1388 'id' => $this->screen->id, 1317 1389 'base' => $this->screen->base, 1318 ) 1390 ), 1319 1391 ); 1320 1392
Note: See TracChangeset
for help on using the changeset viewer.