Ticket #32170: 32170.7.diff
File 32170.7.diff, 21.1 KB (added by , 23 months ago) |
---|
-
src/wp-admin/css/list-tables.css
461 461 width: 160px; 462 462 } 463 463 464 .sorting-indicators { 465 display: grid; 466 } 467 464 468 .sorting-indicator { 465 469 display: block; 466 visibility: hidden;467 470 width: 10px; 468 471 height: 4px; 469 margin-top: 8px;472 margin-top: 4px; 470 473 margin-left: 7px; 471 474 } 472 475 473 476 .sorting-indicator:before { 474 content: "\f142";475 477 font: normal 20px/1 dashicons; 476 478 speak: never; 477 479 display: inline-block; … … 478 480 padding: 0; 479 481 top: -4px; 480 482 left: -8px; 481 color: #3c434a;482 483 line-height: 0.5; 483 484 position: relative; 484 485 vertical-align: top; … … 485 486 -webkit-font-smoothing: antialiased; 486 487 -moz-osx-font-smoothing: grayscale; 487 488 text-decoration: none !important; 488 color: # 3c434a;489 color: #a7aaad; 489 490 } 490 491 491 .column-comments .sorting-indicator:before { 492 top: 0; 493 left: -10px; 494 } 495 496 th.sorted.asc .sorting-indicator:before, 497 th.desc:hover span.sorting-indicator:before, 498 th.desc a:focus span.sorting-indicator:before { 492 .sorting-indicator.asc:before { 499 493 content: "\f142"; 500 494 } 501 495 502 th.sorted.desc .sorting-indicator:before, 503 th.asc:hover span.sorting-indicator:before, 504 th.asc a:focus span.sorting-indicator:before { 496 .sorting-indicator.desc:before { 505 497 content: "\f140"; 506 498 } 507 499 500 th.sorted.desc .sorting-indicator.desc:before { 501 color: #1d2327; 502 } 503 504 th.sorted.asc .sorting-indicator.asc:before { 505 color: #1d2327; 506 } 507 508 th.sorted.asc a:focus .sorting-indicator.asc:before, 509 th.sorted.asc:hover .sorting-indicator.asc:before, 510 th.sorted.desc a:focus .sorting-indicator.desc:before, 511 th.sorted.desc:hover .sorting-indicator.desc:before { 512 color: #a7aaad; 513 } 514 515 th.sorted.asc a:focus .sorting-indicator.desc:before, 516 th.sorted.asc:hover .sorting-indicator.desc:before, 517 th.sorted.desc a:focus .sorting-indicator.asc:before, 518 th.sorted.desc:hover .sorting-indicator.asc:before { 519 color: #1d2327; 520 } 521 508 522 .wp-list-table .toggle-row { 509 523 position: absolute; 510 524 right: 8px; … … 591 605 display: none; 592 606 } 593 607 594 .fixed .column-comments .sorting-indicator {595 margin-top: 3px;596 }597 598 608 #menu-locations-wrap .widefat { 599 609 width: 60%; 600 610 } … … 622 632 cursor: pointer; 623 633 } 624 634 625 th.sorted .sorting-indicator,626 th.desc:hover span.sorting-indicator,627 th.desc a:focus span.sorting-indicator,628 th.asc:hover span.sorting-indicator,629 th.asc a:focus span.sorting-indicator {630 visibility: visible;631 }632 633 635 .tablenav-pages .current-page { 634 636 margin: 0 2px 0 0; 635 637 font-size: 13px; -
src/wp-admin/includes/class-wp-comments-list-table.php
540 540 */ 541 541 protected function get_sortable_columns() { 542 542 return array( 543 'author' => 'comment_author',544 'response' => 'comment_post_ID',543 'author' => array( 'comment_author', false, __( 'Author' ), __( 'Table ordered by Comment Author.' ) ), 544 'response' => array( 'comment_post_ID', false, _x( 'In Response To', 'column name' ), __( 'Table ordered by Post Replied To.' ) ), 545 545 'date' => 'comment_date', 546 546 ); 547 547 } … … 573 573 574 574 if ( $has_items ) { 575 575 $this->display_tablenav( 'top' ); 576 if ( ! isset( $_GET['orderby'] ) ) { 577 // In the initial view, Comments are ordered by comment's date but there's no column for that. 578 echo '<p id="table-description" class="screen-reader-text">' . __( 'Table ordered by Comment Date. Descending order.' ) . '</p>'; 579 } else { 580 $this->print_table_description(); 581 } 576 582 } 577 583 } 578 584 … … 579 585 $this->screen->render_screen_reader_content( 'heading_list' ); 580 586 581 587 ?> 582 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >588 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 583 589 <thead> 584 590 <tr> 585 591 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-links-list-table.php
143 143 */ 144 144 protected function get_sortable_columns() { 145 145 return array( 146 'name' => 'name',147 'url' => 'url',148 'visible' => 'visible',149 'rating' => 'rating',146 'name' => array( 'name', false, _x( 'Name', 'link name' ), __( 'Table ordered by Name.' ), 'asc' ), 147 'url' => array( 'url', false, __( 'URL' ), __( 'Table ordered by URL.' ) ), 148 'visible' => array( 'visible', false, __( 'Visible' ), __( 'Table ordered by Visibility.' ) ), 149 'rating' => array( 'rating', false, __( 'Rating' ), __( 'Table ordered by Rating.' ) ), 150 150 ); 151 151 } 152 152 -
src/wp-admin/includes/class-wp-list-table.php
1111 1111 * 1112 1112 * The format is: 1113 1113 * - `'internal-name' => 'orderby'` 1114 * - `'internal-name' => array( 'orderby', bool, 'abbr', 'orderby-text', 'initially-sorted-column-order' )` - 1114 1115 * - `'internal-name' => array( 'orderby', 'asc' )` - The second element sets the initial sorting order. 1115 1116 * - `'internal-name' => array( 'orderby', true )` - The second element makes the initial order descending. 1116 1117 * 1118 * In the second format, passing true as second parameter will make the initial 1119 * sorting order be descending. Following parameters add a short column name to 1120 * be used as 'abbr' attribute, a translatable string for the current sorting 1121 * and the initial order for the initial sorted column, 'asc' or 'desc' (default: false). 1122 * 1117 1123 * @since 3.1.0 1124 * @since 6.3.0 Added 'abbr', 'orderby-text' and 'initially-sorted-column-order'. 1118 1125 * 1119 1126 * @return array 1120 1127 */ … … 1253 1260 } 1254 1261 1255 1262 $data = (array) $data; 1263 // Descending initial sorting. 1256 1264 if ( ! isset( $data[1] ) ) { 1257 $data[1] = false;1265 $data[1] = false; 1258 1266 } 1267 // Current sorting translatable string. 1268 if ( ! isset( $data[2] ) ) { 1269 $data[2] = ''; 1270 } 1271 // Initial view sorted column and asc/desc order, default: false. 1272 if ( ! isset( $data[3] ) ) { 1273 $data[3] = false; 1274 } 1275 // Initial order for the initial sorted column, default: false. 1276 if ( ! isset( $data[4] ) ) { 1277 $data[4] = false; 1278 } 1259 1279 1260 1280 $sortable[ $id ] = $data; 1261 1281 } … … 1292 1312 $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 1293 1313 $current_url = remove_query_arg( 'paged', $current_url ); 1294 1314 1315 // When users click on a column header to sort by other columns. 1295 1316 if ( isset( $_GET['orderby'] ) ) { 1296 $current_orderby = $_GET['orderby']; 1317 $current_orderby = $_GET['orderby']; 1318 // In the initial view there's no orderby parameter. 1297 1319 } else { 1298 $current_orderby = '';1320 $current_orderby = ''; 1299 1321 } 1300 1322 1301 if ( isset( $_GET['order'] ) && 'desc' === $_GET['order'] ) { 1323 // Not in the initial view and descending order. 1324 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 1302 1325 $current_order = 'desc'; 1303 1326 } else { 1304 $current_order = 'asc'; 1327 // The initial view is not always 'asc' we'll take care of this below. 1328 $current_order = 'asc'; 1305 1329 } 1306 1330 1307 1331 if ( ! empty( $columns['cb'] ) ) { … … 1315 1339 } 1316 1340 1317 1341 foreach ( $columns as $column_key => $column_display_name ) { 1318 $class = array( 'manage-column', "column-$column_key" ); 1342 $class = array( 'manage-column', "column-$column_key" ); 1343 $aria_sort_attr = ''; 1344 $abbr_attr = ''; 1345 $order_text = ''; 1319 1346 1320 1347 if ( in_array( $column_key, $hidden, true ) ) { 1321 1348 $class[] = 'hidden'; … … 1332 1359 } 1333 1360 1334 1361 if ( isset( $sortable[ $column_key ] ) ) { 1335 list( $orderby, $desc_first ) = $sortable[ $column_key ]; 1362 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 1363 1364 /* 1365 * We're in the initial view and there's no $_GET['orderby'] then check if the 1366 * initial sorting information is set in the sortable columns and use that. 1367 */ 1368 if ( '' === $current_orderby && $initial_order ) { 1369 // Use the initially sorted column $orderby as current orderby. 1370 $current_orderby = $orderby; 1371 // Use the initially sorted column asc/desc order as initial order. 1372 $current_order = $initial_order; 1373 } 1336 1374 1375 /* 1376 * True in the initial view when an initial orderby is set via get_sortable_columns() 1377 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1378 */ 1337 1379 if ( $current_orderby === $orderby ) { 1338 $order = 'asc' === $current_order ? 'desc' : 'asc'; 1339 1380 // The sorted column. The `aria-sort` attribute must be set only on the sorted column. 1381 if ( 'asc' == $current_order ) { 1382 $order = 'desc'; 1383 $aria_sort_attr = ' aria-sort="ascending"'; 1384 $order_text = __( 'Click to sort descending.' ); 1385 } else { 1386 $order = 'asc'; 1387 $aria_sort_attr = ' aria-sort="descending"'; 1388 $order_text = __( 'Click to sort ascending.' ); 1389 } 1340 1390 $class[] = 'sorted'; 1341 1391 $class[] = $current_order; 1342 1392 } else { 1393 // The other sortable columns. 1343 1394 $order = strtolower( $desc_first ); 1344 1395 1345 1396 if ( ! in_array( $order, array( 'desc', 'asc' ), true ) ) { … … 1346 1397 $order = $desc_first ? 'desc' : 'asc'; 1347 1398 } 1348 1399 1349 $class[] = 'sortable'; 1350 $class[] = 'desc' === $order ? 'asc' : 'desc'; 1400 $class[] = 'sortable'; 1401 $class[] = 'desc' === $order ? 'asc' : 'desc'; 1402 $order_text = 'asc' === $order ? __( 'Sortable column. Click to sort ascending.' ) : __( 'Sortable column. Click to sort descending.' ); 1351 1403 } 1352 1404 1353 $column_display_name = sprintf( 1354 '<a href="%s"><span>%s</span><span class="sorting-indicator"></span></a>', 1355 esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ), 1356 $column_display_name 1357 ); 1358 } 1405 // Print an 'abbr' attribute if a value is provided via get_sortable_columns(). 1406 $abbr_attr = $abbr ? ' abbr="' . esc_attr( $abbr ) . '"' : ''; 1407 $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . $column_display_name . '</span><span class="sorting-indicators"><span class="sorting-indicator asc" aria-hidden="true"></span><span class="sorting-indicator desc" aria-hidden="true"></span> <span class="screen-reader-text">' . $order_text . '</span></a>'; 1408 } 1359 1409 1360 1410 $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; 1361 1411 $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; … … 1365 1415 $class = "class='" . implode( ' ', $class ) . "'"; 1366 1416 } 1367 1417 1368 echo "<$tag $scope $id $class >$column_display_name</$tag>";1418 echo "<$tag $scope $id $class $aria_sort_attr $abbr_attr>$column_display_name</$tag>"; 1369 1419 } 1370 1420 } 1371 1421 1422 /** 1423 * Print a table description with information about current sorting and order. 1424 * 1425 * For the table initial view, information about initial orderby and order 1426 * should be provided via get_sortable_columns(). 1427 * 1428 * @since 4.3.0 1429 * @access public 1430 */ 1431 public function print_table_description() { 1432 list( $columns, $hidden, $sortable ) = $this->get_column_info(); 1433 1434 if ( empty( $sortable ) ) { 1435 return; 1436 } 1437 1438 // When users click on a column header to sort by other columns. 1439 if ( isset( $_GET['orderby'] ) ) { 1440 $current_orderby = $_GET['orderby']; 1441 // In the initial view there's no orderby parameter. 1442 } else { 1443 $current_orderby = ''; 1444 } 1445 1446 // Not in the initial view and descending order. 1447 if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { 1448 $current_order = 'desc'; 1449 } else { 1450 // The initial view is not always 'asc' we'll take care of this below. 1451 $current_order = 'asc'; 1452 } 1453 1454 foreach ( array_keys( $columns ) as $column_key ) { 1455 1456 if ( isset( $sortable[$column_key] ) ) { 1457 1458 list( $orderby, $desc_first, $abbr, $orderby_text, $initial_order ) = $sortable[$column_key]; 1459 1460 if ( ! is_string( $orderby_text ) || '' === $orderby_text ) { 1461 return; 1462 } 1463 /* 1464 * We're in the initial view and there's no $_GET['orderby'] then check if the 1465 * initial sorting information is set in the sortable columns and use that. 1466 */ 1467 if ( '' === $current_orderby && $initial_order ) { 1468 // Use the initially sorted column $orderby as current orderby. 1469 $current_orderby = $orderby; 1470 // Use the initially sorted column asc/desc order as initial order. 1471 $current_order = $initial_order; 1472 } 1473 1474 /* 1475 * True in the initial view when an initial orderby is set via get_sortable_columns() 1476 * and true in the sorted views when the actual $_GET['orderby'] is equal to $orderby. 1477 */ 1478 if ( $current_orderby == $orderby ) { 1479 $order_text = 'asc' === $current_order ? __( 'Ascending order.' ) : __( 'Descending order.' ); 1480 echo '<p id="table-description" class="screen-reader-text">' . $orderby_text . ' ' . $order_text . '</p>'; 1481 1482 return; 1483 } 1484 } 1485 } 1486 } 1487 1372 1488 /** 1373 1489 * Displays the table. 1374 1490 * … … 1379 1495 1380 1496 $this->display_tablenav( 'top' ); 1381 1497 1498 $this->print_table_description(); 1499 1382 1500 $this->screen->render_screen_reader_content( 'heading_list' ); 1383 1501 ?> 1384 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" >1502 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>" aria-describedby="table-description"> 1385 1503 <thead> 1386 1504 <tr> 1387 1505 <?php $this->print_column_headers(); ?> -
src/wp-admin/includes/class-wp-media-list-table.php
389 389 */ 390 390 protected function get_sortable_columns() { 391 391 return array( 392 'title' => 'title',393 'author' => 'author',394 'parent' => 'parent',395 'comments' => 'comment_count',396 'date' => array( 'date', true ),392 'title' => array( 'title', false, _x( 'File', 'column name' ), __( 'Table ordered by File Name.' ) ), 393 'author' => array( 'author', false, __( 'Author' ), __( 'Table ordered by Author.' ) ), 394 'parent' => array( 'parent', false, _x( 'Uploaded to', 'column name' ), __( 'Table ordered by Uploaded To.' ) ), 395 'comments' => array( 'comment_count', __( 'Comments' ), false, __( 'Table ordered by Comments.' ) ), 396 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), 397 397 ); 398 398 } 399 399 -
src/wp-admin/includes/class-wp-ms-sites-list-table.php
389 389 * @return array 390 390 */ 391 391 protected function get_sortable_columns() { 392 393 if ( is_subdomain_install() ) { 394 $abbr = __( 'Domain' ); 395 $blogname_orderby_text = __( 'Table ordered by Site Domain Name.' ); 396 } else { 397 $abbr = __( 'Path' ); 398 $blogname_orderby_text = __( 'Table ordered by Site Path.' ); 399 } 400 392 401 return array( 393 'blogname' => 'blogname',394 'lastupdated' => 'lastupdated',395 'registered' => 'blog_id',402 'blogname' => array( 'blogname', false, $abbr, $blogname_orderby_text ), 403 'lastupdated' => array( 'lastupdated', true, __( 'Last Updated' ), __( 'Table ordered by Last Updated.' ) ), 404 'registered' => array( 'blog_id', true, _x( 'Registered', 'site' ), __( 'Table ordered by Site Registered Date.' ), 'desc' ), 396 405 ); 397 406 } 398 407 -
src/wp-admin/includes/class-wp-ms-themes-list-table.php
343 343 */ 344 344 protected function get_sortable_columns() { 345 345 return array( 346 'name' => 'name',346 'name' => array( 'name', false, __( 'Theme' ), __( 'Table ordered by Theme Name.' ), 'asc' ), 347 347 ); 348 348 } 349 349 -
src/wp-admin/includes/class-wp-ms-users-list-table.php
212 212 */ 213 213 protected function get_sortable_columns() { 214 214 return array( 215 'username' => 'login',216 'name' => 'name',217 'email' => 'email',218 'registered' => 'id',215 'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 216 'name' => array( 'name', false, __( 'Name' ), __( 'Table ordered by Name.' ) ), 217 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 218 'registered' => array( 'id', false, _x( 'Registered', 'user' ), __( 'Table ordered by User Registered Date.' ) ), 219 219 ); 220 220 } 221 221 -
src/wp-admin/includes/class-wp-posts-list-table.php
760 760 * @return array 761 761 */ 762 762 protected function get_sortable_columns() { 763 return array( 764 'title' => 'title', 765 'parent' => 'parent', 766 'comments' => 'comment_count', 767 'date' => array( 'date', true ), 768 ); 763 764 $post_type = $this->screen->post_type; 765 766 if ( 'page' === $post_type ) { 767 $title_orderby_text = isset( $_GET['orderby'] ) ? __( 'Table ordered by Title.' ) : __( 'Table ordered by Hierarchical Menu Order and Title.' ); 768 $sortables = array( 769 'title' => array( 'title', false, __( 'Title' ), $title_orderby_text, 'asc' ), 770 'parent' => array( 'parent', false ), 771 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 772 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ) ), 773 ); 774 } else { 775 $sortables = array( 776 'title' => array( 'title', false, __( 'Title' ), __( 'Table ordered by Title.' ) ), 777 'parent' => array( 'parent', false ), 778 'comments' => array( 'comment_count', false, __( 'Comments' ), __( 'Table ordered by Comments.' ) ), 779 'date' => array( 'date', true, __( 'Date' ), __( 'Table ordered by Date.' ), 'desc' ), 780 ); 781 } 782 // Custom Post Types: there's a filter for that, see get_column_info(). 783 784 return $sortables; 769 785 } 770 786 771 787 /** -
src/wp-admin/includes/class-wp-terms-list-table.php
208 208 * @return array 209 209 */ 210 210 protected function get_sortable_columns() { 211 $taxonomy = $this->screen->taxonomy; 212 213 if ( ! isset( $_GET['orderby'] ) && is_taxonomy_hierarchical( $taxonomy ) ) { 214 $name_orderby_text = __( 'Table ordered hierarchically.' ); 215 } else { 216 $name_orderby_text = __( 'Table ordered by Name.' ); 217 } 218 211 219 return array( 212 'name' => 'name',213 'description' => 'description',214 'slug' => 'slug',215 'posts' => 'count',216 'links' => 'count',220 'name' => array( 'name', false, _x( 'Name', 'term name' ), $name_orderby_text, 'asc' ), 221 'description' => array( 'description', false, __( 'Description' ), __( 'Table ordered by Description.' ) ), 222 'slug' => array( 'slug', false, __( 'Slug' ), __( 'Table ordered by Slug.' ) ), 223 'posts' => array( 'count', false, _x( 'Count', 'Number/count of items' ), __( 'Table ordered by Posts Count.' ) ), 224 'links' => array( 'count', false, __( 'Links' ), __( 'Table ordered by Links.' ) ), 217 225 ); 218 226 } 219 227 -
src/wp-admin/includes/class-wp-users-list-table.php
393 393 */ 394 394 protected function get_sortable_columns() { 395 395 $columns = array( 396 'username' => 'login',397 'email' => 'email',396 'username' => array( 'login', false, __( 'Username' ), __( 'Table ordered by Username.' ), 'asc' ), 397 'email' => array( 'email', false, __( 'E-mail' ), __( 'Table ordered by E-mail.' ) ), 398 398 ); 399 399 400 400 return $columns;