Ticket #32170: 32170.4.patch
File 32170.4.patch, 17.5 KB (added by , 9 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="<?php echo implode( ' ', $this->get_table_classes() ); ?>" >404 <table class="<?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
786 786 * Get a list of sortable columns. The format is: 787 787 * 'internal-name' => 'orderby' 788 788 * or 789 * 'internal-name' => array( 'orderby', true)789 * 'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' ) 790 790 * 791 * The second format will make the initial sorting order be descending 791 * In the second format, passing true as second parameter will make the initial 792 * sorting order be descending. Following parameters add a short column name to 793 * be used as 'abbr' attribute, a translatable string for the current sorting 794 * and the initial order for the initial sorted column, 'asc' or 'desc'. 792 795 * 793 796 * @since 3.1.0 797 + * @since 4.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'. 794 798 * @access protected 795 799 * 796 800 * @return array … … 884 888 continue; 885 889 886 890 $data = (array) $data; 887 if ( !isset( $data[1] ) ) 888 $data[1] = false; 891 // Descending initial sorting. 892 if ( ! isset( $data[1] ) ) { 893 $data[1] = false; 894 } 895 // Current sorting translatable string. 896 if ( ! isset( $data[2] ) ) { 897 $data[2] = ''; 898 } 899 // Initial view sorted column and asc/desc order. 900 if ( ! isset( $data[3] ) ) { 901 $data[3] = false; 902 } 903 // Initial order for the initial sorted column, default 'asc'. 904 if ( ! isset( $data[4] ) ) { 905 $data[4] = 'asc'; 906 } 889 907 890 908 $sortable[$id] = $data; 891 909 } … … 926 944 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 927 945 $current_url = remove_query_arg( 'paged', $current_url ); 928 946 929 if ( isset( $_GET['orderby'] ) ) 930 $current_orderby = $_GET['orderby']; 931 else 932 $current_orderby = ''; 947 // When users click on a column header to sort by other columns. 948 if ( isset( $_GET['orderby'] ) ) { 949 $current_orderby = $_GET['orderby']; 950 // In the initial view there's no orderby parameter. 951 } else { 952 $current_orderby = ''; 953 } 933 954 934 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) 955 // Not in the initial view and descending order. 956 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 935 957 $current_order = 'desc'; 936 else 958 } else { 959 // The initial view is not always 'asc' we'll take care of this below. 937 960 $current_order = 'asc'; 961 } 938 962 939 963 if ( ! empty( $columns['cb'] ) ) { 940 964 static $cb_counter = 1; … … 946 970 foreach ( $columns as $column_key => $column_display_name ) { 947 971 $class = array( 'manage-column', "column-$column_key" ); 948 972 973 $aria_sort_attr = $abbr_attr = $order_text = ''; 974 949 975 if ( in_array( $column_key, $hidden ) ) { 950 976 $class[] = 'hidden'; 951 977 } … … 956 982 $class[] = 'num'; 957 983 958 984 if ( isset( $sortable[$column_key] ) ) { 959 list( $orderby, $desc_first ) = $sortable[$column_key];985 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 960 986 987 /* 988 * We're in the initial view and there's no $_GET['orderby'] then check if the 989 * initial sorting information is set in the sortable columns and use that. 990 */ 991 if ( '' === $current_orderby && $initial_order ) { 992 // Use the initially sorted column $orderby as current orderby. 993 $current_orderby = $orderby; 994 // Use the initially sorted column asc/desc order as initial order. 995 $current_order = $initial_order; 996 } 997 998 /* 999 * True in the initial view when an initial orderby is set via get_sortable_columns() 1000 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1001 */ 961 1002 if ( $current_orderby == $orderby ) { 962 $order = 'asc' == $current_order ? 'desc' : 'asc'; 1003 // The sorted column. The `aria-sort` attribute must be set only on the sorted column. 1004 if ( 'asc' == $current_order ) { 1005 $order = 'desc'; 1006 $aria_sort_attr = ' aria-sort="ascending"'; 1007 $order_text = __( 'Click to sort descending.' ); 1008 } else { 1009 $order = 'asc'; 1010 $aria_sort_attr = ' aria-sort="descending"'; 1011 $order_text = __( 'Click to sort ascending.' ); 1012 } 963 1013 $class[] = 'sorted'; 964 1014 $class[] = $current_order; 965 1015 } else { 1016 // The other sortable columns. 966 1017 $order = $desc_first ? 'desc' : 'asc'; 967 1018 $class[] = 'sortable'; 968 1019 $class[] = $desc_first ? 'asc' : 'desc'; 1020 $order_text = 'asc' === $order ? __( 'Sortable column. Click to sort ascending.' ) : __( 'Sortable column. Click to sort descending.' ); 969 1021 } 970 1022 971 $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>'; 1023 // Print an 'abbr' attribute if a value is provided via get_sortable_columns(). 1024 $abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : ''; 1025 1026 $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>'; 972 1027 } 973 1028 974 $id = $with_id ? " id='$column_key'" : '';1029 $id = $with_id ? " id='$column_key'" : ''; 975 1030 976 1031 if ( !empty( $class ) ) 977 $class = " class='" . join( ' ', $class ) . "'";1032 $class = " class='" . join( ' ', $class ) . "'"; 978 1033 979 echo "<th scope='col' $id $class>$column_display_name</th>";1034 echo "<th scope='col'$id$class$aria_sort_attr$abbr_attr>$column_display_name</th>"; 980 1035 } 981 1036 } 982 1037 1038 /** 1039 * Print a table description with information about current sorting and order. 1040 * 1041 * For the table initial view, information about initial orderby and order 1042 * should be provided via get_sortable_columns(). 1043 * 1044 * @since 4.3.0 1045 * @access public 1046 */ 1047 public function print_table_description() { 1048 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 1049 1050 if ( empty( $sortable ) ) { 1051 return; 1052 } 1053 1054 // When users click on a column header to sort by other columns. 1055 if ( isset( $_GET['orderby'] ) ) { 1056 $current_orderby = $_GET['orderby']; 1057 // In the initial view there's no orderby parameter. 1058 } else { 1059 $current_orderby = ''; 1060 } 1061 1062 // Not in the initial view and descending order. 1063 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 1064 $current_order = 'desc'; 1065 } else { 1066 // The initial view is not always 'asc' we'll take care of this below. 1067 $current_order = 'asc'; 1068 } 1069 1070 foreach ( array_keys( $columns ) as $column_key ) { 1071 1072 if ( isset( $sortable[$column_key] ) ) { 1073 1074 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 1075 1076 if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { 1077 return; 1078 } 1079 /* 1080 * We're in the initial view and there's no $_GET['orderby'] then check if the 1081 * initial sorting information is set in the sortable columns and use that. 1082 */ 1083 if ( '' === $current_orderby && $initial_order ) { 1084 // Use the initially sorted column $orderby as current orderby. 1085 $current_orderby = $orderby; 1086 // Use the initially sorted column asc/desc order as initial order. 1087 $current_order = $initial_order; 1088 } 1089 1090 /* 1091 * True in the initial view when an initial orderby is set via get_sortable_columns() 1092 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1093 */ 1094 if ( $current_orderby == $orderby ) { 1095 $order_text = 'asc' === $current_order ? __( 'Ascending order.' ) : __( 'Descending order.' ); 1096 echo '<p id="table-description" class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>'; 1097 1098 return; 1099 } 1100 } 1101 } 1102 } 1103 983 1104 /** 984 1105 * Display the table 985 1106 * … … 990 1111 $singular = $this->_args['singular']; 991 1112 992 1113 $this->display_tablenav( 'top' ); 1114 1115 $this->print_table_description(); 993 1116 ?> 994 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >1117 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 995 1118 <thead> 996 1119 <tr> 997 1120 <?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 )