Ticket #32170: 32170.3.patch
File 32170.3.patch, 17.4 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, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ), 322 'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( '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" class="screen-reader-text">' . __( '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, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ), 105 'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ), 106 'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ), 107 'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ), 108 108 ); 109 109 } 110 110 -
src/wp-admin/includes/class-wp-list-table.php
778 778 * Get a list of sortable columns. The format is: 779 779 * 'internal-name' => 'orderby' 780 780 * or 781 * 'internal-name' => array( 'orderby', true)781 * 'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' ) 782 782 * 783 * The second format will make the initial sorting order be descending 783 * In the second format, passing true as second parameter will make the initial 784 * sorting order be descending. Following parameters add a short column name to 785 * be used as 'abbr' attribute, a translatable string for the current sorting 786 * and the initial order for the initial sorted column, 'asc' or 'desc'. 784 787 * 785 788 * @since 3.1.0 789 * @since 4.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'. 786 790 * @access protected 787 791 * 788 792 * @return array … … 825 829 continue; 826 830 827 831 $data = (array) $data; 828 if ( !isset( $data[1] ) ) 832 833 // Descending initial sorting. 834 if ( ! isset( $data[1] ) ) 829 835 $data[1] = false; 836 // Current sorting translatable string. 837 if ( ! isset( $data[2] ) ) 838 $data[2] = ''; 839 // Initial view sorted column and asc/desc order. 840 if ( ! isset( $data[3] ) ) 841 $data[3] = false; 830 842 831 843 $sortable[$id] = $data; 832 844 } … … 864 876 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 865 877 $current_url = remove_query_arg( 'paged', $current_url ); 866 878 867 if ( isset( $_GET['orderby'] ) ) 879 // When users click on a column header to sort by other columns. 880 if ( isset( $_GET['orderby'] ) ) { 868 881 $current_orderby = $_GET['orderby']; 869 else 882 // In the initial view there's no orderby parameter. 883 } else { 870 884 $current_orderby = ''; 885 } 871 886 872 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 887 // Not in the initial view and descending order. 888 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 873 889 $current_order = 'desc'; 874 else 890 } else { 891 // The initial view is not always 'asc' we'll take care of this below. 875 892 $current_order = 'asc'; 893 } 876 894 877 895 if ( ! empty( $columns['cb'] ) ) { 878 896 static $cb_counter = 1; … … 884 902 foreach ( $columns as $column_key => $column_display_name ) { 885 903 $class = array( 'manage-column', "column-$column_key" ); 886 904 887 $style = ''; 888 if ( in_array( $column_key, $hidden ) ) 889 $style = 'display:none;'; 905 $style = $aria_sort_attr = $abbr_attr = $order_text = ''; 890 906 891 $style = ' style="' . $style . '"'; 907 if ( in_array( $column_key, $hidden ) ) { 908 $style = ' style="display:none;"'; 909 } 892 910 893 911 if ( 'cb' == $column_key ) 894 912 $class[] = 'check-column'; … … 896 914 $class[] = 'num'; 897 915 898 916 if ( isset( $sortable[$column_key] ) ) { 899 list( $orderby, $desc_first ) = $sortable[$column_key];917 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 900 918 919 /* 920 * We're in the initial view and there's no $_GET['orderby'] then check if the 921 * initial sorting information is set in the sortable columns and use that. 922 */ 923 if ( '' === $current_orderby && $initial_order ) { 924 // Use the initially sorted column $orderby as current orderby. 925 $current_orderby = $orderby; 926 // Use the initially sorted column asc/desc order as initial order. 927 $current_order = $initial_order; 928 } 929 930 /* 931 * True in the initial view when an initial orderby is set via get_sortable_columns() 932 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 933 */ 901 934 if ( $current_orderby == $orderby ) { 902 $order = 'asc' == $current_order ? 'desc' : 'asc'; 935 // The sorted column. The `aria-sort` attribute must be set only on the sorted column. 936 if ( 'asc' == $current_order ) { 937 $order = 'desc'; 938 $aria_sort_attr = ' aria-sort="ascending"'; 939 $order_text = __( 'Click to sort descending.' ); 940 } else { 941 $order = 'asc'; 942 $aria_sort_attr = ' aria-sort="descending"'; 943 $order_text = __( 'Click to sort ascending.' ); 944 } 903 945 $class[] = 'sorted'; 904 946 $class[] = $current_order; 905 947 } else { 948 // The other sortable columns. 906 949 $order = $desc_first ? 'desc' : 'asc'; 907 950 $class[] = 'sortable'; 908 951 $class[] = $desc_first ? 'asc' : 'desc'; 952 $order_text = 'asc' === $order ? __( 'Sortable column. Click to sort ascending.' ) : __( 'Sortable column. Click to sort descending.' ); 909 953 } 910 954 911 $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>'; 955 // Print an 'abbr' attribute if a value is provided via get_sortable_columns(). 956 $abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : ''; 957 958 $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> <span class="screen-reader-text">' . $order_text . '</span></a>'; 912 959 } 913 960 914 $id = $with_id ? " id='$column_key'" : '';961 $id = $with_id ? " id='$column_key'" : ''; 915 962 916 963 if ( !empty( $class ) ) 917 $class = " class='" . join( ' ', $class ) . "'";964 $class = " class='" . join( ' ', $class ) . "'"; 918 965 919 echo "<th scope='col' $id $class $style>$column_display_name</th>";966 echo "<th scope='col'$id$class$style$aria_sort_attr$abbr_attr>$column_display_name</th>"; 920 967 } 921 968 } 922 969 923 970 /** 971 * Print a table description with information about current sorting and order. 972 * 973 * For the table initial view, information about initial orderby and order 974 * should be provided via get_sortable_columns(). 975 * 976 * @since 4.3.0 977 * @access public 978 */ 979 public function print_table_description() { 980 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 981 982 if ( empty( $sortable ) ) { 983 return; 984 } 985 986 // When users click on a column header to sort by other columns. 987 if ( isset( $_GET['orderby'] ) ) { 988 $current_orderby = $_GET['orderby']; 989 // In the initial view there's no orderby parameter. 990 } else { 991 $current_orderby = ''; 992 } 993 994 // Not in the initial view and descending order. 995 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 996 $current_order = 'desc'; 997 } else { 998 // The initial view is not always 'asc' we'll take care of this below. 999 $current_order = 'asc'; 1000 } 1001 1002 foreach ( array_keys( $columns ) as $column_key ) { 1003 1004 if ( isset( $sortable[$column_key] ) ) { 1005 1006 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 1007 1008 if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { 1009 return; 1010 } 1011 /* 1012 * We're in the initial view and there's no $_GET['orderby'] then check if the 1013 * initial sorting information is set in the sortable columns and use that. 1014 */ 1015 if ( '' === $current_orderby && $initial_order ) { 1016 // Use the initially sorted column $orderby as current orderby. 1017 $current_orderby = $orderby; 1018 // Use the initially sorted column asc/desc order as initial order. 1019 $current_order = $initial_order; 1020 } 1021 1022 /* 1023 * True in the initial view when an initial orderby is set via get_sortable_columns() 1024 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1025 */ 1026 if ( $current_orderby == $orderby ) { 1027 $order_text = 'asc' === $current_order ? __( 'Ascending order.' ) : __( 'Descending order.' ); 1028 echo '<p id="table-description" class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>'; 1029 1030 return; 1031 } 1032 } 1033 } 1034 } 1035 1036 /** 924 1037 * Display the table 925 1038 * 926 1039 * @since 3.1.0 … … 931 1044 932 1045 $this->display_tablenav( 'top' ); 933 1046 1047 $this->print_table_description(); 934 1048 ?> 935 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >1049 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 936 1050 <thead> 937 1051 <tr> 938 1052 <?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, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ), 266 'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ), 267 'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ), 268 'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ), 269 'date' => array( 'date', true, __( 'Date' ), __( '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 if ( is_subdomain_install() ) { 189 $abbr = __( 'Domain' ); 190 $blogname_orderby_text = __( 'Table ordered by Site Domain Name.' ); 191 } else { 192 $abbr = __( 'Path' ); 193 $blogname_orderby_text = __( 'Table ordered by Site Path.' ) 194 } 188 195 return array( 189 'blogname' => 'blogname',190 'lastupdated' => 'lastupdated',191 'registered' => 'blog_id',196 'blogname' => array( 'blogname', false, $abbr, $blogname_orderby_text ), 197 'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ), 198 'registered' => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ), 192 199 ); 193 200 } 194 201 -
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, __( 'Theme' ), __( '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, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 143 'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ), 144 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 145 'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User 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' ), $title_orderby_text, 'asc' ), 427 'parent' => array( 'parent', false ), 428 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 429 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ), 430 ); 431 } else { 432 $sortables = array( 433 'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ), 434 'parent' => array( 'parent', false ), 435 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 436 'date' => array( 'date', true, __( 'Date' ), __( '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, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), 164 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), 165 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), 166 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), 167 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), 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, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 286 'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ), 287 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 288 288 ); 289 289 290 290 if ( $this->is_site_users )