Ticket #32170: 32170.2.patch
File 32170.2.patch, 15.7 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/class-wp-comments-list-table.php
318 318 319 319 protected function get_sortable_columns() { 320 320 return array( 321 'author' => 'comment_author',322 'response' => 'comment_post_ID'321 'author' => array( 'comment_author', false, __( 'Table ordered by Comment Author.' ) ), 322 'response' => array( 'comment_post_ID', false, __( 'Table ordered by Post Replied To.' ) ), 323 323 ); 324 324 } 325 325 … … 328 328 329 329 $this->display_tablenav( 'top' ); 330 330 331 if ( ! isset( $_GET['orderby'] ) ) { 332 // in the initial view, Comments are ordered by comment's date but there's no column for that 333 echo '<p id="table-description">' . __( 'Table ordered by Comment Date. Descending order.' ) . '</p>'; 334 } else { 335 $this->print_table_description(); 336 } 331 337 ?> 332 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" >338 <table class="<?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 333 339 <thead> 334 340 <tr> 335 341 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-links-list-table.php
101 101 102 102 protected function get_sortable_columns() { 103 103 return array( 104 'name' => 'name',105 'url' => 'url',106 'visible' => 'visible',107 'rating' => 'rating'104 'name' => array( 'name', false, __( 'Table ordered by Name.' ), 'asc' ), 105 'url' => array( 'url', false, __( 'Table ordered by URL.' ) ), 106 'visible' => array( 'visible', false, __( 'Table ordered by Visibility.' ) ), 107 'rating' => array( 'rating', false, __( 'Table ordered by Rating.' ) ), 108 108 ); 109 109 } 110 110 -
src/wp-admin/includes/class-wp-list-table.php
779 779 * 'internal-name' => 'orderby' 780 780 * or 781 781 * 'internal-name' => array( 'orderby', true ) 782 * or 783 * 'internal-name' => array( 'orderby', bool, 'orderby-text', 'initially-sorted-column-order' ) 782 784 * 783 * The second format will make the initial sorting order be descending 785 * The second format will make the initial sorting order be descending. 786 * The third format adds a translatable string for the current sorting 787 * and the order for the initial view sorted column, 'asc' or 'desc'. 788 * Setting 'asc' or 'desc' also specifies which is the initially sorted column. 784 789 * 785 790 * @since 3.1.0 791 * @since 4.3.0 Introduced 'orderby-text' and 'initially-sorted-column-order'. 786 792 * @access protected 787 793 * 788 794 * @return array … … 825 831 continue; 826 832 827 833 $data = (array) $data; 828 if ( !isset( $data[1] ) ) 834 835 // descending initial sorting 836 if ( ! isset( $data[1] ) ) 829 837 $data[1] = false; 838 // current sorting translatable string 839 if ( ! isset( $data[2] ) ) 840 $data[2] = ''; 841 // initial view sorted column and asc/desc order 842 if ( ! isset( $data[3] ) ) 843 $data[3] = false; 830 844 831 845 $sortable[$id] = $data; 832 846 } … … 872 886 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 873 887 $current_order = 'desc'; 874 888 else 875 $current_order = 'asc'; 889 $current_order = 'asc'; // the initial view is not always 'asc' we'll take care of this below 876 890 877 891 if ( ! empty( $columns['cb'] ) ) { 878 892 static $cb_counter = 1; … … 884 898 foreach ( $columns as $column_key => $column_display_name ) { 885 899 $class = array( 'manage-column', "column-$column_key" ); 886 900 887 $style = ''; 888 if ( in_array( $column_key, $hidden ) ) 889 $style = 'display:none;'; 901 $style = $aria_sort_attr = ''; 902 if ( in_array( $column_key, $hidden ) ) { 903 $style = ' style="display:none;"'; 904 } 890 905 891 $style = ' style="' . $style . '"';892 893 906 if ( 'cb' == $column_key ) 894 907 $class[] = 'check-column'; 895 908 elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) … … 896 909 $class[] = 'num'; 897 910 898 911 if ( isset( $sortable[$column_key] ) ) { 899 list( $orderby, $desc_first ) = $sortable[$column_key];912 list( $orderby, $desc_first, $orderby_text, $initial_order ) = $sortable[$column_key]; 900 913 914 // we're in the initial view and there's no $_GET['orderby'] then check if the 915 // initial sorting information is set in the sortable columns and use that 916 if ( '' === $current_orderby && $initial_order ) { 917 // use the initially sorted column $orderby as current orderby 918 $current_orderby = $orderby; 919 // use the initially sorted column asc/desc order as initial order 920 $current_order = $initial_order; 921 } 922 923 // true in the initial view when an initial orderby is set via get_sortable_columns() 924 // and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby 901 925 if ( $current_orderby == $orderby ) { 902 $order = 'asc' == $current_order ? 'desc' : 'asc'; 926 // the sorted column 927 // the `aria-sort` attribute must be set only on the sorted column 928 if ( 'asc' == $current_order ) { 929 $order = 'desc'; 930 $aria_sort_attr = ' aria-sort="ascending"'; 931 } else { 932 $order = 'asc'; 933 $aria_sort_attr = ' aria-sort="descending"'; 934 } 903 935 $class[] = 'sorted'; 904 936 $class[] = $current_order; 905 937 } else { 938 // the other sortable columns 906 939 $order = $desc_first ? 'desc' : 'asc'; 907 940 $class[] = 'sortable'; 908 941 $class[] = $desc_first ? 'asc' : 'desc'; … … 911 944 $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicator"></span></a>'; 912 945 } 913 946 914 $id = $with_id ? " id='$column_key'" : '';947 $id = $with_id ? " id='$column_key'" : ''; 915 948 916 949 if ( !empty( $class ) ) 917 $class = " class='" . join( ' ', $class ) . "'";950 $class = " class='" . join( ' ', $class ) . "'"; 918 951 919 echo "<th scope='col' $id $class $style>$column_display_name</th>";952 echo "<th scope='col'$id$class$style$aria_sort_attr>$column_display_name</th>"; 920 953 } 921 954 } 922 955 923 956 /** 957 * Print table description, with information about current sorting and order. 958 * 959 * For the table initial view, information about initial orderby and order 960 * should be provided via get_sortable_columns(). 961 * 962 * @since 4.3.0 963 * @access public 964 */ 965 public function print_table_description() { 966 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 967 968 if ( empty( $sortable ) ) { 969 return; 970 } 971 972 // when users click on a column header to sort by other columns 973 if ( isset( $_GET['orderby'] ) ) { 974 $current_orderby = $_GET['orderby']; 975 // in the initial view there's no orderby parameter 976 } else { 977 $current_orderby = ''; 978 } 979 980 // not in the initial view and descending order 981 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 982 $current_order = 'desc'; 983 } else { 984 // the initial view is not always 'asc' we'll take care of this below 985 $current_order = 'asc'; 986 } 987 988 // array_keys is slower? does it matter here? 989 foreach ( array_keys( $columns ) as $column_key ) { 990 991 if ( isset( $sortable[$column_key] ) ) { 992 993 list( $orderby, $desc_first, $orderby_text, $initial_order ) = $sortable[$column_key]; 994 995 if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { 996 return; 997 } 998 // we're in the initial view and there's no $_GET['orderby'] then check if the 999 // initial sorting information is set in the sortable columns and use that 1000 if ( '' === $current_orderby && $initial_order ) { 1001 // use the initially sorted column $orderby as current orderby 1002 $current_orderby = $orderby; 1003 // use the initially sorted column asc/desc order as initial order 1004 $current_order = $initial_order; 1005 } 1006 1007 // true in the initial view when an initial orderby is set via get_sortable_columns() 1008 // and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby 1009 if ( $current_orderby == $orderby ) { 1010 $order_text = 'asc' === $current_order ? __( 'Ascending order.' ) : __( 'Descending order.' ); 1011 echo '<p id="table-description">' . $orderby_text . ' ' . $order_text . '</p>'; 1012 1013 return; 1014 } 1015 } 1016 } 1017 } 1018 1019 /** 924 1020 * Display the table 925 1021 * 926 1022 * @since 3.1.0 … … 931 1027 932 1028 $this->display_tablenav( 'top' ); 933 1029 1030 $this->print_table_description(); 934 1031 ?> 935 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >1032 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 936 1033 <thead> 937 1034 <tr> 938 1035 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-media-list-table.php
262 262 263 263 protected function get_sortable_columns() { 264 264 return array( 265 'title' => 'title',266 'author' => 'author',267 'parent' => 'parent',268 'comments' => 'comment_count',269 'date' => array( 'date', true ),265 'title' => array( 'title', false, __( 'Table ordered by File Name.' ) ), 266 'author' => array( 'author', false, __( 'Table ordered by Author.' ) ), 267 'parent' => array( 'parent', false, __( 'Table ordered by Uploaded To.' ) ), 268 'comments' => array( 'comment_count', false, __( 'Table ordered by Comments.' ) ), 269 'date' => array( 'date', true, __( 'Table ordered by Date.' ), 'desc' ), 270 270 ); 271 271 } 272 272 -
src/wp-admin/includes/class-wp-ms-sites-list-table.php
185 185 } 186 186 187 187 protected function get_sortable_columns() { 188 $blogname_orderby_text = ( is_subdomain_install() ) ? __( 'Table ordered by Site Domain Name.' ) : __( 'Table ordered by Site Path.' ); 188 189 return array( 189 'blogname' => 'blogname',190 'lastupdated' => 'lastupdated',191 'registered' => 'blog_id',190 'blogname' => array( 'blogname', false, $blogname_orderby_text ), 191 'lastupdated' => array( 'lastupdated', true, __( 'Table ordered by Last Updated.' ) ), 192 'registered' => array( 'blog_id', true, __( 'Table ordered by Registered Date.' ), 'desc' ), 192 193 ); 193 194 } 194 195 -
src/wp-admin/includes/class-wp-ms-themes-list-table.php
211 211 212 212 protected function get_sortable_columns() { 213 213 return array( 214 'name' => 'name',214 'name' => array( 'name', false, __( 'Table ordered by Theme Name.' ), 'asc' ), 215 215 ); 216 216 } 217 217 -
src/wp-admin/includes/class-wp-ms-users-list-table.php
139 139 140 140 protected function get_sortable_columns() { 141 141 return array( 142 'username' => 'login',143 'name' => 'name',144 'email' => 'email',145 'registered' => 'id',142 'username' => array( 'login', false, __( 'Table ordered by Username.' ), 'asc' ), 143 'name' => array( 'name', false, __( 'Table ordered by Name.' ) ), 144 'email' => array( 'email', false, __( 'Table ordered by E-mail.' ) ), 145 'registered' => array( 'id', false, __( 'Table ordered by Registered Date.' ) ), 146 146 ); 147 147 } 148 148 -
src/wp-admin/includes/class-wp-posts-list-table.php
417 417 } 418 418 419 419 protected function get_sortable_columns() { 420 return array( 421 'title' => 'title', 422 'parent' => 'parent', 423 'comments' => 'comment_count', 424 'date' => array( 'date', true ) 425 ); 420 421 $post_type = $this->screen->post_type; 422 423 if ( 'page' === $post_type ) { 424 $title_orderby_text = isset( $_GET['orderby'] ) ? __( 'Table ordered by Title.' ) : __( 'Table ordered by Hierarchical Menu Order and Title.' ); 425 $sortables = array( 426 'title' => array( 'title', false, $title_orderby_text, 'asc' ), 427 'parent' => array( 'parent', false ), 428 'comments' => array( 'comment_count', false, __( 'Table ordered by Comments.' ) ), 429 'date' => array( 'date', true, __( 'Table ordered by Date.' ) ), 430 ); 431 } else { 432 $sortables = array( 433 'title' => array( 'title', false, __( 'Table ordered by Title.' ) ), 434 'parent' => array( 'parent', false ), 435 'comments' => array( 'comment_count', false, __( 'Table ordered by Comments.' ) ), 436 'date' => array( 'date', true, __( 'Table ordered by Date.' ), 'desc' ), 437 ); 438 } 439 // Custom Post Types: there's a filter for that, see get_column_info() 440 441 return $sortables; 426 442 } 427 443 428 444 /** -
src/wp-admin/includes/class-wp-terms-list-table.php
150 150 } 151 151 152 152 protected function get_sortable_columns() { 153 154 $taxonomy = $this->screen->taxonomy; 155 156 if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) { 157 $name_orderby_text = __( 'Table ordered hierarchically.' ); 158 } else { 159 $name_orderby_text = __( 'Table ordered by Name.' ); 160 } 161 153 162 return array( 154 'name' => 'name',155 'description' => 'description',156 'slug' => 'slug',157 'posts' => 'count',158 'links' => 'count'163 'name' => array( 'name', false, $name_orderby_text, 'asc' ), 164 'description' => array( 'description', false, __( 'Table ordered by Description.' ) ), 165 'slug' => array( 'slug', false, __( 'Table ordered by Slug.' ) ), 166 'posts' => array( 'count', false, __( 'Table ordered by Posts Count.' ) ), 167 'links' => array( 'count', false, __( 'Table ordered by Links Count.' ) ), 159 168 ); 160 169 } 161 170 -
src/wp-admin/includes/class-wp-users-list-table.php
282 282 */ 283 283 protected function get_sortable_columns() { 284 284 $c = array( 285 'username' => 'login',286 'name' => 'name',287 'email' => 'email',285 'username' => array( 'login', false, __( 'Table ordered by Username.' ), 'asc' ), 286 'name' => array( 'name', false, __( 'Table ordered by Name.' ) ), 287 'email' => array( 'email', false, __( 'Table ordered by E-mail.' ) ), 288 288 ); 289 289 290 290 if ( $this->is_site_users ) … … 420 420 $r .= "<td $attributes>$user_object->first_name $user_object->last_name</td>"; 421 421 break; 422 422 case 'email': 423 $r .= "<td $attributes><a href='mailto:$email' title='" . esc_attr( sprintf( __( 'E-mail: %s' ), $email ) ) . "'>$email</a></td>";423 $r .= "<td $attributes><a href='mailto:$email'>$email</a></td>"; 424 424 break; 425 425 case 'role': 426 426 $r .= "<td $attributes>$role_name</td>";