| @@ -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,9 @@ | ||
| 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 | + 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 | 395 | } |
| 414 | 396 | } |
| 415 | 397 | |
| 416 | 398 | submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) ); |
| @@ -427,14 +409,13 @@ | ||
| 427 | 409 | /** |
| 428 | 410 | * Get the current action selected from the bulk actions dropdown. |
| 429 | 411 | * |
| 430 | 412 | * @since 2.0.18 |
| 431 | - * @access public | |
| 432 | 413 | * |
| 433 | - * @return string|false The action name or False if no action was selected | |
| 414 | + * @return false|string The action name or False if no action was selected | |
| 434 | 415 | */ |
| 435 | 416 | public function current_action() { |
| 436 | - if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) { | |
| 417 | + if ( ! empty( $_REQUEST['filter_action'] ) ) { | |
| 437 | 418 | return false; |
| 438 | 419 | } |
| 439 | 420 | |
| 440 | 421 | $action = $this->get_bulk_action( 'action' ); |
| @@ -463,12 +444,11 @@ | ||
| 463 | 444 | /** |
| 464 | 445 | * Generate row actions div |
| 465 | 446 | * |
| 466 | 447 | * @since 2.0.18 |
| 467 | - * @access protected | |
| 468 | 448 | * |
| 469 | - * @param array $actions The list of actions | |
| 470 | - * @param bool $always_visible Whether the actions should be always visible | |
| 449 | + * @param array $actions The list of actions. | |
| 450 | + * @param bool $always_visible Whether the actions should be always visible. | |
| 471 | 451 | * |
| 472 | 452 | * @return string |
| 473 | 453 | */ |
| 474 | 454 | protected function row_actions( $actions, $always_visible = false ) { |
| @@ -481,10 +461,10 @@ | ||
| 481 | 461 | } |
| 482 | 462 | |
| 483 | 463 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 484 | 464 | foreach ( $actions as $action => $link ) { |
| 485 | - ++ $i; | |
| 486 | - ( $i == $action_count ) ? $sep = '' : $sep = ' | '; | |
| 465 | + ++$i; | |
| 466 | + $sep = $i == $action_count ? '' : ' | '; | |
| 487 | 467 | $out .= "<span class='$action'>$link$sep</span>"; |
| 488 | 468 | } |
| 489 | 469 | $out .= '</div>'; |
| 490 | 470 | |
| @@ -496,9 +476,8 @@ | ||
| 496 | 476 | /** |
| 497 | 477 | * Display a view switcher |
| 498 | 478 | * |
| 499 | 479 | * @since 2.0.18 |
| 500 | - * @access protected | |
| 501 | 480 | * |
| 502 | 481 | * @param string $current_mode |
| 503 | 482 | */ |
| 504 | 483 | protected function view_switcher( $current_mode ) { |
| @@ -527,9 +506,8 @@ | ||
| 527 | 506 | /** |
| 528 | 507 | * Get the current page number |
| 529 | 508 | * |
| 530 | 509 | * @since 2.0.18 |
| 531 | - * @access public | |
| 532 | 510 | * |
| 533 | 511 | * @return int |
| 534 | 512 | */ |
| 535 | 513 | public function get_pagenum() { |
| @@ -545,12 +523,11 @@ | ||
| 545 | 523 | /** |
| 546 | 524 | * Get number of items to display on a single page |
| 547 | 525 | * |
| 548 | 526 | * @since 2.0.18 |
| 549 | - * @access protected | |
| 550 | 527 | * |
| 551 | 528 | * @param string $option |
| 552 | - * @param int $default | |
| 529 | + * @param int $default | |
| 553 | 530 | * |
| 554 | 531 | * @return int |
| 555 | 532 | */ |
| 556 | 533 | protected function get_items_per_page( $option, $default = 20 ) { |
| @@ -578,9 +555,8 @@ | ||
| 578 | 555 | /** |
| 579 | 556 | * Display the pagination. |
| 580 | 557 | * |
| 581 | 558 | * @since 2.0.18 |
| 582 | - * @access protected | |
| 583 | 559 | * |
| 584 | 560 | * @param string $which |
| 585 | 561 | */ |
| 586 | 562 | protected function pagination( $which ) { |
| @@ -662,9 +638,9 @@ | ||
| 662 | 638 | $pagination_links_class = 'pagination-links'; |
| 663 | 639 | if ( ! empty( $infinite_scroll ) ) { |
| 664 | 640 | $pagination_links_class = ' hide-if-js'; |
| 665 | 641 | } |
| 666 | - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>'; | |
| 642 | + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>'; | |
| 667 | 643 | |
| 668 | 644 | if ( $total_pages ) { |
| 669 | 645 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| 670 | 646 | } else { |
| @@ -753,9 +729,8 @@ | ||
| 753 | 729 | * |
| 754 | 730 | * The second format will make the initial sorting order be descending |
| 755 | 731 | * |
| 756 | 732 | * @since 2.0.18 |
| 757 | - * @access protected | |
| 758 | 733 | * |
| 759 | 734 | * @return array |
| 760 | 735 | */ |
| 761 | 736 | protected function get_sortable_columns() { |
| @@ -765,9 +740,8 @@ | ||
| 765 | 740 | /** |
| 766 | 741 | * Gets the name of the default primary column. |
| 767 | 742 | * |
| 768 | 743 | * @since 4.3.0 |
| 769 | - * @access protected | |
| 770 | 744 | * |
| 771 | 745 | * @return string Name of the default primary column, in this case, an empty string. |
| 772 | 746 | */ |
| 773 | 747 | protected function get_default_primary_column_name() { |
| @@ -791,9 +765,8 @@ | ||
| 791 | 765 | /** |
| 792 | 766 | * Gets the name of the primary column. |
| 793 | 767 | * |
| 794 | 768 | * @since 4.3.0 |
| 795 | - * @access protected | |
| 796 | 769 | * |
| 797 | 770 | * @return string The name of the primary column. |
| 798 | 771 | */ |
| 799 | 772 | protected function get_primary_column_name() { |
| @@ -826,15 +799,14 @@ | ||
| 826 | 799 | /** |
| 827 | 800 | * Get a list of all, hidden and sortable columns, with filter applied |
| 828 | 801 | * |
| 829 | 802 | * @since 2.0.18 |
| 830 | - * @access protected | |
| 831 | 803 | * |
| 832 | 804 | * @return array |
| 833 | 805 | */ |
| 834 | 806 | protected function get_column_info() { |
| 835 | 807 | // $_column_headers is already set / cached |
| 836 | - if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) { | |
| 808 | + if ( is_array( $this->_column_headers ) ) { | |
| 837 | 809 | // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. |
| 838 | 810 | // In 4.3, we added a fourth argument for primary column. |
| 839 | 811 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 840 | 812 | foreach ( $this->_column_headers as $key => $value ) { |
| @@ -884,15 +856,14 @@ | ||
| 884 | 856 | /** |
| 885 | 857 | * Return number of visible columns |
| 886 | 858 | * |
| 887 | 859 | * @since 2.0.18 |
| 888 | - * @access public | |
| 889 | 860 | * |
| 890 | 861 | * @return int |
| 891 | 862 | */ |
| 892 | 863 | public function get_column_count() { |
| 893 | 864 | list ( $columns, $hidden ) = $this->get_column_info(); |
| 894 | - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); | |
| 865 | + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) ); | |
| 895 | 866 | |
| 896 | 867 | return count( $columns ) - count( $hidden ); |
| 897 | 868 | } |
| 898 | 869 | |
| @@ -899,13 +870,13 @@ | ||
| 899 | 870 | /** |
| 900 | 871 | * Print column headers, accounting for hidden and sortable columns. |
| 901 | 872 | * |
| 902 | 873 | * @since 2.0.18 |
| 903 | - * @access public | |
| 904 | 874 | * |
| 905 | 875 | * @staticvar int $cb_counter |
| 906 | 876 | * |
| 907 | - * @param bool $with_id Whether to set the id attribute or not | |
| 877 | + * @param bool $with_id Whether to set the id attribute or not. | |
| 878 | + * @return void | |
| 908 | 879 | */ |
| 909 | 880 | public function print_column_headers( $with_id = true ) { |
| 910 | 881 | list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
| 911 | 882 | |
| @@ -925,23 +896,25 @@ | ||
| 925 | 896 | } |
| 926 | 897 | |
| 927 | 898 | if ( ! empty( $columns['cb'] ) ) { |
| 928 | 899 | 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 ++; | |
| 900 | + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>'; | |
| 901 | + $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />'; | |
| 902 | + ++$cb_counter; | |
| 932 | 903 | } |
| 933 | 904 | |
| 934 | 905 | foreach ( $columns as $column_key => $column_display_name ) { |
| 935 | - $class = array( 'manage-column', "column-$column_key" ); | |
| 906 | + $class = array( 'manage-column', "column-$column_key" ); | |
| 907 | + $aria_sort_attr = ''; | |
| 908 | + $order_text = ''; | |
| 936 | 909 | |
| 937 | 910 | if ( in_array( $column_key, $hidden ) ) { |
| 938 | 911 | $class[] = 'hidden'; |
| 939 | 912 | } |
| 940 | 913 | |
| 941 | - if ( 'cb' == $column_key ) { | |
| 914 | + if ( 'cb' === $column_key ) { | |
| 942 | 915 | $class[] = 'check-column'; |
| 943 | - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) { | |
| 916 | + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) { | |
| 944 | 917 | $class[] = 'num'; |
| 945 | 918 | } |
| 946 | 919 | |
| 947 | 920 | if ( $column_key === $primary || $column_key === 'name' ) { |
| @@ -951,9 +924,17 @@ | ||
| 951 | 924 | if ( isset( $sortable[ $column_key ] ) ) { |
| 952 | 925 | list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
| 953 | 926 | |
| 954 | 927 | if ( $current_orderby == $orderby ) { |
| 955 | - $order = 'asc' == $current_order ? 'desc' : 'asc'; | |
| 928 | + // The sorted column. The `aria-sort` attribute must be set only on the sorted column. | |
| 929 | + if ( 'asc' === $current_order ) { | |
| 930 | + $order = 'desc'; | |
| 931 | + $aria_sort_attr = ' aria-sort="ascending"'; | |
| 932 | + } else { | |
| 933 | + $order = 'asc'; | |
| 934 | + $aria_sort_attr = ' aria-sort="descending"'; | |
| 935 | + } | |
| 936 | + | |
| 956 | 937 | $class[] = 'sorted'; |
| 957 | 938 | $class[] = $current_order; |
| 958 | 939 | } else { |
| 959 | 940 | $order = $desc_first ? 'desc' : 'asc'; |
| @@ -958,19 +939,41 @@ | ||
| 958 | 939 | } else { |
| 959 | 940 | $order = $desc_first ? 'desc' : 'asc'; |
| 960 | 941 | $class[] = 'sortable'; |
| 961 | 942 | $class[] = $desc_first ? 'asc' : 'desc'; |
| 943 | + | |
| 944 | + /* translators: Hidden accessibility text. */ | |
| 945 | + $asc_text = __( 'Sort ascending.', 'formidable' ); | |
| 946 | + /* translators: Hidden accessibility text. */ | |
| 947 | + $desc_text = __( 'Sort descending.', 'formidable' ); | |
| 948 | + $order_text = 'asc' === $order ? $asc_text : $desc_text; | |
| 949 | + }//end if | |
| 950 | + | |
| 951 | + if ( '' !== $order_text ) { | |
| 952 | + $order_text = ' <span class="screen-reader-text">' . $order_text . '</span>'; | |
| 962 | 953 | } |
| 963 | 954 | |
| 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 | - } | |
| 955 | + $column_display_name = sprintf( | |
| 956 | + '<a href="%1$s">' . | |
| 957 | + '<span>%2$s</span>' . | |
| 958 | + '<span class="sorting-indicators">' . | |
| 959 | + '<span class="sorting-indicator asc" aria-hidden="true"></span>' . | |
| 960 | + '<span class="sorting-indicator desc" aria-hidden="true"></span>' . | |
| 961 | + '</span>' . | |
| 962 | + '%3$s' . | |
| 963 | + '</a>', | |
| 964 | + esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ), | |
| 965 | + $column_display_name, | |
| 966 | + $order_text | |
| 967 | + ); | |
| 968 | + }//end if | |
| 966 | 969 | |
| 967 | - $tag = ( 'cb' === $column_key ) ? 'td' : 'th'; | |
| 968 | - $scope = ( 'th' === $tag ) ? 'scope="col"' : ''; | |
| 970 | + $tag = 'cb' === $column_key ? 'td' : 'th'; | |
| 971 | + $scope = 'th' === $tag ? 'scope="col"' : ''; | |
| 969 | 972 | $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : ''; |
| 970 | 973 | |
| 971 | 974 | if ( ! empty( $class ) ) { |
| 972 | - $class = "class='" . esc_attr( join( ' ', $class ) ) . "'"; | |
| 975 | + $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'"; | |
| 973 | 976 | } |
| 974 | 977 | |
| 975 | 978 | if ( ! $this->has_min_items() && ! $with_id ) { |
| 976 | 979 | // Hide the labels but show the border. |
| @@ -975,10 +978,10 @@ | ||
| 975 | 978 | if ( ! $this->has_min_items() && ! $with_id ) { |
| 976 | 979 | // Hide the labels but show the border. |
| 977 | 980 | $column_display_name = ''; |
| 978 | 981 | } |
| 979 | - echo "<$tag $scope $id $class>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 980 | - } | |
| 982 | + echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | |
| 983 | + }//end foreach | |
| 981 | 984 | } |
| 982 | 985 | |
| 983 | 986 | /** |
| 984 | 987 | * Display the table |
| @@ -983,18 +986,21 @@ | ||
| 983 | 986 | /** |
| 984 | 987 | * Display the table |
| 985 | 988 | * |
| 986 | 989 | * @since 2.0.18 |
| 987 | - * @access public | |
| 990 | + * @param array $args | |
| 988 | 991 | */ |
| 989 | - public function display() { | |
| 992 | + public function display( $args = array() ) { | |
| 990 | 993 | $singular = $this->_args['singular']; |
| 991 | 994 | $tbody_params = array(); |
| 992 | 995 | if ( $singular ) { |
| 993 | 996 | $tbody_params['data-wp-lists'] = 'list:' . $singular; |
| 994 | 997 | } |
| 998 | + if ( $this->should_display( $args, 'display-top-nav' ) ) { | |
| 999 | + $this->display_tablenav( 'top' ); | |
| 1000 | + } | |
| 1001 | + $this->screen->render_screen_reader_content( 'heading_list' ); | |
| 995 | 1002 | |
| 996 | - $this->display_tablenav( 'top' ); | |
| 997 | 1003 | ?> |
| 998 | 1004 | <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>"> |
| 999 | 1005 | <?php if ( $this->has_min_items( 1 ) ) { ?> |
| 1000 | 1006 | <thead> |
| @@ -1007,9 +1013,9 @@ | ||
| 1007 | 1013 | <tbody id="the-list"<?php FrmAppHelper::array_to_html_params( $tbody_params, true ); ?>> |
| 1008 | 1014 | <?php $this->display_rows_or_placeholder(); ?> |
| 1009 | 1015 | </tbody> |
| 1010 | 1016 | |
| 1011 | - <?php if ( $this->has_min_items( 1 ) ) { ?> | |
| 1017 | + <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?> | |
| 1012 | 1018 | <tfoot> |
| 1013 | 1019 | <tr> |
| 1014 | 1020 | <?php $this->print_column_headers( false ); ?> |
| 1015 | 1021 | </tr> |
| @@ -1016,16 +1022,29 @@ | ||
| 1016 | 1022 | </tfoot> |
| 1017 | 1023 | <?php } ?> |
| 1018 | 1024 | </table> |
| 1019 | 1025 | <?php |
| 1020 | - $this->display_tablenav( 'bottom' ); | |
| 1026 | + if ( $this->should_display( $args, 'display-bottom-nav' ) ) { | |
| 1027 | + $this->display_tablenav( 'bottom' ); | |
| 1028 | + } | |
| 1021 | 1029 | } |
| 1022 | 1030 | |
| 1023 | 1031 | /** |
| 1032 | + * Determines if a particular feature or element should be displayed. | |
| 1033 | + * | |
| 1034 | + * @param array $args An associative array of arguments. | |
| 1035 | + * @param string $settings The specific setting key to check within the arguments array. | |
| 1036 | + * | |
| 1037 | + * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false. | |
| 1038 | + */ | |
| 1039 | + protected function should_display( $args, $settings ) { | |
| 1040 | + return ! isset( $args[ $settings ] ) || false !== $args[ $settings ]; | |
| 1041 | + } | |
| 1042 | + | |
| 1043 | + /** | |
| 1024 | 1044 | * Get a list of CSS classes for the list table table tag. |
| 1025 | 1045 | * |
| 1026 | 1046 | * @since 2.0.18 |
| 1027 | - * @access protected | |
| 1028 | 1047 | * |
| 1029 | 1048 | * @return array List of CSS classes for the table tag. |
| 1030 | 1049 | */ |
| 1031 | 1050 | protected function get_table_classes() { |
| @@ -1035,9 +1054,8 @@ | ||
| 1035 | 1054 | /** |
| 1036 | 1055 | * Generate the table navigation above or below the table |
| 1037 | 1056 | * |
| 1038 | 1057 | * @since 2.0.18 |
| 1039 | - * @access protected | |
| 1040 | 1058 | * |
| 1041 | 1059 | * @param string $which |
| 1042 | 1060 | */ |
| 1043 | 1061 | protected function display_tablenav( $which ) { |
| @@ -1080,9 +1098,8 @@ | ||
| 1080 | 1098 | /** |
| 1081 | 1099 | * Extra controls to be displayed between bulk actions and pagination |
| 1082 | 1100 | * |
| 1083 | 1101 | * @since 2.0.18 |
| 1084 | - * @access protected | |
| 1085 | 1102 | * |
| 1086 | 1103 | * @param string $which |
| 1087 | 1104 | */ |
| 1088 | 1105 | protected function extra_tablenav( $which ) { |
| @@ -1091,9 +1108,8 @@ | ||
| 1091 | 1108 | /** |
| 1092 | 1109 | * Generate the tbody element for the list table. |
| 1093 | 1110 | * |
| 1094 | 1111 | * @since 2.0.18 |
| 1095 | - * @access public | |
| 1096 | 1112 | */ |
| 1097 | 1113 | public function display_rows_or_placeholder() { |
| 1098 | 1114 | if ( $this->has_items() ) { |
| 1099 | 1115 | $this->display_rows(); |
| @@ -1107,11 +1123,10 @@ | ||
| 1107 | 1123 | /** |
| 1108 | 1124 | * Generates content for a single row of the table |
| 1109 | 1125 | * |
| 1110 | 1126 | * @since 2.0.18 |
| 1111 | - * @access public | |
| 1112 | 1127 | * |
| 1113 | - * @param object $item The current item | |
| 1128 | + * @param object $item The current item. | |
| 1114 | 1129 | */ |
| 1115 | 1130 | public function single_row( $item ) { |
| 1116 | 1131 | echo '<tr>'; |
| 1117 | 1132 | $this->single_row_columns( $item ); |
| @@ -1121,11 +1136,10 @@ | ||
| 1121 | 1136 | /** |
| 1122 | 1137 | * Generates the columns for a single row of the table |
| 1123 | 1138 | * |
| 1124 | 1139 | * @since 2.0.18 |
| 1125 | - * @access protected | |
| 1126 | 1140 | * |
| 1127 | - * @param object $item The current item | |
| 1141 | + * @param object $item The current item. | |
| 1128 | 1142 | */ |
| 1129 | 1143 | protected function single_row_columns( $item ) { |
| 1130 | 1144 | list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
| 1131 | 1145 | |
| @@ -1159,9 +1173,9 @@ | ||
| 1159 | 1173 | |
| 1160 | 1174 | echo $this->handle_row_actions( $item, $column_name, $primary ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 1161 | 1175 | echo '</td>'; |
| 1162 | 1176 | } |
| 1163 | - } | |
| 1177 | + }//end foreach | |
| 1164 | 1178 | } |
| 1165 | 1179 | |
| 1166 | 1180 | /** |
| 1167 | 1181 | * Generates and display row actions links for the list table. |
| @@ -1166,9 +1180,8 @@ | ||
| 1166 | 1180 | /** |
| 1167 | 1181 | * Generates and display row actions links for the list table. |
| 1168 | 1182 | * |
| 1169 | 1183 | * @since 4.3.0 |
| 1170 | - * @access protected | |
| 1171 | 1184 | * |
| 1172 | 1185 | * @param object $item The item being acted upon. |
| 1173 | 1186 | * @param string $column_name Current column name. |
| 1174 | 1187 | * @param string $primary Primary column name. |
| @@ -1182,9 +1195,8 @@ | ||
| 1182 | 1195 | /** |
| 1183 | 1196 | * Handle an incoming ajax request (called from admin-ajax.php) |
| 1184 | 1197 | * |
| 1185 | 1198 | * @since 2.0.18 |
| 1186 | - * @access public | |
| 1187 | 1199 | */ |
| 1188 | 1200 | public function ajax_response() { |
| 1189 | 1201 | $this->prepare_items(); |
| 1190 | 1202 | |
| @@ -1216,9 +1228,9 @@ | ||
| 1216 | 1228 | |
| 1217 | 1229 | /** |
| 1218 | 1230 | * Send required variables to JavaScript land |
| 1219 | 1231 | * |
| 1220 | - * @access public | |
| 1232 | + * @return void | |
| 1221 | 1233 | */ |
| 1222 | 1234 | public function _js_vars() { |
| 1223 | 1235 | $args = array( |
| 1224 | 1236 | 'class' => get_class( $this ), |
| @@ -1228,6 +1240,13 @@ | ||
| 1228 | 1240 | ), |
| 1229 | 1241 | ); |
| 1230 | 1242 | |
| 1231 | 1243 | printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) ); |
| 1244 | + } | |
| 1245 | + | |
| 1246 | + /** | |
| 1247 | + * @return string | |
| 1248 | + */ | |
| 1249 | + protected function loaded_from() { | |
| 1250 | + return ''; | |
| 1232 | 1251 | } |
| 1233 | 1252 | } |