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