| @@ -8,14 +8,14 @@ | ||
| 8 | 8 | * The current list of items |
| 9 | 9 | * |
| 10 | 10 | * @since 2.0.18 |
| 11 | 11 | * @var array |
| 12 | - * @access public | |
| 13 | 12 | */ |
| 14 | 13 | public $items; |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * @since 4.07 |
| 17 | + * @var bool|int | |
| 18 | 18 | */ |
| 19 | 19 | public $total_items = false; |
| 20 | 20 | |
| 21 | 21 | /** |
| @@ -22,9 +22,8 @@ | ||
| 22 | 22 | * Various information about the current table |
| 23 | 23 | * |
| 24 | 24 | * @since 2.0.18 |
| 25 | 25 | * @var array |
| 26 | - * @access protected | |
| 27 | 26 | */ |
| 28 | 27 | protected $_args; |
| 29 | 28 | |
| 30 | 29 | /** |
| @@ -38,10 +37,10 @@ | ||
| 38 | 37 | /** |
| 39 | 38 | * The current screen |
| 40 | 39 | * |
| 41 | 40 | * @since 2.0.18 |
| 42 | - * @var object | |
| 43 | - * @access protected | |
| 41 | + * | |
| 42 | + * @var \WP_Screen | |
| 44 | 43 | */ |
| 45 | 44 | protected $screen; |
| 46 | 45 | |
| 47 | 46 | /** |
| @@ -48,9 +47,8 @@ | ||
| 48 | 47 | * Cached bulk actions |
| 49 | 48 | * |
| 50 | 49 | * @since 2.0.18 |
| 51 | 50 | * @var array |
| 52 | - * @access private | |
| 53 | 51 | */ |
| 54 | 52 | private $_actions; |
| 55 | 53 | |
| 56 | 54 | /** |
| @@ -57,9 +55,8 @@ | ||
| 57 | 55 | * Cached pagination output |
| 58 | 56 | * |
| 59 | 57 | * @since 2.0.18 |
| 60 | 58 | * @var string |
| 61 | - * @access private | |
| 62 | 59 | */ |
| 63 | 60 | private $_pagination; |
| 64 | 61 | |
| 65 | 62 | /** |
| @@ -66,14 +63,12 @@ | ||
| 66 | 63 | * The view switcher modes. |
| 67 | 64 | * |
| 68 | 65 | * @since 2.0.18 |
| 69 | 66 | * @var array |
| 70 | - * @access protected | |
| 71 | 67 | */ |
| 72 | 68 | protected $modes = array(); |
| 73 | 69 | |
| 74 | 70 | /** |
| 75 | - * | |
| 76 | 71 | * @var array |
| 77 | 72 | */ |
| 78 | 73 | protected $params; |
| 79 | 74 | |
| @@ -165,9 +160,8 @@ | ||
| 165 | 160 | * |
| 166 | 161 | * @uses FrmListHelper::set_pagination_args() |
| 167 | 162 | * |
| 168 | 163 | * @since 2.0.18 |
| 169 | - * @access public | |
| 170 | 164 | * @abstract |
| 171 | 165 | */ |
| 172 | 166 | public function prepare_items() { |
| 173 | 167 | die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' ); |
| @@ -189,13 +183,9 @@ | ||
| 189 | 183 | |
| 190 | 184 | /** |
| 191 | 185 | * An internal method that sets all the necessary pagination arguments |
| 192 | 186 | * |
| 193 | - * @param array $args An associative array with information about the pagination | |
| 194 | - * | |
| 195 | - * @access protected | |
| 196 | - * | |
| 197 | - * @param array|string $args | |
| 187 | + * @param array $args An associative array with information about the pagination. | |
| 198 | 188 | */ |
| 199 | 189 | protected function set_pagination_args( $args ) { |
| 200 | 190 | $args = wp_parse_args( |
| 201 | 191 | $args, |
| @@ -222,9 +212,8 @@ | ||
| 222 | 212 | /** |
| 223 | 213 | * Access the pagination args. |
| 224 | 214 | * |
| 225 | 215 | * @since 2.0.18 |
| 226 | - * @access public | |
| 227 | 216 | * |
| 228 | 217 | * @param string $key Pagination argument to retrieve. Common values include 'total_items', |
| 229 | 218 | * 'total_pages', 'per_page', or 'infinite_scroll'. |
| 230 | 219 | * |
| @@ -243,9 +232,8 @@ | ||
| 243 | 232 | /** |
| 244 | 233 | * Whether the table has items to display or not |
| 245 | 234 | * |
| 246 | 235 | * @since 2.0.18 |
| 247 | - * @access public | |
| 248 | 236 | * |
| 249 | 237 | * @return bool |
| 250 | 238 | */ |
| 251 | 239 | public function has_items() { |
| @@ -255,9 +243,8 @@ | ||
| 255 | 243 | /** |
| 256 | 244 | * Message to be displayed when there are no items |
| 257 | 245 | * |
| 258 | 246 | * @since 2.0.18 |
| 259 | - * @access public | |
| 260 | 247 | */ |
| 261 | 248 | public function no_items() { |
| 262 | 249 | esc_html_e( 'No items found.', 'formidable' ); |
| 263 | 250 | } |
| @@ -265,12 +252,11 @@ | ||
| 265 | 252 | /** |
| 266 | 253 | * Display the search box. |
| 267 | 254 | * |
| 268 | 255 | * @since 2.0.18 |
| 269 | - * @access public | |
| 270 | 256 | * |
| 271 | - * @param string $text The search button text | |
| 272 | - * @param string $input_id The search input id | |
| 257 | + * @param string $text The search button text. | |
| 258 | + * @param string $input_id The search input id. | |
| 273 | 259 | */ |
| 274 | 260 | public function search_box( $text, $input_id ) { |
| 275 | 261 | if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
| 276 | 262 | return; |
| @@ -294,9 +280,8 @@ | ||
| 294 | 280 | * Get an associative array ( id => link ) with the list |
| 295 | 281 | * of views available on this table. |
| 296 | 282 | * |
| 297 | 283 | * @since 2.0.18 |
| 298 | - * @access protected | |
| 299 | 284 | * |
| 300 | 285 | * @return array |
| 301 | 286 | */ |
| 302 | 287 | protected function get_views() { |
| @@ -306,9 +291,8 @@ | ||
| 306 | 291 | /** |
| 307 | 292 | * Display the list of views available on this table. |
| 308 | 293 | * |
| 309 | 294 | * @since 2.0.18 |
| 310 | - * @access public | |
| 311 | 295 | */ |
| 312 | 296 | public function views() { |
| 313 | 297 | $views = $this->get_views(); |
| 314 | 298 | /** |
| @@ -339,9 +323,8 @@ | ||
| 339 | 323 | * Get an associative array ( option_name => option_title ) with the list |
| 340 | 324 | * of bulk actions available on this table. |
| 341 | 325 | * |
| 342 | 326 | * @since 2.0.18 |
| 343 | - * @access protected | |
| 344 | 327 | * |
| 345 | 328 | * @return array |
| 346 | 329 | */ |
| 347 | 330 | protected function get_bulk_actions() { |
| @@ -351,9 +334,8 @@ | ||
| 351 | 334 | /** |
| 352 | 335 | * Display the bulk actions dropdown. |
| 353 | 336 | * |
| 354 | 337 | * @since 2.0.18 |
| 355 | - * @access protected | |
| 356 | 338 | * |
| 357 | 339 | * @param string $which The location of the bulk actions: 'top' or 'bottom'. |
| 358 | 340 | * This is designated as optional for backwards-compatibility. |
| 359 | 341 | */ |
| @@ -379,17 +361,17 @@ | ||
| 379 | 361 | |
| 380 | 362 | $two = ''; |
| 381 | 363 | } else { |
| 382 | 364 | $two = '2'; |
| 383 | - } | |
| 365 | + }//end if | |
| 384 | 366 | |
| 385 | 367 | if ( empty( $this->_actions ) ) { |
| 386 | 368 | return; |
| 387 | 369 | } |
| 388 | 370 | |
| 389 | - echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_attr__( 'Select bulk action', 'formidable' ) . '</label>'; | |
| 371 | + echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>'; | |
| 390 | 372 | echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n"; |
| 391 | - echo "<option value='-1' selected='selected'>" . esc_attr__( 'Bulk Actions', 'formidable' ) . "</option>\n"; | |
| 373 | + echo "<option value='-1' selected='selected'>" . esc_html__( 'Bulk Actions', 'formidable' ) . "</option>\n"; | |
| 392 | 374 | |
| 393 | 375 | foreach ( $this->_actions as $name => $title ) { |
| 394 | 376 | $params = array( |
| 395 | 377 | 'value' => $name, |
| @@ -408,9 +390,21 @@ | ||
| 408 | 390 | if ( isset( $this->_actions['bulk_delete'] ) ) { |
| 409 | 391 | $verify = $this->confirm_bulk_delete(); |
| 410 | 392 | |
| 411 | 393 | if ( $verify ) { |
| 412 | - echo "<a id='confirm-bulk-delete-" . esc_attr( $which ) . "' class='frm-hidden' href='confirm-bulk-delete' data-frmverify='" . esc_attr( $verify ) . "' data-frmverify-btn='frm-button-red'></a>"; | |
| 394 | + $confirm_delete_attributes = array( | |
| 395 | + 'id' => 'confirm-bulk-delete-' . $which, | |
| 396 | + 'class' => 'frm-hidden', | |
| 397 | + 'tabindex' => '-1', | |
| 398 | + 'aria-hidden' => 'true', | |
| 399 | + 'href' => 'confirm-bulk-delete', | |
| 400 | + 'data-loaded-from' => $this->loaded_from(), | |
| 401 | + 'data-frmverify' => $verify, | |
| 402 | + 'data-frmverify-btn' => 'frm-button-red', | |
| 403 | + ); | |
| 404 | + | |
| 405 | + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 406 | + echo '<a ' . FrmAppHelper::array_to_html_params( $confirm_delete_attributes ) . '></a>'; | |
| 413 | 407 | } |
| 414 | 408 | } |
| 415 | 409 | |
| 416 | 410 | submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
| @@ -427,14 +421,13 @@ | ||
| 427 | 421 | /** |
| 428 | 422 | * Get the current action selected from the bulk actions dropdown. |
| 429 | 423 | * |
| 430 | 424 | * @since 2.0.18 |
| 431 | - * @access public | |
| 432 | 425 | * |
| 433 | - * @return string|false The action name or False if no action was selected | |
| 426 | + * @return false|string The action name or False if no action was selected | |
| 434 | 427 | */ |
| 435 | 428 | public function current_action() { |
| 436 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { | |
| 429 | + if ( ! empty( $_REQUEST['filter_action'] ) ) { | |
| 437 | 430 | return false; |
| 438 | 431 | } |
| 439 | 432 | |
| 440 | 433 | $action = $this->get_bulk_action( 'action' ); |
| @@ -463,12 +456,11 @@ | ||
| 463 | 456 | /** |
| 464 | 457 | * Generate row actions div |
| 465 | 458 | * |
| 466 | 459 | * @since 2.0.18 |
| 467 | - * @access protected | |
| 468 | 460 | * |
| 469 | - * @param array $actions The list of actions | |
| 470 | - * @param bool $always_visible Whether the actions should be always visible | |
| 461 | + * @param array $actions The list of actions. | |
| 462 | + * @param bool $always_visible Whether the actions should be always visible. | |
| 471 | 463 | * |
| 472 | 464 | * @return string |
| 473 | 465 | */ |
| 474 | 466 | protected function row_actions( $actions, $always_visible = false ) { |
| @@ -481,10 +473,10 @@ | ||
| 481 | 473 | } |
| 482 | 474 | |
| 483 | 475 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 484 | 476 | foreach ( $actions as $action => $link ) { |
| 485 | - ++ $i; | |
| 486 | - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; | |
| 477 | + ++$i; | |
| 478 | + $sep = $i == $action_count ? '' : ' | '; | |
| 487 | 479 | $out .= "<span class='$action'>$link$sep</span>"; |
| 488 | 480 | } |
| 489 | 481 | $out .= '</div>'; |
| 490 | 482 | |
| @@ -496,9 +488,8 @@ | ||
| 496 | 488 | /** |
| 497 | 489 | * Display a view switcher |
| 498 | 490 | * |
| 499 | 491 | * @since 2.0.18 |
| 500 | - * @access protected | |
| 501 | 492 | * |
| 502 | 493 | * @param string $current_mode |
| 503 | 494 | */ |
| 504 | 495 | protected function view_switcher( $current_mode ) { |
| @@ -527,9 +518,8 @@ | ||
| 527 | 518 | /** |
| 528 | 519 | * Get the current page number |
| 529 | 520 | * |
| 530 | 521 | * @since 2.0.18 |
| 531 | - * @access public | |
| 532 | 522 | * |
| 533 | 523 | * @return int |
| 534 | 524 | */ |
| 535 | 525 | public function get_pagenum() { |
| @@ -545,12 +535,11 @@ | ||
| 545 | 535 | /** |
| 546 | 536 | * Get number of items to display on a single page |
| 547 | 537 | * |
| 548 | 538 | * @since 2.0.18 |
| 549 | - * @access protected | |
| 550 | 539 | * |
| 551 | 540 | * @param string $option |
| 552 | - * @param int $default | |
| 541 | + * @param int $default | |
| 553 | 542 | * |
| 554 | 543 | * @return int |
| 555 | 544 | */ |
| 556 | 545 | protected function get_items_per_page( $option, $default = 20 ) { |
| @@ -578,9 +567,8 @@ | ||
| 578 | 567 | /** |
| 579 | 568 | * Display the pagination. |
| 580 | 569 | * |
| 581 | 570 | * @since 2.0.18 |
| 582 | - * @access protected | |
| 583 | 571 | * |
| 584 | 572 | * @param string $which |
| 585 | 573 | */ |
| 586 | 574 | protected function pagination( $which ) { |
| @@ -662,9 +650,9 @@ | ||
| 662 | 650 | $pagination_links_class = 'pagination-links'; |
| 663 | 651 | if ( ! empty( $infinite_scroll ) ) { |
| 664 | 652 | $pagination_links_class = ' hide-if-js'; |
| 665 | 653 | } |
| 666 | - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>'; | |
| 654 | + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>'; | |
| 667 | 655 | |
| 668 | 656 | if ( $total_pages ) { |
| 669 | 657 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 670 | 658 | } else { |
| @@ -753,9 +741,8 @@ | ||
| 753 | 741 | * |
| 754 | 742 | * The second format will make the initial sorting order be descending |
| 755 | 743 | * |
| 756 | 744 | * @since 2.0.18 |
| 757 | - * @access protected | |
| 758 | 745 | * |
| 759 | 746 | * @return array |
| 760 | 747 | */ |
| 761 | 748 | protected function get_sortable_columns() { |
| @@ -765,9 +752,8 @@ | ||
| 765 | 752 | /** |
| 766 | 753 | * Gets the name of the default primary column. |
| 767 | 754 | * |
| 768 | 755 | * @since 4.3.0 |
| 769 | - * @access protected | |
| 770 | 756 | * |
| 771 | 757 | * @return string Name of the default primary column, in this case, an empty string. |
| 772 | 758 | */ |
| 773 | 759 | protected function get_default_primary_column_name() { |
| @@ -791,9 +777,8 @@ | ||
| 791 | 777 | /** |
| 792 | 778 | * Gets the name of the primary column. |
| 793 | 779 | * |
| 794 | 780 | * @since 4.3.0 |
| 795 | - * @access protected | |
| 796 | 781 | * |
| 797 | 782 | * @return string The name of the primary column. |
| 798 | 783 | */ |
| 799 | 784 | protected function get_primary_column_name() { |
| @@ -826,15 +811,14 @@ | ||
| 826 | 811 | /** |
| 827 | 812 | * Get a list of all, hidden and sortable columns, with filter applied |
| 828 | 813 | * |
| 829 | 814 | * @since 2.0.18 |
| 830 | - * @access protected | |
| 831 | 815 | * |
| 832 | 816 | * @return array |
| 833 | 817 | */ |
| 834 | 818 | protected function get_column_info() { |
| 835 | 819 | // $_column_headers is already set / cached |
| 836 | - if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { | |
| 820 | + if ( is_array( $this->_column_headers ) ) { | |
| 837 | 821 | // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. |
| 838 | 822 | // In 4.3, we added a fourth argument for primary column. |
| 839 | 823 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 840 | 824 | foreach ( $this->_column_headers as $key => $value ) { |
| @@ -884,15 +868,14 @@ | ||
| 884 | 868 | /** |
| 885 | 869 | * Return number of visible columns |
| 886 | 870 | * |
| 887 | 871 | * @since 2.0.18 |
| 888 | - * @access public | |
| 889 | 872 | * |
| 890 | 873 | * @return int |
| 891 | 874 | */ |
| 892 | 875 | public function get_column_count() { |
| 893 | 876 | list ( $columns, $hidden ) = $this->get_column_info(); |
| 894 | - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); | |
| 877 | + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); | |
| 895 | 878 | |
| 896 | 879 | return count( $columns ) - count( $hidden ); |
| 897 | 880 | } |
| 898 | 881 | |
| @@ -899,13 +882,13 @@ | ||
| 899 | 882 | /** |
| 900 | 883 | * Print column headers, accounting for hidden and sortable columns. |
| 901 | 884 | * |
| 902 | 885 | * @since 2.0.18 |
| 903 | - * @access public | |
| 904 | 886 | * |
| 905 | 887 | * @staticvar int $cb_counter |
| 906 | 888 | * |
| 907 | - * @param bool $with_id Whether to set the id attribute or not | |
| 889 | + * @param bool $with_id Whether to set the id attribute or not. | |
| 890 | + * @return void | |
| 908 | 891 | */ |
| 909 | 892 | public function print_column_headers( $with_id = true ) { |
| 910 | 893 | list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
| 911 | 894 | |
| @@ -923,25 +906,29 @@ | ||
| 923 | 906 | } else { |
| 924 | 907 | $current_order = 'asc'; |
| 925 | 908 | } |
| 926 | 909 | |
| 910 | + FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order ); | |
| 911 | + | |
| 927 | 912 | if ( ! empty( $columns['cb'] ) ) { |
| 928 | 913 | static $cb_counter = 1; |
| 929 | - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>'; | |
| 930 | - $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; | |
| 931 | - $cb_counter ++; | |
| 914 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>'; | |
| 915 | + $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; | |
| 916 | + ++$cb_counter; | |
| 932 | 917 | } |
| 933 | 918 | |
| 934 | 919 | foreach ( $columns as $column_key => $column_display_name ) { |
| 935 | - $class = array( 'manage-column', "column-$column_key" ); | |
| 920 | + $class = array( 'manage-column', "column-$column_key" ); | |
| 921 | + $aria_sort_attr = ''; | |
| 922 | + $order_text = ''; | |
| 936 | 923 | |
| 937 | 924 | if ( in_array( $column_key, $hidden ) ) { |
| 938 | 925 | $class[] = 'hidden'; |
| 939 | 926 | } |
| 940 | 927 | |
| 941 | - if ( 'cb' == $column_key ) { | |
| 928 | + if ( 'cb' === $column_key ) { | |
| 942 | 929 | $class[] = 'check-column'; |
| 943 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { | |
| 930 | + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { | |
| 944 | 931 | $class[] = 'num'; |
| 945 | 932 | } |
| 946 | 933 | |
| 947 | 934 | if ( $column_key === $primary || $column_key === 'name' ) { |
| @@ -951,9 +938,17 @@ | ||
| 951 | 938 | if ( isset( $sortable[ $column_key ] ) ) { |
| 952 | 939 | list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
| 953 | 940 | |
| 954 | 941 | if ( $current_orderby == $orderby ) { |
| 955 | - $order = 'asc' == $current_order ? 'desc' : 'asc'; | |
| 942 | + // The sorted column. The `aria-sort` attribute must be set only on the sorted column. | |
| 943 | + if ( 'asc' === $current_order ) { | |
| 944 | + $order = 'desc'; | |
| 945 | + $aria_sort_attr = ' aria-sort="ascending"'; | |
| 946 | + } else { | |
| 947 | + $order = 'asc'; | |
| 948 | + $aria_sort_attr = ' aria-sort="descending"'; | |
| 949 | + } | |
| 950 | + | |
| 956 | 951 | $class[] = 'sorted'; |
| 957 | 952 | $class[] = $current_order; |
| 958 | 953 | } else { |
| 959 | 954 | $order = $desc_first ? 'desc' : 'asc'; |
| @@ -958,19 +953,41 @@ | ||
| 958 | 953 | } else { |
| 959 | 954 | $order = $desc_first ? 'desc' : 'asc'; |
| 960 | 955 | $class[] = 'sortable'; |
| 961 | 956 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 957 | + | |
| 958 | + /* translators: Hidden accessibility text. */ | |
| 959 | + $asc_text = __( 'Sort ascending.', 'formidable' ); | |
| 960 | + /* translators: Hidden accessibility text. */ | |
| 961 | + $desc_text = __( 'Sort descending.', 'formidable' ); | |
| 962 | + $order_text = 'asc' === $order ? $asc_text : $desc_text; | |
| 963 | + }//end if | |
| 964 | + | |
| 965 | + if ( '' !== $order_text ) { | |
| 966 | + $order_text = ' <span class="screen-reader-text">' . $order_text . '</span>'; | |
| 962 | 967 | } |
| 963 | 968 | |
| 964 | - $column_display_name = '<a href="' . esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ) . '"><span>' . esc_html( $column_display_name ) . '</span><span class="sorting-indicator"></span></a>'; | |
| 965 | - } | |
| 969 | + $column_display_name = sprintf( | |
| 970 | + '<a href="%1$s">' . | |
| 971 | + '<span>%2$s</span>' . | |
| 972 | + '<span class="sorting-indicators">' . | |
| 973 | + '<span class="sorting-indicator asc" aria-hidden="true"></span>' . | |
| 974 | + '<span class="sorting-indicator desc" aria-hidden="true"></span>' . | |
| 975 | + '</span>' . | |
| 976 | + '%3$s' . | |
| 977 | + '</a>', | |
| 978 | + esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ), | |
| 979 | + $column_display_name, | |
| 980 | + $order_text | |
| 981 | + ); | |
| 982 | + }//end if | |
| 966 | 983 | |
| 967 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; | |
| 968 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; | |
| 984 | + $tag = 'cb' === $column_key ? 'td' : 'th'; | |
| 985 | + $scope = 'th' === $tag ? 'scope="col"' : ''; | |
| 969 | 986 | $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : ''; |
| 970 | 987 | |
| 971 | 988 | if ( ! empty( $class ) ) { |
| 972 | - $class = "class='" . esc_attr( join( ' ', $class ) ) . "'"; | |
| 989 | + $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'"; | |
| 973 | 990 | } |
| 974 | 991 | |
| 975 | 992 | if ( ! $this->has_min_items() && ! $with_id ) { |
| 976 | 993 | // Hide the labels but show the border. |
| @@ -975,10 +992,10 @@ | ||
| 975 | 992 | if ( ! $this->has_min_items() && ! $with_id ) { |
| 976 | 993 | // Hide the labels but show the border. |
| 977 | 994 | $column_display_name = ''; |
| 978 | 995 | } |
| 979 | - echo "<$tag $scope $id $class>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 980 | - } | |
| 996 | + echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 997 | + }//end foreach | |
| 981 | 998 | } |
| 982 | 999 | |
| 983 | 1000 | /** |
| 984 | 1001 | * Display the table |
| @@ -983,18 +1000,21 @@ | ||
| 983 | 1000 | /** |
| 984 | 1001 | * Display the table |
| 985 | 1002 | * |
| 986 | 1003 | * @since 2.0.18 |
| 987 | - * @access public | |
| 1004 | + * @param array $args | |
| 988 | 1005 | */ |
| 989 | - public function display() { | |
| 1006 | + public function display( $args = array() ) { | |
| 990 | 1007 | $singular = $this->_args['singular']; |
| 991 | 1008 | $tbody_params = array(); |
| 992 | 1009 | if ( $singular ) { |
| 993 | 1010 | $tbody_params['data-wp-lists'] = 'list:' . $singular; |
| 994 | 1011 | } |
| 1012 | + if ( $this->should_display( $args, 'display-top-nav' ) ) { | |
| 1013 | + $this->display_tablenav( 'top' ); | |
| 1014 | + } | |
| 1015 | + $this->screen->render_screen_reader_content( 'heading_list' ); | |
| 995 | 1016 | |
| 996 | - $this->display_tablenav( 'top' ); | |
| 997 | 1017 | ?> |
| 998 | 1018 | <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>"> |
| 999 | 1019 | <?php if ( $this->has_min_items( 1 ) ) { ?> |
| 1000 | 1020 | <thead> |
| @@ -1007,9 +1027,9 @@ | ||
| 1007 | 1027 | <tbody id="the-list"<?php FrmAppHelper::array_to_html_params( $tbody_params, true ); ?>> |
| 1008 | 1028 | <?php $this->display_rows_or_placeholder(); ?> |
| 1009 | 1029 | </tbody> |
| 1010 | 1030 | |
| 1011 | - <?php if ( $this->has_min_items( 1 ) ) { ?> | |
| 1031 | + <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?> | |
| 1012 | 1032 | <tfoot> |
| 1013 | 1033 | <tr> |
| 1014 | 1034 | <?php $this->print_column_headers( false ); ?> |
| 1015 | 1035 | </tr> |
| @@ -1016,16 +1036,29 @@ | ||
| 1016 | 1036 | </tfoot> |
| 1017 | 1037 | <?php } ?> |
| 1018 | 1038 | </table> |
| 1019 | 1039 | <?php |
| 1020 | - $this->display_tablenav( 'bottom' ); | |
| 1040 | + if ( $this->should_display( $args, 'display-bottom-nav' ) ) { | |
| 1041 | + $this->display_tablenav( 'bottom' ); | |
| 1042 | + } | |
| 1021 | 1043 | } |
| 1022 | 1044 | |
| 1023 | 1045 | /** |
| 1046 | + * Determines if a particular feature or element should be displayed. | |
| 1047 | + * | |
| 1048 | + * @param array $args An associative array of arguments. | |
| 1049 | + * @param string $settings The specific setting key to check within the arguments array. | |
| 1050 | + * | |
| 1051 | + * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false. | |
| 1052 | + */ | |
| 1053 | + protected function should_display( $args, $settings ) { | |
| 1054 | + return ! isset( $args[ $settings ] ) || false !== $args[ $settings ]; | |
| 1055 | + } | |
| 1056 | + | |
| 1057 | + /** | |
| 1024 | 1058 | * Get a list of CSS classes for the list table table tag. |
| 1025 | 1059 | * |
| 1026 | 1060 | * @since 2.0.18 |
| 1027 | - * @access protected | |
| 1028 | 1061 | * |
| 1029 | 1062 | * @return array List of CSS classes for the table tag. |
| 1030 | 1063 | */ |
| 1031 | 1064 | protected function get_table_classes() { |
| @@ -1035,9 +1068,8 @@ | ||
| 1035 | 1068 | /** |
| 1036 | 1069 | * Generate the table navigation above or below the table |
| 1037 | 1070 | * |
| 1038 | 1071 | * @since 2.0.18 |
| 1039 | - * @access protected | |
| 1040 | 1072 | * |
| 1041 | 1073 | * @param string $which |
| 1042 | 1074 | */ |
| 1043 | 1075 | protected function display_tablenav( $which ) { |
| @@ -1080,9 +1112,8 @@ | ||
| 1080 | 1112 | /** |
| 1081 | 1113 | * Extra controls to be displayed between bulk actions and pagination |
| 1082 | 1114 | * |
| 1083 | 1115 | * @since 2.0.18 |
| 1084 | - * @access protected | |
| 1085 | 1116 | * |
| 1086 | 1117 | * @param string $which |
| 1087 | 1118 | */ |
| 1088 | 1119 | protected function extra_tablenav( $which ) { |
| @@ -1091,9 +1122,8 @@ | ||
| 1091 | 1122 | /** |
| 1092 | 1123 | * Generate the tbody element for the list table. |
| 1093 | 1124 | * |
| 1094 | 1125 | * @since 2.0.18 |
| 1095 | - * @access public | |
| 1096 | 1126 | */ |
| 1097 | 1127 | public function display_rows_or_placeholder() { |
| 1098 | 1128 | if ( $this->has_items() ) { |
| 1099 | 1129 | $this->display_rows(); |
| @@ -1107,11 +1137,10 @@ | ||
| 1107 | 1137 | /** |
| 1108 | 1138 | * Generates content for a single row of the table |
| 1109 | 1139 | * |
| 1110 | 1140 | * @since 2.0.18 |
| 1111 | - * @access public | |
| 1112 | 1141 | * |
| 1113 | - * @param object $item The current item | |
| 1142 | + * @param object $item The current item. | |
| 1114 | 1143 | */ |
| 1115 | 1144 | public function single_row( $item ) { |
| 1116 | 1145 | echo '<tr>'; |
| 1117 | 1146 | $this->single_row_columns( $item ); |
| @@ -1121,11 +1150,10 @@ | ||
| 1121 | 1150 | /** |
| 1122 | 1151 | * Generates the columns for a single row of the table |
| 1123 | 1152 | * |
| 1124 | 1153 | * @since 2.0.18 |
| 1125 | - * @access protected | |
| 1126 | 1154 | * |
| 1127 | - * @param object $item The current item | |
| 1155 | + * @param object $item The current item. | |
| 1128 | 1156 | */ |
| 1129 | 1157 | protected function single_row_columns( $item ) { |
| 1130 | 1158 | list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
| 1131 | 1159 | |
| @@ -1159,9 +1187,9 @@ | ||
| 1159 | 1187 | |
| 1160 | 1188 | echo $this->handle_row_actions( $item, $column_name, $primary ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1161 | 1189 | echo '</td>'; |
| 1162 | 1190 | } |
| 1163 | - } | |
| 1191 | + }//end foreach | |
| 1164 | 1192 | } |
| 1165 | 1193 | |
| 1166 | 1194 | /** |
| 1167 | 1195 | * Generates and display row actions links for the list table. |
| @@ -1166,9 +1194,8 @@ | ||
| 1166 | 1194 | /** |
| 1167 | 1195 | * Generates and display row actions links for the list table. |
| 1168 | 1196 | * |
| 1169 | 1197 | * @since 4.3.0 |
| 1170 | - * @access protected | |
| 1171 | 1198 | * |
| 1172 | 1199 | * @param object $item The item being acted upon. |
| 1173 | 1200 | * @param string $column_name Current column name. |
| 1174 | 1201 | * @param string $primary Primary column name. |
| @@ -1182,9 +1209,8 @@ | ||
| 1182 | 1209 | /** |
| 1183 | 1210 | * Handle an incoming ajax request (called from admin-ajax.php) |
| 1184 | 1211 | * |
| 1185 | 1212 | * @since 2.0.18 |
| 1186 | - * @access public | |
| 1187 | 1213 | */ |
| 1188 | 1214 | public function ajax_response() { |
| 1189 | 1215 | $this->prepare_items(); |
| 1190 | 1216 | |
| @@ -1216,9 +1242,9 @@ | ||
| 1216 | 1242 | |
| 1217 | 1243 | /** |
| 1218 | 1244 | * Send required variables to JavaScript land |
| 1219 | 1245 | * |
| 1220 | - * @access public | |
| 1246 | + * @return void | |
| 1221 | 1247 | */ |
| 1222 | 1248 | public function _js_vars() { |
| 1223 | 1249 | $args = array( |
| 1224 | 1250 | 'class' => get_class( $this ), |
| @@ -1228,6 +1254,13 @@ | ||
| 1228 | 1254 | ), |
| 1229 | 1255 | ); |
| 1230 | 1256 | |
| 1231 | 1257 | printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
| 1258 | + } | |
| 1259 | + | |
| 1260 | + /** | |
| 1261 | + * @return string | |
| 1262 | + */ | |
| 1263 | + protected function loaded_from() { | |
| 1264 | + return ''; | |
| 1232 | 1265 | } |
| 1233 | 1266 | } |