PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.13
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.13
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 +82 -175 6.316.13 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
@@ -41,10 +37,9 @@
41 37 /**
42 38 * The current screen
43 39 *
44 40 * @since 2.0.18
45 - *
46 - * @var \WP_Screen
41 + * @var object
47 42 */
48 43 protected $screen;
49 44
50 45 /**
@@ -50,9 +45,8 @@
50 45 /**
51 46 * Cached bulk actions
52 47 *
53 48 * @since 2.0.18
54 - *
55 49 * @var array
56 50 */
57 51 private $_actions;
58 52
@@ -59,9 +53,8 @@
59 53 /**
60 54 * Cached pagination output
61 55 *
62 56 * @since 2.0.18
63 - *
64 57 * @var string
65 58 */
66 59 private $_pagination;
67 60
@@ -68,9 +61,8 @@
68 61 /**
69 62 * The view switcher modes.
70 63 *
71 64 * @since 2.0.18
72 - *
73 65 * @var array
74 66 */
75 67 protected $modes = array();
76 68
@@ -85,16 +77,10 @@
85 77 * @var array
86 78 */
87 79 protected $_column_headers;
88 80
89 - /**
90 - * @var array
91 - */
92 81 protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
93 82
94 - /**
95 - * @var array
96 - */
97 83 protected $compat_methods = array(
98 84 'set_pagination_args',
99 85 'get_views',
100 86 'get_bulk_actions',
@@ -112,12 +98,8 @@
112 98 );
113 99
114 100 /**
115 101 * Construct the table object
116 - *
117 - * @param array $args
118 - *
119 - * @return void
120 102 */
121 103 public function __construct( $args ) {
122 104 $args = wp_parse_args(
123 105 $args,
@@ -149,9 +131,9 @@
149 131 // wp_enqueue_script( 'list-table' );
150 132 add_action( 'admin_footer', array( $this, '_js_vars' ) );
151 133 }
152 134
153 - if ( ! $this->modes ) {
135 + if ( empty( $this->modes ) ) {
154 136 $this->modes = array(
155 137 'list' => __( 'List View', 'formidable' ),
156 138 'excerpt' => __( 'Excerpt View', 'formidable' ),
157 139 );
@@ -161,11 +143,8 @@
161 143 public function ajax_user_can() {
162 144 return current_user_can( 'administrator' );
163 145 }
164 146
165 - /**
166 - * @return array
167 - */
168 147 public function get_columns() {
169 148 return array();
170 149 }
171 150
@@ -180,9 +159,8 @@
180 159 *
181 160 * @uses FrmListHelper::set_pagination_args()
182 161 *
183 162 * @since 2.0.18
184 - *
185 163 * @abstract
186 164 */
187 165 public function prepare_items() {
188 166 die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' );
@@ -189,19 +167,15 @@
189 167 }
190 168
191 169 /**
192 170 * @since 3.0
193 - *
194 - * @param array $args
195 - *
196 - * @return array|string
197 171 */
198 172 protected function get_param( $args ) {
199 173 return FrmAppHelper::get_simple_request(
200 174 array(
201 175 'param' => $args['param'],
202 - 'default' => $args['default'] ?? '',
203 - 'sanitize' => $args['sanitize'] ?? 'sanitize_title',
176 + 'default' => isset( $args['default'] ) ? $args['default'] : '',
177 + 'sanitize' => isset( $args['sanitize'] ) ? $args['sanitize'] : 'sanitize_title',
204 178 'type' => 'request',
205 179 )
206 180 );
207 181 }
@@ -225,17 +199,10 @@
225 199 $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
226 200 }
227 201
228 202 // 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 );
203 + if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
204 + wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
238 205 exit;
239 206 }
240 207
241 208 $this->_pagination_args = $args;
@@ -251,13 +218,15 @@
251 218 *
252 219 * @return int Number of items that correspond to the given pagination argument.
253 220 */
254 221 public function get_pagination_arg( $key ) {
255 - if ( 'page' === $key ) {
222 + if ( 'page' == $key ) {
256 223 return $this->get_pagenum();
257 224 }
258 225
259 - return $this->_pagination_args[ $key ] ?? null;
226 + if ( isset( $this->_pagination_args[ $key ] ) ) {
227 + return $this->_pagination_args[ $key ];
228 + }
260 229 }
261 230
262 231 /**
263 232 * Whether the table has items to display or not
@@ -298,20 +267,13 @@
298 267
299 268 FrmAppHelper::show_search_box( compact( 'text', 'input_id' ) );
300 269 }
301 270
302 - /**
303 - * @param string $param_name
304 - *
305 - * @return void
306 - */
307 271 private function hidden_search_inputs( $param_name ) {
308 - if ( empty( $_REQUEST[ $param_name ] ) ) {
309 - return;
272 + if ( ! empty( $_REQUEST[ $param_name ] ) ) {
273 + $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
274 + echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
310 275 }
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 276 }
315 277
316 278 /**
317 279 * Get an associative array ( id => link ) with the list
@@ -343,14 +305,13 @@
343 305 * @param array $views An array of available list table views.
344 306 */
345 307 $views = apply_filters( 'views_' . $this->screen->id, $views );
346 308
347 - if ( ! $views ) {
309 + if ( empty( $views ) ) {
348 310 return;
349 311 }
350 312
351 313 echo "<ul class='subsubsub'>\n";
352 -
353 314 foreach ( $views as $class => $view ) {
354 315 $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
355 316 }
356 317 echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -401,9 +362,9 @@
401 362 } else {
402 363 $two = '2';
403 364 }//end if
404 365
405 - if ( ! $this->_actions ) {
366 + if ( empty( $this->_actions ) ) {
406 367 return;
407 368 }
408 369
409 370 echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>';
@@ -413,9 +374,8 @@
413 374 foreach ( $this->_actions as $name => $title ) {
414 375 $params = array(
415 376 'value' => $name,
416 377 );
417 -
418 378 if ( 'edit' === $name ) {
419 379 $params['class'] = 'hide-if-no-js';
420 380 }
421 381
@@ -429,21 +389,9 @@
429 389 if ( isset( $this->_actions['bulk_delete'] ) ) {
430 390 $verify = $this->confirm_bulk_delete();
431 391
432 392 if ( $verify ) {
433 - $confirm_delete_attributes = array(
434 - 'id' => 'confirm-bulk-delete-' . $which,
435 - 'class' => 'frm-hidden',
436 - 'tabindex' => '-1',
437 - 'aria-hidden' => 'true',
438 - 'href' => 'confirm-bulk-delete',
439 - 'data-loaded-from' => $this->loaded_from(),
440 - 'data-frmverify' => $verify,
441 - 'data-frmverify-btn' => 'frm-button-red',
442 - );
443 -
444 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
445 - echo '<a ' . FrmAppHelper::array_to_html_params( $confirm_delete_attributes ) . '></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>";
446 394 }
447 395 }
448 396
449 397 submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
@@ -469,17 +417,15 @@
469 417 return false;
470 418 }
471 419
472 420 $action = $this->get_bulk_action( 'action' );
421 + if ( $action === false ) {
422 + $action = $this->get_bulk_action( 'action2' );
423 + }
473 424
474 - return $action === false ? $this->get_bulk_action( 'action2' ) : $action;
425 + return $action;
475 426 }
476 427
477 - /**
478 - * @param string $action_name
479 - *
480 - * @return false|string
481 - */
482 428 private function get_bulk_action( $action_name ) {
483 429 $action = false;
484 430 $action_param = $this->get_param(
485 431 array(
@@ -486,12 +432,10 @@
486 432 'param' => $action_name,
487 433 'sanitize' => 'sanitize_text_field',
488 434 )
489 435 );
490 -
491 - // phpcs:ignore Universal.Operators.StrictComparisons
492 436 if ( $action_param && - 1 != $action_param ) {
493 - return $action_param;
437 + $action = $action_param;
494 438 }
495 439
496 440 return $action;
497 441 }
@@ -508,24 +452,25 @@
508 452 */
509 453 protected function row_actions( $actions, $always_visible = false ) {
510 454 $action_count = count( $actions );
511 455
456 + $i = 0;
457 +
512 458 if ( ! $action_count ) {
513 459 return '';
514 460 }
515 461
516 - $i = 0;
517 462 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
518 -
519 463 foreach ( $actions as $action => $link ) {
520 464 ++$i;
521 - $sep = $i === $action_count ? '' : ' | ';
465 + $sep = $i == $action_count ? '' : ' | ';
522 466 $out .= "<span class='$action'>$link$sep</span>";
523 467 }
468 + $out .= '</div>';
524 469
525 - $out .= '</div>';
470 + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
526 471
527 - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' );
472 + return $out;
528 473 }
529 474
530 475 /**
531 476 * Display a view switcher
@@ -534,9 +479,8 @@
534 479 *
535 480 * @param string $current_mode
536 481 */
537 482 protected function view_switcher( $current_mode ) {
538 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
539 483 ?>
540 484 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/>
541 485 <div class="view-switch">
542 486 <?php
@@ -541,10 +485,9 @@
541 485 <div class="view-switch">
542 486 <?php
543 487 foreach ( $this->modes as $mode => $title ) {
544 488 $classes = array( 'view-' . $mode );
545 -
546 - if ( $current_mode === $mode ) {
489 + if ( $current_mode == $mode ) {
547 490 $classes[] = 'current';
548 491 }
549 492
550 493 printf(
@@ -556,9 +499,8 @@
556 499 }
557 500 ?>
558 501 </div>
559 502 <?php
560 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
561 503 }
562 504
563 505 /**
564 506 * Get the current page number
@@ -588,10 +530,9 @@
588 530 * @return int
589 531 */
590 532 protected function get_items_per_page( $option, $default = 20 ) {
591 533 $per_page = (int) get_user_option( $option );
592 -
593 - if ( ! $per_page || $per_page < 1 ) {
534 + if ( empty( $per_page ) || $per_page < 1 ) {
594 535 $per_page = $default;
595 536 }
596 537
597 538 /**
@@ -617,9 +558,9 @@
617 558 *
618 559 * @param string $which
619 560 */
620 561 protected function pagination( $which ) {
621 - if ( ! $this->_pagination_args ) {
562 + if ( empty( $this->_pagination_args ) ) {
622 563 return;
623 564 }
624 565
625 566 $total_items = $this->_pagination_args['total_items'];
@@ -624,9 +565,8 @@
624 565
625 566 $total_items = $this->_pagination_args['total_items'];
626 567 $total_pages = $this->_pagination_args['total_pages'];
627 568 $infinite_scroll = false;
628 -
629 569 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
630 570 $infinite_scroll = $this->_pagination_args['infinite_scroll'];
631 571 }
632 572
@@ -632,14 +572,17 @@
632 572
633 573 /* translators: %s: Number of items */
634 574 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
635 575
636 - $current = $this->get_pagenum();
637 - $page_links = array();
576 + $current = $this->get_pagenum();
577 +
578 + $page_links = array();
579 +
638 580 $total_pages_before = '<span class="paging-input">';
639 581 $total_pages_after = '</span>';
640 - $disable = $this->disabled_pages( $total_pages );
641 582
583 + $disable = $this->disabled_pages( $total_pages );
584 +
642 585 $page_links[] = $this->add_page_link(
643 586 array(
644 587 'page' => 'first',
645 588 'arrow' => '&laquo;',
@@ -656,20 +599,19 @@
656 599 'disabled' => $disable['prev'],
657 600 )
658 601 );
659 602
660 - if ( 'bottom' === $which ) {
603 + if ( 'bottom' == $which ) {
661 604 $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">';
605 + $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
663 606 } else {
664 607 $html_current_page = sprintf(
665 608 "%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>',
609 + '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>',
667 610 $current,
668 611 strlen( $total_pages )
669 612 );
670 613 }
671 -
672 614 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
673 615
674 616 /* translators: %1$s: Current page number, %2$s: Total pages */
675 617 $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 +634,11 @@
692 634 )
693 635 );
694 636
695 637 $pagination_links_class = 'pagination-links';
696 -
697 - if ( $infinite_scroll ) {
638 + if ( ! empty( $infinite_scroll ) ) {
698 639 $pagination_links_class = ' hide-if-js';
699 640 }
700 -
701 641 $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
702 642
703 643 if ( $total_pages ) {
704 644 $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -709,13 +649,8 @@
709 649
710 650 echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
711 651 }
712 652
713 - /**
714 - * @param int $total_pages
715 - *
716 - * @return array
717 - */
718 653 private function disabled_pages( $total_pages ) {
719 654 $current = $this->get_pagenum();
720 655 $disable = array(
721 656 'first' => false,
@@ -723,21 +658,19 @@
723 658 'prev' => false,
724 659 'next' => false,
725 660 );
726 661
727 - // phpcs:ignore Universal.Operators.StrictComparisons
728 662 if ( $current == 1 ) {
729 663 $disable['first'] = true;
730 664 $disable['prev'] = true;
731 - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons
665 + } elseif ( $current == 2 ) {
732 666 $disable['first'] = true;
733 667 }
734 668
735 - // phpcs:ignore Universal.Operators.StrictComparisons
736 669 if ( $current == $total_pages ) {
737 670 $disable['last'] = true;
738 671 $disable['next'] = true;
739 - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons
672 + } elseif ( $current == $total_pages - 1 ) {
740 673 $disable['last'] = true;
741 674 }
742 675
743 676 return $disable;
@@ -742,13 +675,8 @@
742 675
743 676 return $disable;
744 677 }
745 678
746 - /**
747 - * @param string $link
748 - *
749 - * @return string
750 - */
751 679 private function link_label( $link ) {
752 680 $labels = array(
753 681 'first' => __( 'First page', 'formidable' ),
754 682 'last' => __( 'Last page', 'formidable' ),
@@ -760,34 +688,26 @@
760 688 }
761 689
762 690 private function current_url() {
763 691 $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
692 +
764 693 return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
765 694 }
766 695
767 - /**
768 - * @param array $atts
769 - *
770 - * @return string
771 - */
772 696 private function add_page_link( $atts ) {
773 - return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts );
697 + if ( $atts['disabled'] ) {
698 + $link = $this->add_disabled_link( $atts['arrow'] );
699 + } else {
700 + $link = $this->add_active_link( $atts );
701 + }
702 +
703 + return $link;
774 704 }
775 705
776 - /**
777 - * @param string $label
778 - *
779 - * @return string
780 - */
781 706 private function add_disabled_link( $label ) {
782 707 return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>';
783 708 }
784 709
785 - /**
786 - * @param array $atts
787 - *
788 - * @return string
789 - */
790 710 private function add_active_link( $atts ) {
791 711 $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) );
792 712 $label = $this->link_label( $atts['page'] );
793 713
@@ -823,13 +743,14 @@
823 743 *
824 744 * @return string Name of the default primary column, in this case, an empty string.
825 745 */
826 746 protected function get_default_primary_column_name() {
827 - $column = '';
747 + $columns = $this->get_columns();
748 + $column = '';
828 749
829 750 // 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 ) {
751 + // so let's fall back to the first non-checkbox column.
752 + foreach ( $columns as $col => $column_name ) {
832 753 if ( 'cb' === $col ) {
833 754 continue;
834 755 }
835 756
@@ -851,9 +772,9 @@
851 772 $columns = $this->get_columns();
852 773 $default = $this->get_default_primary_column_name();
853 774
854 775 // If the primary column doesn't exist fall back to the
855 - // First non-checkbox column.
776 + // first non-checkbox column.
856 777 if ( ! isset( $columns[ $default ] ) ) {
857 778 $default = self::get_default_primary_column_name();
858 779 }
859 780
@@ -866,10 +787,10 @@
866 787 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
867 788 */
868 789 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
869 790
870 - if ( ! $column || ! isset( $columns[ $column ] ) ) {
871 - return $default;
791 + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
792 + $column = $default;
872 793 }
873 794
874 795 return $column;
875 796 }
@@ -886,9 +807,8 @@
886 807 if ( is_array( $this->_column_headers ) ) {
887 808 // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
888 809 // In 4.3, we added a fourth argument for primary column.
889 810 $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
890 -
891 811 foreach ( $this->_column_headers as $key => $value ) {
892 812 $column_headers[ $key ] = $value;
893 813 }
894 814
@@ -896,8 +816,10 @@
896 816 }
897 817
898 818 $columns = get_column_headers( $this->screen );
899 819 $hidden = get_hidden_columns( $this->screen );
820 +
821 + $sortable_columns = $this->get_sortable_columns();
900 822 /**
901 823 * Filter the list table sortable columns for a specific screen.
902 824 *
903 825 * The dynamic portion of the hook name, `$this->screen->id`, refers
@@ -906,19 +828,17 @@
906 828 * @since 3.5.0
907 829 *
908 830 * @param array $sortable_columns An array of sortable columns.
909 831 */
910 - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
832 + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
911 833
912 834 $sortable = array();
913 -
914 835 foreach ( $_sortable as $id => $data ) {
915 - if ( ! $data ) {
836 + if ( empty( $data ) ) {
916 837 continue;
917 838 }
918 839
919 840 $data = (array) $data;
920 -
921 841 if ( ! isset( $data[1] ) ) {
922 842 $data[1] = false;
923 843 }
924 844
@@ -953,24 +873,31 @@
953 873 *
954 874 * @staticvar int $cb_counter
955 875 *
956 876 * @param bool $with_id Whether to set the id attribute or not.
957 - *
958 877 * @return void
959 878 */
960 - public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Files.LineLength.LineTooLong
879 + public function print_column_headers( $with_id = true ) {
961 880 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
962 881
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';
882 + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
883 + $current_url = remove_query_arg( 'paged', $current_url );
967 884
968 - FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
885 + if ( isset( $_GET['orderby'] ) ) {
886 + $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
887 + } else {
888 + $current_orderby = '';
889 + }
969 890
891 + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
892 + $current_order = 'desc';
893 + } else {
894 + $current_order = 'asc';
895 + }
896 +
970 897 if ( ! empty( $columns['cb'] ) ) {
971 898 static $cb_counter = 1;
972 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . esc_html__( 'Select All', 'formidable' ) . '</label>';
899 + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
973 900 $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
974 901 ++$cb_counter;
975 902 }
976 903
@@ -978,9 +905,8 @@
978 905 $class = array( 'manage-column', "column-$column_key" );
979 906 $aria_sort_attr = '';
980 907 $order_text = '';
981 908
982 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
983 909 if ( in_array( $column_key, $hidden ) ) {
984 910 $class[] = 'hidden';
985 911 }
986 912
@@ -996,9 +922,8 @@
996 922
997 923 if ( isset( $sortable[ $column_key ] ) ) {
998 924 list( $orderby, $desc_first ) = $sortable[ $column_key ];
999 925
1000 - // phpcs:ignore Universal.Operators.StrictComparisons
1001 926 if ( $current_orderby == $orderby ) {
1002 927 // The sorted column. The `aria-sort` attribute must be set only on the sorted column.
1003 928 if ( 'asc' === $current_order ) {
1004 929 $order = 'desc';
@@ -1044,9 +969,9 @@
1044 969 $tag = 'cb' === $column_key ? 'td' : 'th';
1045 970 $scope = 'th' === $tag ? 'scope="col"' : '';
1046 971 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
1047 972
1048 - if ( $class ) {
973 + if ( ! empty( $class ) ) {
1049 974 $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
1050 975 }
1051 976
1052 977 if ( ! $this->has_min_items() && ! $with_id ) {
@@ -1060,27 +985,21 @@
1060 985 /**
1061 986 * Display the table
1062 987 *
1063 988 * @since 2.0.18
1064 - *
1065 989 * @param array $args
1066 - *
1067 - * @return void
1068 990 */
1069 991 public function display( $args = array() ) {
1070 992 $singular = $this->_args['singular'];
1071 993 $tbody_params = array();
1072 -
1073 994 if ( $singular ) {
1074 995 $tbody_params['data-wp-lists'] = 'list:' . $singular;
1075 996 }
1076 -
1077 997 if ( $this->should_display( $args, 'display-top-nav' ) ) {
1078 998 $this->display_tablenav( 'top' );
1079 999 }
1080 1000 $this->screen->render_screen_reader_content( 'heading_list' );
1081 1001
1082 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1083 1002 ?>
1084 1003 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1085 1004 <?php if ( $this->has_min_items( 1 ) ) { ?>
1086 1005 <thead>
@@ -1102,10 +1021,8 @@
1102 1021 </tfoot>
1103 1022 <?php } ?>
1104 1023 </table>
1105 1024 <?php
1106 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1107 -
1108 1025 if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1109 1026 $this->display_tablenav( 'bottom' );
1110 1027 }
1111 1028 }
@@ -1142,18 +1059,16 @@
1142 1059 */
1143 1060 protected function display_tablenav( $which ) {
1144 1061 if ( 'top' === $which ) {
1145 1062 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1146 -
1147 1063 if ( ! $this->has_min_items( 1 ) ) {
1148 1064 // Don't show bulk actions if no items.
1149 1065 return;
1150 1066 }
1151 1067 } elseif ( ! $this->has_min_items() ) {
1152 - // Don't show the bulk actions when there aren't many rows.
1068 + // don't show the bulk actions when there aren't many rows.
1153 1069 return;
1154 1070 }
1155 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1156 1071 ?>
1157 1072 <div class="tablenav <?php echo esc_attr( $which ); ?>">
1158 1073
1159 1074 <div class="alignleft actions bulkactions">
@@ -1166,9 +1081,8 @@
1166 1081
1167 1082 <br class="clear"/>
1168 1083 </div>
1169 1084 <?php
1170 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1171 1085 }
1172 1086
1173 1087 /**
1174 1088 * Use this to exclude the footer labels and bulk items.
@@ -1174,12 +1088,8 @@
1174 1088 * Use this to exclude the footer labels and bulk items.
1175 1089 * When close together, it feels like duplicates.
1176 1090 *
1177 1091 * @since 4.07
1178 - *
1179 - * @param int $limit
1180 - *
1181 - * @return bool
1182 1092 */
1183 1093 protected function has_min_items( $limit = 5 ) {
1184 1094 return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit );
1185 1095 }
@@ -1213,9 +1123,9 @@
1213 1123 * Generates content for a single row of the table
1214 1124 *
1215 1125 * @since 2.0.18
1216 1126 *
1217 - * @param stdClass $item The current item.
1127 + * @param object $item The current item.
1218 1128 */
1219 1129 public function single_row( $item ) {
1220 1130 echo '<tr>';
1221 1131 $this->single_row_columns( $item );
@@ -1233,14 +1143,12 @@
1233 1143 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1234 1144
1235 1145 foreach ( $columns as $column_name => $column_display_name ) {
1236 1146 $classes = "$column_name column-$column_name";
1237 -
1238 1147 if ( $primary === $column_name ) {
1239 1148 $classes .= ' has-row-actions column-primary';
1240 1149 }
1241 1150
1242 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1243 1151 if ( in_array( $column_name, $hidden ) ) {
1244 1152 $classes .= ' hidden';
1245 1153 }
1246 1154
@@ -1279,9 +1187,9 @@
1279 1187 *
1280 1188 * @return string The row actions output. In this case, an empty string.
1281 1189 */
1282 1190 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
1191 + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : '';
1284 1192 }
1285 1193
1286 1194 /**
1287 1195 * Handle an incoming ajax request (called from admin-ajax.php)
@@ -1291,9 +1199,8 @@
1291 1199 public function ajax_response() {
1292 1200 $this->prepare_items();
1293 1201
1294 1202 ob_start();
1295 -
1296 1203 if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1297 1204 $this->display_rows();
1298 1205 } else {
1299 1206 $this->display_rows_or_placeholder();
@@ -1298,9 +1205,10 @@
1298 1205 } else {
1299 1206 $this->display_rows_or_placeholder();
1300 1207 }
1301 1208
1302 - $rows = ob_get_clean();
1209 + $rows = ob_get_clean();
1210 +
1303 1211 $response = array( 'rows' => $rows );
1304 1212
1305 1213 if ( isset( $this->_pagination_args['total_items'] ) ) {
1306 1214 $response['total_items_i18n'] = sprintf(
@@ -1308,9 +1216,8 @@
1308 1216 _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
1309 1217 number_format_i18n( $this->_pagination_args['total_items'] )
1310 1218 );
1311 1219 }
1312 -
1313 1220 if ( isset( $this->_pagination_args['total_pages'] ) ) {
1314 1221 $response['total_pages'] = $this->_pagination_args['total_pages'];
1315 1222 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1316 1223 }