| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | /** |
| 8 | 8 | * The current list of items |
| 9 | 9 | * |
| 10 | 10 | * @since 2.0.18 |
| 11 | - * | |
| 12 | 11 | * @var array |
| 13 | 12 | */ |
| 14 | 13 | public $items; |
| 15 | 14 | |
| @@ -14,9 +13,8 @@ | ||
| 14 | 13 | public $items; |
| 15 | 14 | |
| 16 | 15 | /** |
| 17 | 16 | * @since 4.07 |
| 18 | - * | |
| 19 | 17 | * @var bool|int |
| 20 | 18 | */ |
| 21 | 19 | public $total_items = false; |
| 22 | 20 | |
| @@ -23,9 +21,8 @@ | ||
| 23 | 21 | /** |
| 24 | 22 | * Various information about the current table |
| 25 | 23 | * |
| 26 | 24 | * @since 2.0.18 |
| 27 | - * | |
| 28 | 25 | * @var array |
| 29 | 26 | */ |
| 30 | 27 | protected $_args; |
| 31 | 28 | |
| @@ -32,9 +29,8 @@ | ||
| 32 | 29 | /** |
| 33 | 30 | * Various information needed for displaying the pagination |
| 34 | 31 | * |
| 35 | 32 | * @since 2.0.18 |
| 36 | - * | |
| 37 | 33 | * @var array |
| 38 | 34 | */ |
| 39 | 35 | protected $_pagination_args = array(); |
| 40 | 36 | |
| @@ -50,9 +46,8 @@ | ||
| 50 | 46 | /** |
| 51 | 47 | * Cached bulk actions |
| 52 | 48 | * |
| 53 | 49 | * @since 2.0.18 |
| 54 | - * | |
| 55 | 50 | * @var array |
| 56 | 51 | */ |
| 57 | 52 | private $_actions; |
| 58 | 53 | |
| @@ -59,9 +54,8 @@ | ||
| 59 | 54 | /** |
| 60 | 55 | * Cached pagination output |
| 61 | 56 | * |
| 62 | 57 | * @since 2.0.18 |
| 63 | - * | |
| 64 | 58 | * @var string |
| 65 | 59 | */ |
| 66 | 60 | private $_pagination; |
| 67 | 61 | |
| @@ -68,9 +62,8 @@ | ||
| 68 | 62 | /** |
| 69 | 63 | * The view switcher modes. |
| 70 | 64 | * |
| 71 | 65 | * @since 2.0.18 |
| 72 | - * | |
| 73 | 66 | * @var array |
| 74 | 67 | */ |
| 75 | 68 | protected $modes = array(); |
| 76 | 69 | |
| @@ -85,16 +78,10 @@ | ||
| 85 | 78 | * @var array |
| 86 | 79 | */ |
| 87 | 80 | protected $_column_headers; |
| 88 | 81 | |
| 89 | - /** | |
| 90 | - * @var array | |
| 91 | - */ | |
| 92 | 82 | protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' ); |
| 93 | 83 | |
| 94 | - /** | |
| 95 | - * @var array | |
| 96 | - */ | |
| 97 | 84 | protected $compat_methods = array( |
| 98 | 85 | 'set_pagination_args', |
| 99 | 86 | 'get_views', |
| 100 | 87 | 'get_bulk_actions', |
| @@ -112,12 +99,8 @@ | ||
| 112 | 99 | ); |
| 113 | 100 | |
| 114 | 101 | /** |
| 115 | 102 | * Construct the table object |
| 116 | - * | |
| 117 | - * @param array $args | |
| 118 | - * | |
| 119 | - * @return void | |
| 120 | 103 | */ |
| 121 | 104 | public function __construct( $args ) { |
| 122 | 105 | $args = wp_parse_args( |
| 123 | 106 | $args, |
| @@ -149,9 +132,9 @@ | ||
| 149 | 132 | // wp_enqueue_script( 'list-table' ); |
| 150 | 133 | add_action( 'admin_footer', array( $this, '_js_vars' ) ); |
| 151 | 134 | } |
| 152 | 135 | |
| 153 | - if ( ! $this->modes ) { | |
| 136 | + if ( empty( $this->modes ) ) { | |
| 154 | 137 | $this->modes = array( |
| 155 | 138 | 'list' => __( 'List View', 'formidable' ), |
| 156 | 139 | 'excerpt' => __( 'Excerpt View', 'formidable' ), |
| 157 | 140 | ); |
| @@ -177,9 +160,8 @@ | ||
| 177 | 160 | * |
| 178 | 161 | * @uses FrmListHelper::set_pagination_args() |
| 179 | 162 | * |
| 180 | 163 | * @since 2.0.18 |
| 181 | - * | |
| 182 | 164 | * @abstract |
| 183 | 165 | */ |
| 184 | 166 | public function prepare_items() { |
| 185 | 167 | die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' ); |
| @@ -186,19 +168,15 @@ | ||
| 186 | 168 | } |
| 187 | 169 | |
| 188 | 170 | /** |
| 189 | 171 | * @since 3.0 |
| 190 | - * | |
| 191 | - * @param array $args | |
| 192 | - * | |
| 193 | - * @return array|string | |
| 194 | 172 | */ |
| 195 | 173 | protected function get_param( $args ) { |
| 196 | 174 | return FrmAppHelper::get_simple_request( |
| 197 | 175 | array( |
| 198 | 176 | 'param' => $args['param'], |
| 199 | - 'default' => $args['default'] ?? '', | |
| 200 | - 'sanitize' => $args['sanitize'] ?? 'sanitize_title', | |
| 177 | + 'default' => isset( $args['default'] ) ? $args['default'] : '', | |
| 178 | + 'sanitize' => isset( $args['sanitize'] ) ? $args['sanitize'] : 'sanitize_title', | |
| 201 | 179 | 'type' => 'request', |
| 202 | 180 | ) |
| 203 | 181 | ); |
| 204 | 182 | } |
| @@ -241,13 +219,15 @@ | ||
| 241 | 219 | * |
| 242 | 220 | * @return int Number of items that correspond to the given pagination argument. |
| 243 | 221 | */ |
| 244 | 222 | public function get_pagination_arg( $key ) { |
| 245 | - if ( 'page' === $key ) { | |
| 223 | + if ( 'page' == $key ) { | |
| 246 | 224 | return $this->get_pagenum(); |
| 247 | 225 | } |
| 248 | 226 | |
| 249 | - return $this->_pagination_args[ $key ] ?? null; | |
| 227 | + if ( isset( $this->_pagination_args[ $key ] ) ) { | |
| 228 | + return $this->_pagination_args[ $key ]; | |
| 229 | + } | |
| 250 | 230 | } |
| 251 | 231 | |
| 252 | 232 | /** |
| 253 | 233 | * Whether the table has items to display or not |
| @@ -288,13 +268,8 @@ | ||
| 288 | 268 | |
| 289 | 269 | FrmAppHelper::show_search_box( compact( 'text', 'input_id' ) ); |
| 290 | 270 | } |
| 291 | 271 | |
| 292 | - /** | |
| 293 | - * @param string $param_name | |
| 294 | - * | |
| 295 | - * @return void | |
| 296 | - */ | |
| 297 | 272 | private function hidden_search_inputs( $param_name ) { |
| 298 | 273 | if ( ! empty( $_REQUEST[ $param_name ] ) ) { |
| 299 | 274 | $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) ); |
| 300 | 275 | echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />'; |
| @@ -331,14 +306,13 @@ | ||
| 331 | 306 | * @param array $views An array of available list table views. |
| 332 | 307 | */ |
| 333 | 308 | $views = apply_filters( 'views_' . $this->screen->id, $views ); |
| 334 | 309 | |
| 335 | - if ( ! $views ) { | |
| 310 | + if ( empty( $views ) ) { | |
| 336 | 311 | return; |
| 337 | 312 | } |
| 338 | 313 | |
| 339 | 314 | echo "<ul class='subsubsub'>\n"; |
| 340 | - | |
| 341 | 315 | foreach ( $views as $class => $view ) { |
| 342 | 316 | $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view; |
| 343 | 317 | } |
| 344 | 318 | echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| @@ -401,9 +375,8 @@ | ||
| 401 | 375 | foreach ( $this->_actions as $name => $title ) { |
| 402 | 376 | $params = array( |
| 403 | 377 | 'value' => $name, |
| 404 | 378 | ); |
| 405 | - | |
| 406 | 379 | if ( 'edit' === $name ) { |
| 407 | 380 | $params['class'] = 'hide-if-no-js'; |
| 408 | 381 | } |
| 409 | 382 | |
| @@ -457,9 +430,8 @@ | ||
| 457 | 430 | return false; |
| 458 | 431 | } |
| 459 | 432 | |
| 460 | 433 | $action = $this->get_bulk_action( 'action' ); |
| 461 | - | |
| 462 | 434 | if ( $action === false ) { |
| 463 | 435 | $action = $this->get_bulk_action( 'action2' ); |
| 464 | 436 | } |
| 465 | 437 | |
| @@ -465,13 +437,8 @@ | ||
| 465 | 437 | |
| 466 | 438 | return $action; |
| 467 | 439 | } |
| 468 | 440 | |
| 469 | - /** | |
| 470 | - * @param string $action_name | |
| 471 | - * | |
| 472 | - * @return false|string | |
| 473 | - */ | |
| 474 | 441 | private function get_bulk_action( $action_name ) { |
| 475 | 442 | $action = false; |
| 476 | 443 | $action_param = $this->get_param( |
| 477 | 444 | array( |
| @@ -478,10 +445,8 @@ | ||
| 478 | 445 | 'param' => $action_name, |
| 479 | 446 | 'sanitize' => 'sanitize_text_field', |
| 480 | 447 | ) |
| 481 | 448 | ); |
| 482 | - | |
| 483 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 484 | 449 | if ( $action_param && - 1 != $action_param ) { |
| 485 | 450 | $action = $action_param; |
| 486 | 451 | } |
| 487 | 452 | |
| @@ -499,25 +464,26 @@ | ||
| 499 | 464 | * @return string |
| 500 | 465 | */ |
| 501 | 466 | protected function row_actions( $actions, $always_visible = false ) { |
| 502 | 467 | $action_count = count( $actions ); |
| 503 | - $i = 0; | |
| 504 | 468 | |
| 469 | + $i = 0; | |
| 470 | + | |
| 505 | 471 | if ( ! $action_count ) { |
| 506 | 472 | return ''; |
| 507 | 473 | } |
| 508 | 474 | |
| 509 | 475 | $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">'; |
| 510 | - | |
| 511 | 476 | foreach ( $actions as $action => $link ) { |
| 512 | 477 | ++$i; |
| 513 | - $sep = $i === $action_count ? '' : ' | '; | |
| 478 | + $sep = $i == $action_count ? '' : ' | '; | |
| 514 | 479 | $out .= "<span class='$action'>$link$sep</span>"; |
| 515 | 480 | } |
| 481 | + $out .= '</div>'; | |
| 516 | 482 | |
| 517 | - $out .= '</div>'; | |
| 483 | + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>'; | |
| 518 | 484 | |
| 519 | - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' ); | |
| 485 | + return $out; | |
| 520 | 486 | } |
| 521 | 487 | |
| 522 | 488 | /** |
| 523 | 489 | * Display a view switcher |
| @@ -532,10 +498,8 @@ | ||
| 532 | 498 | <div class="view-switch"> |
| 533 | 499 | <?php |
| 534 | 500 | foreach ( $this->modes as $mode => $title ) { |
| 535 | 501 | $classes = array( 'view-' . $mode ); |
| 536 | - | |
| 537 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 538 | 502 | if ( $current_mode == $mode ) { |
| 539 | 503 | $classes[] = 'current'; |
| 540 | 504 | } |
| 541 | 505 | |
| @@ -579,10 +543,9 @@ | ||
| 579 | 543 | * @return int |
| 580 | 544 | */ |
| 581 | 545 | protected function get_items_per_page( $option, $default = 20 ) { |
| 582 | 546 | $per_page = (int) get_user_option( $option ); |
| 583 | - | |
| 584 | - if ( ! $per_page || $per_page < 1 ) { | |
| 547 | + if ( empty( $per_page ) || $per_page < 1 ) { | |
| 585 | 548 | $per_page = $default; |
| 586 | 549 | } |
| 587 | 550 | |
| 588 | 551 | /** |
| @@ -615,9 +578,8 @@ | ||
| 615 | 578 | |
| 616 | 579 | $total_items = $this->_pagination_args['total_items']; |
| 617 | 580 | $total_pages = $this->_pagination_args['total_pages']; |
| 618 | 581 | $infinite_scroll = false; |
| 619 | - | |
| 620 | 582 | if ( isset( $this->_pagination_args['infinite_scroll'] ) ) { |
| 621 | 583 | $infinite_scroll = $this->_pagination_args['infinite_scroll']; |
| 622 | 584 | } |
| 623 | 585 | |
| @@ -623,14 +585,17 @@ | ||
| 623 | 585 | |
| 624 | 586 | /* translators: %s: Number of items */ |
| 625 | 587 | $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>'; |
| 626 | 588 | |
| 627 | - $current = $this->get_pagenum(); | |
| 628 | - $page_links = array(); | |
| 589 | + $current = $this->get_pagenum(); | |
| 590 | + | |
| 591 | + $page_links = array(); | |
| 592 | + | |
| 629 | 593 | $total_pages_before = '<span class="paging-input">'; |
| 630 | 594 | $total_pages_after = '</span>'; |
| 631 | - $disable = $this->disabled_pages( $total_pages ); | |
| 632 | 595 | |
| 596 | + $disable = $this->disabled_pages( $total_pages ); | |
| 597 | + | |
| 633 | 598 | $page_links[] = $this->add_page_link( |
| 634 | 599 | array( |
| 635 | 600 | 'page' => 'first', |
| 636 | 601 | 'arrow' => '«', |
| @@ -647,9 +612,9 @@ | ||
| 647 | 612 | 'disabled' => $disable['prev'], |
| 648 | 613 | ) |
| 649 | 614 | ); |
| 650 | 615 | |
| 651 | - if ( 'bottom' === $which ) { | |
| 616 | + if ( 'bottom' == $which ) { | |
| 652 | 617 | $html_current_page = $current; |
| 653 | 618 | $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">'; |
| 654 | 619 | } else { |
| 655 | 620 | $html_current_page = sprintf( |
| @@ -658,9 +623,8 @@ | ||
| 658 | 623 | $current, |
| 659 | 624 | strlen( $total_pages ) |
| 660 | 625 | ); |
| 661 | 626 | } |
| 662 | - | |
| 663 | 627 | $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) ); |
| 664 | 628 | |
| 665 | 629 | /* translators: %1$s: Current page number, %2$s: Total pages */ |
| 666 | 630 | $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'formidable' ), $html_current_page, $html_total_pages ) . $total_pages_after; |
| @@ -683,13 +647,11 @@ | ||
| 683 | 647 | ) |
| 684 | 648 | ); |
| 685 | 649 | |
| 686 | 650 | $pagination_links_class = 'pagination-links'; |
| 687 | - | |
| 688 | - if ( $infinite_scroll ) { | |
| 651 | + if ( ! empty( $infinite_scroll ) ) { | |
| 689 | 652 | $pagination_links_class = ' hide-if-js'; |
| 690 | 653 | } |
| 691 | - | |
| 692 | 654 | $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>'; |
| 693 | 655 | |
| 694 | 656 | if ( $total_pages ) { |
| 695 | 657 | $page_class = $total_pages < 2 ? ' one-page' : ''; |
| @@ -700,13 +662,8 @@ | ||
| 700 | 662 | |
| 701 | 663 | echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 702 | 664 | } |
| 703 | 665 | |
| 704 | - /** | |
| 705 | - * @param int $total_pages | |
| 706 | - * | |
| 707 | - * @return array | |
| 708 | - */ | |
| 709 | 666 | private function disabled_pages( $total_pages ) { |
| 710 | 667 | $current = $this->get_pagenum(); |
| 711 | 668 | $disable = array( |
| 712 | 669 | 'first' => false, |
| @@ -714,21 +671,19 @@ | ||
| 714 | 671 | 'prev' => false, |
| 715 | 672 | 'next' => false, |
| 716 | 673 | ); |
| 717 | 674 | |
| 718 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 719 | 675 | if ( $current == 1 ) { |
| 720 | 676 | $disable['first'] = true; |
| 721 | 677 | $disable['prev'] = true; |
| 722 | - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons | |
| 678 | + } elseif ( $current == 2 ) { | |
| 723 | 679 | $disable['first'] = true; |
| 724 | 680 | } |
| 725 | 681 | |
| 726 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 727 | 682 | if ( $current == $total_pages ) { |
| 728 | 683 | $disable['last'] = true; |
| 729 | 684 | $disable['next'] = true; |
| 730 | - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons | |
| 685 | + } elseif ( $current == $total_pages - 1 ) { | |
| 731 | 686 | $disable['last'] = true; |
| 732 | 687 | } |
| 733 | 688 | |
| 734 | 689 | return $disable; |
| @@ -733,13 +688,8 @@ | ||
| 733 | 688 | |
| 734 | 689 | return $disable; |
| 735 | 690 | } |
| 736 | 691 | |
| 737 | - /** | |
| 738 | - * @param string $link | |
| 739 | - * | |
| 740 | - * @return string | |
| 741 | - */ | |
| 742 | 692 | private function link_label( $link ) { |
| 743 | 693 | $labels = array( |
| 744 | 694 | 'first' => __( 'First page', 'formidable' ), |
| 745 | 695 | 'last' => __( 'Last page', 'formidable' ), |
| @@ -751,34 +701,26 @@ | ||
| 751 | 701 | } |
| 752 | 702 | |
| 753 | 703 | private function current_url() { |
| 754 | 704 | $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); |
| 705 | + | |
| 755 | 706 | return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url ); |
| 756 | 707 | } |
| 757 | 708 | |
| 758 | - /** | |
| 759 | - * @param array $atts | |
| 760 | - * | |
| 761 | - * @return string | |
| 762 | - */ | |
| 763 | 709 | private function add_page_link( $atts ) { |
| 764 | - return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts ); | |
| 710 | + if ( $atts['disabled'] ) { | |
| 711 | + $link = $this->add_disabled_link( $atts['arrow'] ); | |
| 712 | + } else { | |
| 713 | + $link = $this->add_active_link( $atts ); | |
| 714 | + } | |
| 715 | + | |
| 716 | + return $link; | |
| 765 | 717 | } |
| 766 | 718 | |
| 767 | - /** | |
| 768 | - * @param string $label | |
| 769 | - * | |
| 770 | - * @return string | |
| 771 | - */ | |
| 772 | 719 | private function add_disabled_link( $label ) { |
| 773 | 720 | return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>'; |
| 774 | 721 | } |
| 775 | 722 | |
| 776 | - /** | |
| 777 | - * @param array $atts | |
| 778 | - * | |
| 779 | - * @return string | |
| 780 | - */ | |
| 781 | 723 | private function add_active_link( $atts ) { |
| 782 | 724 | $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) ); |
| 783 | 725 | $label = $this->link_label( $atts['page'] ); |
| 784 | 726 | |
| @@ -858,9 +800,9 @@ | ||
| 858 | 800 | * @param string $context Screen ID for specific list table, e.g. 'plugins'. |
| 859 | 801 | */ |
| 860 | 802 | $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id ); |
| 861 | 803 | |
| 862 | - if ( ! $column || ! isset( $columns[ $column ] ) ) { | |
| 804 | + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) { | |
| 863 | 805 | $column = $default; |
| 864 | 806 | } |
| 865 | 807 | |
| 866 | 808 | return $column; |
| @@ -878,9 +820,8 @@ | ||
| 878 | 820 | if ( is_array( $this->_column_headers ) ) { |
| 879 | 821 | // Back-compat for list tables that have been manually setting $_column_headers for horse reasons. |
| 880 | 822 | // In 4.3, we added a fourth argument for primary column. |
| 881 | 823 | $column_headers = array( array(), array(), array(), $this->get_primary_column_name() ); |
| 882 | - | |
| 883 | 824 | foreach ( $this->_column_headers as $key => $value ) { |
| 884 | 825 | $column_headers[ $key ] = $value; |
| 885 | 826 | } |
| 886 | 827 | |
| @@ -886,10 +827,11 @@ | ||
| 886 | 827 | |
| 887 | 828 | return $column_headers; |
| 888 | 829 | } |
| 889 | 830 | |
| 890 | - $columns = get_column_headers( $this->screen ); | |
| 891 | - $hidden = get_hidden_columns( $this->screen ); | |
| 831 | + $columns = get_column_headers( $this->screen ); | |
| 832 | + $hidden = get_hidden_columns( $this->screen ); | |
| 833 | + | |
| 892 | 834 | $sortable_columns = $this->get_sortable_columns(); |
| 893 | 835 | /** |
| 894 | 836 | * Filter the list table sortable columns for a specific screen. |
| 895 | 837 | * |
| @@ -902,9 +844,8 @@ | ||
| 902 | 844 | */ |
| 903 | 845 | $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns ); |
| 904 | 846 | |
| 905 | 847 | $sortable = array(); |
| 906 | - | |
| 907 | 848 | foreach ( $_sortable as $id => $data ) { |
| 908 | 849 | if ( empty( $data ) ) { |
| 909 | 850 | continue; |
| 910 | 851 | } |
| @@ -909,9 +850,8 @@ | ||
| 909 | 850 | continue; |
| 910 | 851 | } |
| 911 | 852 | |
| 912 | 853 | $data = (array) $data; |
| 913 | - | |
| 914 | 854 | if ( ! isset( $data[1] ) ) { |
| 915 | 855 | $data[1] = false; |
| 916 | 856 | } |
| 917 | 857 | |
| @@ -946,19 +886,28 @@ | ||
| 946 | 886 | * |
| 947 | 887 | * @staticvar int $cb_counter |
| 948 | 888 | * |
| 949 | 889 | * @param bool $with_id Whether to set the id attribute or not. |
| 950 | - * | |
| 951 | 890 | * @return void |
| 952 | 891 | */ |
| 953 | - public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 892 | + public function print_column_headers( $with_id = true ) { | |
| 954 | 893 | list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
| 955 | 894 | |
| 956 | - $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); | |
| 957 | - $current_url = remove_query_arg( 'paged', $current_url ); | |
| 958 | - $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : ''; | |
| 959 | - $current_order = isset( $_GET['order'] ) && 'desc' === $_GET['order'] ? 'desc' : 'asc'; | |
| 895 | + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) ); | |
| 896 | + $current_url = remove_query_arg( 'paged', $current_url ); | |
| 960 | 897 | |
| 898 | + if ( isset( $_GET['orderby'] ) ) { | |
| 899 | + $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) ); | |
| 900 | + } else { | |
| 901 | + $current_orderby = ''; | |
| 902 | + } | |
| 903 | + | |
| 904 | + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) { | |
| 905 | + $current_order = 'desc'; | |
| 906 | + } else { | |
| 907 | + $current_order = 'asc'; | |
| 908 | + } | |
| 909 | + | |
| 961 | 910 | FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order ); |
| 962 | 911 | |
| 963 | 912 | if ( ! empty( $columns['cb'] ) ) { |
| 964 | 913 | static $cb_counter = 1; |
| @@ -971,9 +920,8 @@ | ||
| 971 | 920 | $class = array( 'manage-column', "column-$column_key" ); |
| 972 | 921 | $aria_sort_attr = ''; |
| 973 | 922 | $order_text = ''; |
| 974 | 923 | |
| 975 | - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 976 | 924 | if ( in_array( $column_key, $hidden ) ) { |
| 977 | 925 | $class[] = 'hidden'; |
| 978 | 926 | } |
| 979 | 927 | |
| @@ -989,9 +937,8 @@ | ||
| 989 | 937 | |
| 990 | 938 | if ( isset( $sortable[ $column_key ] ) ) { |
| 991 | 939 | list( $orderby, $desc_first ) = $sortable[ $column_key ]; |
| 992 | 940 | |
| 993 | - // phpcs:ignore Universal.Operators.StrictComparisons | |
| 994 | 941 | if ( $current_orderby == $orderby ) { |
| 995 | 942 | // The sorted column. The `aria-sort` attribute must be set only on the sorted column. |
| 996 | 943 | if ( 'asc' === $current_order ) { |
| 997 | 944 | $order = 'desc'; |
| @@ -1037,9 +984,9 @@ | ||
| 1037 | 984 | $tag = 'cb' === $column_key ? 'td' : 'th'; |
| 1038 | 985 | $scope = 'th' === $tag ? 'scope="col"' : ''; |
| 1039 | 986 | $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : ''; |
| 1040 | 987 | |
| 1041 | - if ( $class ) { | |
| 988 | + if ( ! empty( $class ) ) { | |
| 1042 | 989 | $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'"; |
| 1043 | 990 | } |
| 1044 | 991 | |
| 1045 | 992 | if ( ! $this->has_min_items() && ! $with_id ) { |
| @@ -1053,21 +1000,16 @@ | ||
| 1053 | 1000 | /** |
| 1054 | 1001 | * Display the table |
| 1055 | 1002 | * |
| 1056 | 1003 | * @since 2.0.18 |
| 1057 | - * | |
| 1058 | 1004 | * @param array $args |
| 1059 | - * | |
| 1060 | - * @return void | |
| 1061 | 1005 | */ |
| 1062 | 1006 | public function display( $args = array() ) { |
| 1063 | 1007 | $singular = $this->_args['singular']; |
| 1064 | 1008 | $tbody_params = array(); |
| 1065 | - | |
| 1066 | 1009 | if ( $singular ) { |
| 1067 | 1010 | $tbody_params['data-wp-lists'] = 'list:' . $singular; |
| 1068 | 1011 | } |
| 1069 | - | |
| 1070 | 1012 | if ( $this->should_display( $args, 'display-top-nav' ) ) { |
| 1071 | 1013 | $this->display_tablenav( 'top' ); |
| 1072 | 1014 | } |
| 1073 | 1015 | $this->screen->render_screen_reader_content( 'heading_list' ); |
| @@ -1132,9 +1074,8 @@ | ||
| 1132 | 1074 | */ |
| 1133 | 1075 | protected function display_tablenav( $which ) { |
| 1134 | 1076 | if ( 'top' === $which ) { |
| 1135 | 1077 | wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); |
| 1136 | - | |
| 1137 | 1078 | if ( ! $this->has_min_items( 1 ) ) { |
| 1138 | 1079 | // Don't show bulk actions if no items. |
| 1139 | 1080 | return; |
| 1140 | 1081 | } |
| @@ -1162,12 +1103,8 @@ | ||
| 1162 | 1103 | * Use this to exclude the footer labels and bulk items. |
| 1163 | 1104 | * When close together, it feels like duplicates. |
| 1164 | 1105 | * |
| 1165 | 1106 | * @since 4.07 |
| 1166 | - * | |
| 1167 | - * @param int $limit | |
| 1168 | - * | |
| 1169 | - * @return bool | |
| 1170 | 1107 | */ |
| 1171 | 1108 | protected function has_min_items( $limit = 5 ) { |
| 1172 | 1109 | return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit ); |
| 1173 | 1110 | } |
| @@ -1221,14 +1158,12 @@ | ||
| 1221 | 1158 | list( $columns, $hidden,, $primary ) = $this->get_column_info(); |
| 1222 | 1159 | |
| 1223 | 1160 | foreach ( $columns as $column_name => $column_display_name ) { |
| 1224 | 1161 | $classes = "$column_name column-$column_name"; |
| 1225 | - | |
| 1226 | 1162 | if ( $primary === $column_name ) { |
| 1227 | 1163 | $classes .= ' has-row-actions column-primary'; |
| 1228 | 1164 | } |
| 1229 | 1165 | |
| 1230 | - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict | |
| 1231 | 1166 | if ( in_array( $column_name, $hidden ) ) { |
| 1232 | 1167 | $classes .= ' hidden'; |
| 1233 | 1168 | } |
| 1234 | 1169 | |
| @@ -1267,9 +1202,9 @@ | ||
| 1267 | 1202 | * |
| 1268 | 1203 | * @return string The row actions output. In this case, an empty string. |
| 1269 | 1204 | */ |
| 1270 | 1205 | protected function handle_row_actions( $item, $column_name, $primary ) { |
| 1271 | - return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : ''; // phpcs:ignore Universal.Operators.StrictComparisons, SlevomatCodingStandard.Files.LineLength.LineTooLong | |
| 1206 | + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : ''; | |
| 1272 | 1207 | } |
| 1273 | 1208 | |
| 1274 | 1209 | /** |
| 1275 | 1210 | * Handle an incoming ajax request (called from admin-ajax.php) |
| @@ -1279,9 +1214,8 @@ | ||
| 1279 | 1214 | public function ajax_response() { |
| 1280 | 1215 | $this->prepare_items(); |
| 1281 | 1216 | |
| 1282 | 1217 | ob_start(); |
| 1283 | - | |
| 1284 | 1218 | if ( ! empty( $_REQUEST['no_placeholder'] ) ) { |
| 1285 | 1219 | $this->display_rows(); |
| 1286 | 1220 | } else { |
| 1287 | 1221 | $this->display_rows_or_placeholder(); |
| @@ -1286,9 +1220,10 @@ | ||
| 1286 | 1220 | } else { |
| 1287 | 1221 | $this->display_rows_or_placeholder(); |
| 1288 | 1222 | } |
| 1289 | 1223 | |
| 1290 | - $rows = ob_get_clean(); | |
| 1224 | + $rows = ob_get_clean(); | |
| 1225 | + | |
| 1291 | 1226 | $response = array( 'rows' => $rows ); |
| 1292 | 1227 | |
| 1293 | 1228 | if ( isset( $this->_pagination_args['total_items'] ) ) { |
| 1294 | 1229 | $response['total_items_i18n'] = sprintf( |
| @@ -1296,9 +1231,8 @@ | ||
| 1296 | 1231 | _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ), |
| 1297 | 1232 | number_format_i18n( $this->_pagination_args['total_items'] ) |
| 1298 | 1233 | ); |
| 1299 | 1234 | } |
| 1300 | - | |
| 1301 | 1235 | if ( isset( $this->_pagination_args['total_pages'] ) ) { |
| 1302 | 1236 | $response['total_pages'] = $this->_pagination_args['total_pages']; |
| 1303 | 1237 | $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] ); |
| 1304 | 1238 | } |