Ticket #32170: 32170.5.patch
File 32170.5.patch, 17.6 KB (added by , 10 years ago) |
---|
-
src/wp-admin/includes/class-wp-comments-list-table.php
369 369 */ 370 370 protected function get_sortable_columns() { 371 371 return array( 372 'author' => 'comment_author',373 'response' => 'comment_post_ID'372 'author' => array( 'comment_author', false, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ), 373 'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( 'Table ordered by Post Replied To.' ) ), 374 374 ); 375 375 } 376 376 … … 394 394 395 395 $this->display_tablenav( 'top' ); 396 396 397 if ( ! isset( $_GET['orderby'] ) ) { 398 // In the initial view, Comments are ordered by comment's date but there's no column for that. 399 echo '<p id="table-description" class="screen-reader-text">' . __( 'Table ordered by Comment Date. Descending order.' ) . '</p>'; 400 } else { 401 $this->print_table_description(); 402 } 397 403 ?> 398 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >404 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 399 405 <thead> 400 406 <tr> 401 407 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-links-list-table.php
132 132 */ 133 133 protected function get_sortable_columns() { 134 134 return array( 135 'name' => 'name',136 'url' => 'url',137 'visible' => 'visible',138 'rating' => 'rating'135 'name' => array( 'name', false, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ), 136 'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ), 137 'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ), 138 'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ), 139 139 ); 140 140 } 141 141 -
src/wp-admin/includes/class-wp-list-table.php
810 810 * Get a list of sortable columns. The format is: 811 811 * 'internal-name' => 'orderby' 812 812 * or 813 * 'internal-name' => array( 'orderby', true)813 * 'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' ) 814 814 * 815 * The second format will make the initial sorting order be descending 815 * In the second format, passing true as second parameter will make the initial 816 * sorting order be descending. Following parameters add a short column name to 817 * be used as 'abbr' attribute, a translatable string for the current sorting 818 * and the initial order for the initial sorted column, 'asc' or 'desc' (default: false). 816 819 * 817 820 * @since 3.1.0 821 + * @since 4.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'. 818 822 * @access protected 819 823 * 820 824 * @return array … … 908 912 continue; 909 913 910 914 $data = (array) $data; 911 if ( !isset( $data[1] ) ) 912 $data[1] = false; 915 // Descending initial sorting. 916 if ( ! isset( $data[1] ) ) { 917 $data[1] = false; 918 } 919 // Current sorting translatable string. 920 if ( ! isset( $data[2] ) ) { 921 $data[2] = ''; 922 } 923 // Initial view sorted column and asc/desc order, default: false. 924 if ( ! isset( $data[3] ) ) { 925 $data[3] = false; 926 } 927 // Initial order for the initial sorted column, default: false. 928 if ( ! isset( $data[4] ) ) { 929 $data[4] = false; 930 } 913 931 914 932 $sortable[$id] = $data; 915 933 } … … 950 968 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 951 969 $current_url = remove_query_arg( 'paged', $current_url ); 952 970 953 if ( isset( $_GET['orderby'] ) ) 954 $current_orderby = $_GET['orderby']; 955 else 956 $current_orderby = ''; 971 // When users click on a column header to sort by other columns. 972 if ( isset( $_GET['orderby'] ) ) { 973 $current_orderby = $_GET['orderby']; 974 // In the initial view there's no orderby parameter. 975 } else { 976 $current_orderby = ''; 977 } 957 978 958 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 979 // Not in the initial view and descending order. 980 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 959 981 $current_order = 'desc'; 960 else 982 } else { 983 // The initial view is not always 'asc' we'll take care of this below. 961 984 $current_order = 'asc'; 985 } 962 986 963 987 if ( ! empty( $columns['cb'] ) ) { 964 988 static $cb_counter = 1; … … 970 994 foreach ( $columns as $column_key => $column_display_name ) { 971 995 $class = array( 'manage-column', "column-$column_key" ); 972 996 997 $aria_sort_attr = $abbr_attr = $order_text = ''; 998 973 999 if ( in_array( $column_key, $hidden ) ) { 974 1000 $class[] = 'hidden'; 975 1001 } … … 984 1010 } 985 1011 986 1012 if ( isset( $sortable[$column_key] ) ) { 987 list( $orderby, $desc_first ) = $sortable[$column_key];1013 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 988 1014 1015 /* 1016 * We're in the initial view and there's no $_GET['orderby'] then check if the 1017 * initial sorting information is set in the sortable columns and use that. 1018 */ 1019 if ( '' === $current_orderby && $initial_order ) { 1020 // Use the initially sorted column $orderby as current orderby. 1021 $current_orderby = $orderby; 1022 // Use the initially sorted column asc/desc order as initial order. 1023 $current_order = $initial_order; 1024 } 1025 1026 /* 1027 * True in the initial view when an initial orderby is set via get_sortable_columns() 1028 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1029 */ 989 1030 if ( $current_orderby == $orderby ) { 990 $order = 'asc' == $current_order ? 'desc' : 'asc'; 1031 // The sorted column. The `aria-sort` attribute must be set only on the sorted column. 1032 if ( 'asc' == $current_order ) { 1033 $order = 'desc'; 1034 $aria_sort_attr = ' aria-sort="ascending"'; 1035 $order_text = __( 'Click to sort descending.' ); 1036 } else { 1037 $order = 'asc'; 1038 $aria_sort_attr = ' aria-sort="descending"'; 1039 $order_text = __( 'Click to sort ascending.' ); 1040 } 991 1041 $class[] = 'sorted'; 992 1042 $class[] = $current_order; 993 1043 } else { 1044 // The other sortable columns. 994 1045 $order = $desc_first ? 'desc' : 'asc'; 995 1046 $class[] = 'sortable'; 996 1047 $class[] = $desc_first ? 'asc' : 'desc'; 1048 $order_text = 'asc' === $order ? __( 'Sortable column. Click to sort ascending.' ) : __( 'Sortable column. Click to sort descending.' ); 997 1049 } 998 1050 999 $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>';1000 }1051 // Print an 'abbr' attribute if a value is provided via get_sortable_columns(). 1052 $abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : ''; 1001 1053 1054 $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>'; 1055 } 1056 1002 1057 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; 1003 1058 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; 1004 1059 $id = $with_id ? "id='$column_key'" : ''; … … 1006 1061 if ( !empty( $class ) ) 1007 1062 $class = "class='" . join( ' ', $class ) . "'"; 1008 1063 1009 echo "<$tag $scope $id $class >$column_display_name</$tag>";1064 echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>"; 1010 1065 } 1011 1066 } 1012 1067 1068 /** 1069 * Print a table description with information about current sorting and order. 1070 * 1071 * For the table initial view, information about initial orderby and order 1072 * should be provided via get_sortable_columns(). 1073 * 1074 * @since 4.3.0 1075 * @access public 1076 */ 1077 public function print_table_description() { 1078 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 1079 1080 if ( empty( $sortable ) ) { 1081 return; 1082 } 1083 1084 // When users click on a column header to sort by other columns. 1085 if ( isset( $_GET['orderby'] ) ) { 1086 $current_orderby = $_GET['orderby']; 1087 // In the initial view there's no orderby parameter. 1088 } else { 1089 $current_orderby = ''; 1090 } 1091 1092 // Not in the initial view and descending order. 1093 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 1094 $current_order = 'desc'; 1095 } else { 1096 // The initial view is not always 'asc' we'll take care of this below. 1097 $current_order = 'asc'; 1098 } 1099 1100 foreach ( array_keys( $columns ) as $column_key ) { 1101 1102 if ( isset( $sortable[$column_key] ) ) { 1103 1104 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 1105 1106 if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { 1107 return; 1108 } 1109 /* 1110 * We're in the initial view and there's no $_GET['orderby'] then check if the 1111 * initial sorting information is set in the sortable columns and use that. 1112 */ 1113 if ( '' === $current_orderby && $initial_order ) { 1114 // Use the initially sorted column $orderby as current orderby. 1115 $current_orderby = $orderby; 1116 // Use the initially sorted column asc/desc order as initial order. 1117 $current_order = $initial_order; 1118 } 1119 1120 /* 1121 * True in the initial view when an initial orderby is set via get_sortable_columns() 1122 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1123 */ 1124 if ( $current_orderby == $orderby ) { 1125 $order_text = 'asc' === $current_order ? __( 'Ascending order.' ) : __( 'Descending order.' ); 1126 echo '<p id="table-description" class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>'; 1127 1128 return; 1129 } 1130 } 1131 } 1132 } 1133 1013 1134 /** 1014 1135 * Display the table 1015 1136 * … … 1020 1141 $singular = $this->_args['singular']; 1021 1142 1022 1143 $this->display_tablenav( 'top' ); 1144 1145 $this->print_table_description(); 1023 1146 ?> 1024 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >1147 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 1025 1148 <thead> 1026 1149 <tr> 1027 1150 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-media-list-table.php
302 302 */ 303 303 protected function get_sortable_columns() { 304 304 return array( 305 'title' => 'title',306 'author' => 'author',307 'parent' => 'parent',308 'comments' => 'comment_count',309 'date' => array( 'date', true ),305 'title' => array( 'title', false, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ), 306 'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ), 307 'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ), 308 'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ), 309 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), 310 310 ); 311 311 } 312 312 -
src/wp-admin/includes/class-wp-ms-sites-list-table.php
223 223 * @return array 224 224 */ 225 225 protected function get_sortable_columns() { 226 227 if ( is_subdomain_install() ) { 228 $abbr = __( 'Domain' ); 229 $blogname_orderby_text = __( 'Table ordered by Site Domain Name.' ); 230 } else { 231 $abbr = __( 'Path' ); 232 $blogname_orderby_text = __( 'Table ordered by Site Path.' ); 233 } 234 226 235 return array( 227 'blogname' => 'blogname',228 'lastupdated' => 'lastupdated',229 'registered' => 'blog_id',236 'blogname' => array( 'blogname', false, $abbr, $blogname_orderby_text ), 237 'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ), 238 'registered' => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ), 230 239 ); 231 240 } 232 241 -
src/wp-admin/includes/class-wp-ms-themes-list-table.php
240 240 */ 241 241 protected function get_sortable_columns() { 242 242 return array( 243 'name' => 'name',243 'name' => array( 'name', false, __( 'Theme' ), __( 'Table ordered by Theme Name.' ), 'asc' ), 244 244 ); 245 245 } 246 246 -
src/wp-admin/includes/class-wp-ms-users-list-table.php
167 167 */ 168 168 protected function get_sortable_columns() { 169 169 return array( 170 'username' => 'login',171 'name' => 'name',172 'email' => 'email',173 'registered' => 'id',170 'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 171 'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ), 172 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 173 'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ), 174 174 ); 175 175 } 176 176 -
src/wp-admin/includes/class-wp-posts-list-table.php
468 468 * @return array 469 469 */ 470 470 protected function get_sortable_columns() { 471 return array( 472 'title' => 'title', 473 'parent' => 'parent', 474 'comments' => 'comment_count', 475 'date' => array( 'date', true ) 476 ); 471 472 $post_type = $this->screen->post_type; 473 474 if ( 'page' === $post_type ) { 475 $title_orderby_text = isset( $_GET['orderby'] ) ? __( 'Table ordered by Title.' ) : __( 'Table ordered by Hierarchical Menu Order and Title.' ); 476 $sortables = array( 477 'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ), 478 'parent' => array( 'parent', false ), 479 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 480 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ), 481 ); 482 } else { 483 $sortables = array( 484 'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ), 485 'parent' => array( 'parent', false ), 486 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 487 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), 488 ); 489 } 490 // Custom Post Types: there's a filter for that, see get_column_info(). 491 492 return $sortables; 477 493 } 478 494 479 495 /** -
src/wp-admin/includes/class-wp-terms-list-table.php
185 185 * @return array 186 186 */ 187 187 protected function get_sortable_columns() { 188 189 $taxonomy = $this->screen->taxonomy; 190 191 if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) { 192 $name_orderby_text = __( 'Table ordered hierarchically.' ); 193 } else { 194 $name_orderby_text = __( 'Table ordered by Name.' ); 195 } 196 188 197 return array( 189 'name' => 'name',190 'description' => 'description',191 'slug' => 'slug',192 'posts' => 'count',193 'links' => 'count'198 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), 199 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), 200 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), 201 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), 202 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), 194 203 ); 195 204 } 196 205 -
src/wp-admin/includes/class-wp-users-list-table.php
291 291 */ 292 292 protected function get_sortable_columns() { 293 293 $c = array( 294 'username' => 'login',295 'name' => 'name',296 'email' => 'email',294 'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 295 'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ), 296 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 297 297 ); 298 298 299 299 if ( $this->is_site_users )