PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmListHelper.php +81 -159 6.31 → 6.24.1 View file →
@@ -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 );
@@ -161,11 +144,8 @@
161 144 public function ajax_user_can() {
162 145 return current_user_can( 'administrator' );
163 146 }
164 147
165 - /**
166 - * @return array
167 - */
168 148 public function get_columns() {
169 149 return array();
170 150 }
171 151
@@ -180,9 +160,8 @@
180 160 *
181 161 * @uses FrmListHelper::set_pagination_args()
182 162 *
183 163 * @since 2.0.18
184 - *
185 164 * @abstract
186 165 */
187 166 public function prepare_items() {
188 167 die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' );
@@ -189,19 +168,15 @@
189 168 }
190 169
191 170 /**
192 171 * @since 3.0
193 - *
194 - * @param array $args
195 - *
196 - * @return array|string
197 172 */
198 173 protected function get_param( $args ) {
199 174 return FrmAppHelper::get_simple_request(
200 175 array(
201 176 'param' => $args['param'],
202 - 'default' => $args['default'] ?? '',
203 - 'sanitize' => $args['sanitize'] ?? 'sanitize_title',
177 + 'default' => isset( $args['default'] ) ? $args['default'] : '',
178 + 'sanitize' => isset( $args['sanitize'] ) ? $args['sanitize'] : 'sanitize_title',
204 179 'type' => 'request',
205 180 )
206 181 );
207 182 }
@@ -225,17 +200,10 @@
225 200 $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
226 201 }
227 202
228 203 // Redirect if page number is invalid and headers are not already sent.
229 - if ( ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
230 - $url = add_query_arg( 'paged', $args['total_pages'] );
231 -
232 - if ( headers_sent() ) {
233 - FrmAppHelper::js_redirect( $url, true );
234 - exit;
235 - }
236 -
237 - wp_safe_redirect( $url );
204 + if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
205 + wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
238 206 exit;
239 207 }
240 208
241 209 $this->_pagination_args = $args;
@@ -251,13 +219,15 @@
251 219 *
252 220 * @return int Number of items that correspond to the given pagination argument.
253 221 */
254 222 public function get_pagination_arg( $key ) {
255 - if ( 'page' === $key ) {
223 + if ( 'page' == $key ) {
256 224 return $this->get_pagenum();
257 225 }
258 226
259 - return $this->_pagination_args[ $key ] ?? null;
227 + if ( isset( $this->_pagination_args[ $key ] ) ) {
228 + return $this->_pagination_args[ $key ];
229 + }
260 230 }
261 231
262 232 /**
263 233 * Whether the table has items to display or not
@@ -298,20 +268,13 @@
298 268
299 269 FrmAppHelper::show_search_box( compact( 'text', 'input_id' ) );
300 270 }
301 271
302 - /**
303 - * @param string $param_name
304 - *
305 - * @return void
306 - */
307 272 private function hidden_search_inputs( $param_name ) {
308 - if ( empty( $_REQUEST[ $param_name ] ) ) {
309 - return;
273 + if ( ! empty( $_REQUEST[ $param_name ] ) ) {
274 + $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
275 + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
310 276 }
311 -
312 - $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
313 - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
314 277 }
315 278
316 279 /**
317 280 * Get an associative array ( id => link ) with the list
@@ -343,14 +306,13 @@
343 306 * @param array $views An array of available list table views.
344 307 */
345 308 $views = apply_filters( 'views_' . $this->screen->id, $views );
346 309
347 - if ( ! $views ) {
310 + if ( empty( $views ) ) {
348 311 return;
349 312 }
350 313
351 314 echo "<ul class='subsubsub'>\n";
352 -
353 315 foreach ( $views as $class => $view ) {
354 316 $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
355 317 }
356 318 echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -401,9 +363,9 @@
401 363 } else {
402 364 $two = '2';
403 365 }//end if
404 366
405 - if ( ! $this->_actions ) {
367 + if ( empty( $this->_actions ) ) {
406 368 return;
407 369 }
408 370
409 371 echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>';
@@ -413,9 +375,8 @@
413 375 foreach ( $this->_actions as $name => $title ) {
414 376 $params = array(
415 377 'value' => $name,
416 378 );
417 -
418 379 if ( 'edit' === $name ) {
419 380 $params['class'] = 'hide-if-no-js';
420 381 }
421 382
@@ -469,17 +430,15 @@
469 430 return false;
470 431 }
471 432
472 433 $action = $this->get_bulk_action( 'action' );
434 + if ( $action === false ) {
435 + $action = $this->get_bulk_action( 'action2' );
436 + }
473 437
474 - return $action === false ? $this->get_bulk_action( 'action2' ) : $action;
438 + return $action;
475 439 }
476 440
477 - /**
478 - * @param string $action_name
479 - *
480 - * @return false|string
481 - */
482 441 private function get_bulk_action( $action_name ) {
483 442 $action = false;
484 443 $action_param = $this->get_param(
485 444 array(
@@ -486,12 +445,10 @@
486 445 'param' => $action_name,
487 446 'sanitize' => 'sanitize_text_field',
488 447 )
489 448 );
490 -
491 - // phpcs:ignore Universal.Operators.StrictComparisons
492 449 if ( $action_param && - 1 != $action_param ) {
493 - return $action_param;
450 + $action = $action_param;
494 451 }
495 452
496 453 return $action;
497 454 }
@@ -508,24 +465,25 @@
508 465 */
509 466 protected function row_actions( $actions, $always_visible = false ) {
510 467 $action_count = count( $actions );
511 468
469 + $i = 0;
470 +
512 471 if ( ! $action_count ) {
513 472 return '';
514 473 }
515 474
516 - $i = 0;
517 475 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
518 -
519 476 foreach ( $actions as $action => $link ) {
520 477 ++$i;
521 - $sep = $i === $action_count ? '' : ' | ';
478 + $sep = $i == $action_count ? '' : ' | ';
522 479 $out .= "<span class='$action'>$link$sep</span>";
523 480 }
481 + $out .= '</div>';
524 482
525 - $out .= '</div>';
483 + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
526 484
527 - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' );
485 + return $out;
528 486 }
529 487
530 488 /**
531 489 * Display a view switcher
@@ -534,9 +492,8 @@
534 492 *
535 493 * @param string $current_mode
536 494 */
537 495 protected function view_switcher( $current_mode ) {
538 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
539 496 ?>
540 497 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/>
541 498 <div class="view-switch">
542 499 <?php
@@ -541,10 +498,9 @@
541 498 <div class="view-switch">
542 499 <?php
543 500 foreach ( $this->modes as $mode => $title ) {
544 501 $classes = array( 'view-' . $mode );
545 -
546 - if ( $current_mode === $mode ) {
502 + if ( $current_mode == $mode ) {
547 503 $classes[] = 'current';
548 504 }
549 505
550 506 printf(
@@ -556,9 +512,8 @@
556 512 }
557 513 ?>
558 514 </div>
559 515 <?php
560 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
561 516 }
562 517
563 518 /**
564 519 * Get the current page number
@@ -588,10 +543,9 @@
588 543 * @return int
589 544 */
590 545 protected function get_items_per_page( $option, $default = 20 ) {
591 546 $per_page = (int) get_user_option( $option );
592 -
593 - if ( ! $per_page || $per_page < 1 ) {
547 + if ( empty( $per_page ) || $per_page < 1 ) {
594 548 $per_page = $default;
595 549 }
596 550
597 551 /**
@@ -617,9 +571,9 @@
617 571 *
618 572 * @param string $which
619 573 */
620 574 protected function pagination( $which ) {
621 - if ( ! $this->_pagination_args ) {
575 + if ( empty( $this->_pagination_args ) ) {
622 576 return;
623 577 }
624 578
625 579 $total_items = $this->_pagination_args['total_items'];
@@ -624,9 +578,8 @@
624 578
625 579 $total_items = $this->_pagination_args['total_items'];
626 580 $total_pages = $this->_pagination_args['total_pages'];
627 581 $infinite_scroll = false;
628 -
629 582 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
630 583 $infinite_scroll = $this->_pagination_args['infinite_scroll'];
631 584 }
632 585
@@ -632,14 +585,17 @@
632 585
633 586 /* translators: %s: Number of items */
634 587 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
635 588
636 - $current = $this->get_pagenum();
637 - $page_links = array();
589 + $current = $this->get_pagenum();
590 +
591 + $page_links = array();
592 +
638 593 $total_pages_before = '<span class="paging-input">';
639 594 $total_pages_after = '</span>';
640 - $disable = $this->disabled_pages( $total_pages );
641 595
596 + $disable = $this->disabled_pages( $total_pages );
597 +
642 598 $page_links[] = $this->add_page_link(
643 599 array(
644 600 'page' => 'first',
645 601 'arrow' => '&laquo;',
@@ -656,20 +612,19 @@
656 612 'disabled' => $disable['prev'],
657 613 )
658 614 );
659 615
660 - if ( 'bottom' === $which ) {
616 + if ( 'bottom' == $which ) {
661 617 $html_current_page = $current;
662 - $total_pages_before = '<span class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
618 + $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
663 619 } else {
664 620 $html_current_page = sprintf(
665 621 "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
666 - '<label for="current-page-selector" class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</label>',
622 + '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>',
667 623 $current,
668 624 strlen( $total_pages )
669 625 );
670 626 }
671 -
672 627 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
673 628
674 629 /* translators: %1$s: Current page number, %2$s: Total pages */
675 630 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'formidable' ), $html_current_page, $html_total_pages ) . $total_pages_after;
@@ -692,13 +647,11 @@
692 647 )
693 648 );
694 649
695 650 $pagination_links_class = 'pagination-links';
696 -
697 - if ( $infinite_scroll ) {
651 + if ( ! empty( $infinite_scroll ) ) {
698 652 $pagination_links_class = ' hide-if-js';
699 653 }
700 -
701 654 $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
702 655
703 656 if ( $total_pages ) {
704 657 $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -709,13 +662,8 @@
709 662
710 663 echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
711 664 }
712 665
713 - /**
714 - * @param int $total_pages
715 - *
716 - * @return array
717 - */
718 666 private function disabled_pages( $total_pages ) {
719 667 $current = $this->get_pagenum();
720 668 $disable = array(
721 669 'first' => false,
@@ -723,21 +671,19 @@
723 671 'prev' => false,
724 672 'next' => false,
725 673 );
726 674
727 - // phpcs:ignore Universal.Operators.StrictComparisons
728 675 if ( $current == 1 ) {
729 676 $disable['first'] = true;
730 677 $disable['prev'] = true;
731 - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons
678 + } elseif ( $current == 2 ) {
732 679 $disable['first'] = true;
733 680 }
734 681
735 - // phpcs:ignore Universal.Operators.StrictComparisons
736 682 if ( $current == $total_pages ) {
737 683 $disable['last'] = true;
738 684 $disable['next'] = true;
739 - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons
685 + } elseif ( $current == $total_pages - 1 ) {
740 686 $disable['last'] = true;
741 687 }
742 688
743 689 return $disable;
@@ -742,13 +688,8 @@
742 688
743 689 return $disable;
744 690 }
745 691
746 - /**
747 - * @param string $link
748 - *
749 - * @return string
750 - */
751 692 private function link_label( $link ) {
752 693 $labels = array(
753 694 'first' => __( 'First page', 'formidable' ),
754 695 'last' => __( 'Last page', 'formidable' ),
@@ -760,34 +701,26 @@
760 701 }
761 702
762 703 private function current_url() {
763 704 $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
705 +
764 706 return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
765 707 }
766 708
767 - /**
768 - * @param array $atts
769 - *
770 - * @return string
771 - */
772 709 private function add_page_link( $atts ) {
773 - 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;
774 717 }
775 718
776 - /**
777 - * @param string $label
778 - *
779 - * @return string
780 - */
781 719 private function add_disabled_link( $label ) {
782 720 return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>';
783 721 }
784 722
785 - /**
786 - * @param array $atts
787 - *
788 - * @return string
789 - */
790 723 private function add_active_link( $atts ) {
791 724 $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) );
792 725 $label = $this->link_label( $atts['page'] );
793 726
@@ -823,13 +756,14 @@
823 756 *
824 757 * @return string Name of the default primary column, in this case, an empty string.
825 758 */
826 759 protected function get_default_primary_column_name() {
827 - $column = '';
760 + $columns = $this->get_columns();
761 + $column = '';
828 762
829 763 // We need a primary defined so responsive views show something,
830 - // So let's fall back to the first non-checkbox column.
831 - foreach ( $this->get_columns() as $col => $column_name ) {
764 + // so let's fall back to the first non-checkbox column.
765 + foreach ( $columns as $col => $column_name ) {
832 766 if ( 'cb' === $col ) {
833 767 continue;
834 768 }
835 769
@@ -851,9 +785,9 @@
851 785 $columns = $this->get_columns();
852 786 $default = $this->get_default_primary_column_name();
853 787
854 788 // If the primary column doesn't exist fall back to the
855 - // First non-checkbox column.
789 + // first non-checkbox column.
856 790 if ( ! isset( $columns[ $default ] ) ) {
857 791 $default = self::get_default_primary_column_name();
858 792 }
859 793
@@ -866,10 +800,10 @@
866 800 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
867 801 */
868 802 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
869 803
870 - if ( ! $column || ! isset( $columns[ $column ] ) ) {
871 - return $default;
804 + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
805 + $column = $default;
872 806 }
873 807
874 808 return $column;
875 809 }
@@ -886,9 +820,8 @@
886 820 if ( is_array( $this->_column_headers ) ) {
887 821 // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
888 822 // In 4.3, we added a fourth argument for primary column.
889 823 $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
890 -
891 824 foreach ( $this->_column_headers as $key => $value ) {
892 825 $column_headers[ $key ] = $value;
893 826 }
894 827
@@ -896,8 +829,10 @@
896 829 }
897 830
898 831 $columns = get_column_headers( $this->screen );
899 832 $hidden = get_hidden_columns( $this->screen );
833 +
834 + $sortable_columns = $this->get_sortable_columns();
900 835 /**
901 836 * Filter the list table sortable columns for a specific screen.
902 837 *
903 838 * The dynamic portion of the hook name, `$this->screen->id`, refers
@@ -906,19 +841,17 @@
906 841 * @since 3.5.0
907 842 *
908 843 * @param array $sortable_columns An array of sortable columns.
909 844 */
910 - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
845 + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
911 846
912 847 $sortable = array();
913 -
914 848 foreach ( $_sortable as $id => $data ) {
915 - if ( ! $data ) {
849 + if ( empty( $data ) ) {
916 850 continue;
917 851 }
918 852
919 853 $data = (array) $data;
920 -
921 854 if ( ! isset( $data[1] ) ) {
922 855 $data[1] = false;
923 856 }
924 857
@@ -953,24 +886,33 @@
953 886 *
954 887 * @staticvar int $cb_counter
955 888 *
956 889 * @param bool $with_id Whether to set the id attribute or not.
957 - *
958 890 * @return void
959 891 */
960 - 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 ) {
961 893 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
962 894
963 - $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
964 - $current_url = remove_query_arg( 'paged', $current_url );
965 - $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : '';
966 - $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 );
967 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 +
968 910 FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
969 911
970 912 if ( ! empty( $columns['cb'] ) ) {
971 913 static $cb_counter = 1;
972 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . esc_html__( 'Select All', 'formidable' ) . '</label>';
914 + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
973 915 $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
974 916 ++$cb_counter;
975 917 }
976 918
@@ -978,9 +920,8 @@
978 920 $class = array( 'manage-column', "column-$column_key" );
979 921 $aria_sort_attr = '';
980 922 $order_text = '';
981 923
982 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
983 924 if ( in_array( $column_key, $hidden ) ) {
984 925 $class[] = 'hidden';
985 926 }
986 927
@@ -996,9 +937,8 @@
996 937
997 938 if ( isset( $sortable[ $column_key ] ) ) {
998 939 list( $orderby, $desc_first ) = $sortable[ $column_key ];
999 940
1000 - // phpcs:ignore Universal.Operators.StrictComparisons
1001 941 if ( $current_orderby == $orderby ) {
1002 942 // The sorted column. The `aria-sort` attribute must be set only on the sorted column.
1003 943 if ( 'asc' === $current_order ) {
1004 944 $order = 'desc';
@@ -1044,9 +984,9 @@
1044 984 $tag = 'cb' === $column_key ? 'td' : 'th';
1045 985 $scope = 'th' === $tag ? 'scope="col"' : '';
1046 986 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
1047 987
1048 - if ( $class ) {
988 + if ( ! empty( $class ) ) {
1049 989 $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
1050 990 }
1051 991
1052 992 if ( ! $this->has_min_items() && ! $with_id ) {
@@ -1060,27 +1000,21 @@
1060 1000 /**
1061 1001 * Display the table
1062 1002 *
1063 1003 * @since 2.0.18
1064 - *
1065 1004 * @param array $args
1066 - *
1067 - * @return void
1068 1005 */
1069 1006 public function display( $args = array() ) {
1070 1007 $singular = $this->_args['singular'];
1071 1008 $tbody_params = array();
1072 -
1073 1009 if ( $singular ) {
1074 1010 $tbody_params['data-wp-lists'] = 'list:' . $singular;
1075 1011 }
1076 -
1077 1012 if ( $this->should_display( $args, 'display-top-nav' ) ) {
1078 1013 $this->display_tablenav( 'top' );
1079 1014 }
1080 1015 $this->screen->render_screen_reader_content( 'heading_list' );
1081 1016
1082 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1083 1017 ?>
1084 1018 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1085 1019 <?php if ( $this->has_min_items( 1 ) ) { ?>
1086 1020 <thead>
@@ -1102,10 +1036,8 @@
1102 1036 </tfoot>
1103 1037 <?php } ?>
1104 1038 </table>
1105 1039 <?php
1106 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1107 -
1108 1040 if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1109 1041 $this->display_tablenav( 'bottom' );
1110 1042 }
1111 1043 }
@@ -1142,18 +1074,16 @@
1142 1074 */
1143 1075 protected function display_tablenav( $which ) {
1144 1076 if ( 'top' === $which ) {
1145 1077 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1146 -
1147 1078 if ( ! $this->has_min_items( 1 ) ) {
1148 1079 // Don't show bulk actions if no items.
1149 1080 return;
1150 1081 }
1151 1082 } elseif ( ! $this->has_min_items() ) {
1152 - // Don't show the bulk actions when there aren't many rows.
1083 + // don't show the bulk actions when there aren't many rows.
1153 1084 return;
1154 1085 }
1155 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1156 1086 ?>
1157 1087 <div class="tablenav <?php echo esc_attr( $which ); ?>">
1158 1088
1159 1089 <div class="alignleft actions bulkactions">
@@ -1166,9 +1096,8 @@
1166 1096
1167 1097 <br class="clear"/>
1168 1098 </div>
1169 1099 <?php
1170 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1171 1100 }
1172 1101
1173 1102 /**
1174 1103 * Use this to exclude the footer labels and bulk items.
@@ -1174,12 +1103,8 @@
1174 1103 * Use this to exclude the footer labels and bulk items.
1175 1104 * When close together, it feels like duplicates.
1176 1105 *
1177 1106 * @since 4.07
1178 - *
1179 - * @param int $limit
1180 - *
1181 - * @return bool
1182 1107 */
1183 1108 protected function has_min_items( $limit = 5 ) {
1184 1109 return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit );
1185 1110 }
@@ -1213,9 +1138,9 @@
1213 1138 * Generates content for a single row of the table
1214 1139 *
1215 1140 * @since 2.0.18
1216 1141 *
1217 - * @param stdClass $item The current item.
1142 + * @param object $item The current item.
1218 1143 */
1219 1144 public function single_row( $item ) {
1220 1145 echo '<tr>';
1221 1146 $this->single_row_columns( $item );
@@ -1233,14 +1158,12 @@
1233 1158 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1234 1159
1235 1160 foreach ( $columns as $column_name => $column_display_name ) {
1236 1161 $classes = "$column_name column-$column_name";
1237 -
1238 1162 if ( $primary === $column_name ) {
1239 1163 $classes .= ' has-row-actions column-primary';
1240 1164 }
1241 1165
1242 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1243 1166 if ( in_array( $column_name, $hidden ) ) {
1244 1167 $classes .= ' hidden';
1245 1168 }
1246 1169
@@ -1279,9 +1202,9 @@
1279 1202 *
1280 1203 * @return string The row actions output. In this case, an empty string.
1281 1204 */
1282 1205 protected function handle_row_actions( $item, $column_name, $primary ) {
1283 - 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>' : '';
1284 1207 }
1285 1208
1286 1209 /**
1287 1210 * Handle an incoming ajax request (called from admin-ajax.php)
@@ -1291,9 +1214,8 @@
1291 1214 public function ajax_response() {
1292 1215 $this->prepare_items();
1293 1216
1294 1217 ob_start();
1295 -
1296 1218 if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1297 1219 $this->display_rows();
1298 1220 } else {
1299 1221 $this->display_rows_or_placeholder();
@@ -1298,9 +1220,10 @@
1298 1220 } else {
1299 1221 $this->display_rows_or_placeholder();
1300 1222 }
1301 1223
1302 - $rows = ob_get_clean();
1224 + $rows = ob_get_clean();
1225 +
1303 1226 $response = array( 'rows' => $rows );
1304 1227
1305 1228 if ( isset( $this->_pagination_args['total_items'] ) ) {
1306 1229 $response['total_items_i18n'] = sprintf(
@@ -1308,9 +1231,8 @@
1308 1231 _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
1309 1232 number_format_i18n( $this->_pagination_args['total_items'] )
1310 1233 );
1311 1234 }
1312 -
1313 1235 if ( isset( $this->_pagination_args['total_pages'] ) ) {
1314 1236 $response['total_pages'] = $this->_pagination_args['total_pages'];
1315 1237 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1316 1238 }