PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 +122 -215 6.27 → 6.7.2 View file →
@@ -7,17 +7,16 @@
7 7 /**
8 8 * The current list of items
9 9 *
10 10 * @since 2.0.18
11 - *
12 11 * @var array
12 + * @access public
13 13 */
14 14 public $items;
15 15
16 16 /**
17 17 * @since 4.07
18 - *
19 - * @var bool|int
18 + * @var int|bool
20 19 */
21 20 public $total_items = false;
22 21
23 22 /**
@@ -23,10 +22,10 @@
23 22 /**
24 23 * Various information about the current table
25 24 *
26 25 * @since 2.0.18
27 - *
28 26 * @var array
27 + * @access protected
29 28 */
30 29 protected $_args;
31 30
32 31 /**
@@ -32,9 +31,8 @@
32 31 /**
33 32 * Various information needed for displaying the pagination
34 33 *
35 34 * @since 2.0.18
36 - *
37 35 * @var array
38 36 */
39 37 protected $_pagination_args = array();
40 38
@@ -41,10 +39,10 @@
41 39 /**
42 40 * The current screen
43 41 *
44 42 * @since 2.0.18
45 - *
46 - * @var \WP_Screen
43 + * @var object
44 + * @access protected
47 45 */
48 46 protected $screen;
49 47
50 48 /**
@@ -50,10 +48,10 @@
50 48 /**
51 49 * Cached bulk actions
52 50 *
53 51 * @since 2.0.18
54 - *
55 52 * @var array
53 + * @access private
56 54 */
57 55 private $_actions;
58 56
59 57 /**
@@ -59,10 +57,10 @@
59 57 /**
60 58 * Cached pagination output
61 59 *
62 60 * @since 2.0.18
63 - *
64 61 * @var string
62 + * @access private
65 63 */
66 64 private $_pagination;
67 65
68 66 /**
@@ -68,14 +66,15 @@
68 66 /**
69 67 * The view switcher modes.
70 68 *
71 69 * @since 2.0.18
72 - *
73 70 * @var array
71 + * @access protected
74 72 */
75 73 protected $modes = array();
76 74
77 75 /**
76 + *
78 77 * @var array
79 78 */
80 79 protected $params;
81 80
@@ -85,16 +84,10 @@
85 84 * @var array
86 85 */
87 86 protected $_column_headers;
88 87
89 - /**
90 - * @var array
91 - */
92 88 protected $compat_fields = array( '_args', '_pagination_args', 'screen', '_actions', '_pagination' );
93 89
94 - /**
95 - * @var array
96 - */
97 90 protected $compat_methods = array(
98 91 'set_pagination_args',
99 92 'get_views',
100 93 'get_bulk_actions',
@@ -112,12 +105,8 @@
112 105 );
113 106
114 107 /**
115 108 * Construct the table object
116 - *
117 - * @param array $args
118 - *
119 - * @return void
120 109 */
121 110 public function __construct( $args ) {
122 111 $args = wp_parse_args(
123 112 $args,
@@ -149,9 +138,9 @@
149 138 // wp_enqueue_script( 'list-table' );
150 139 add_action( 'admin_footer', array( $this, '_js_vars' ) );
151 140 }
152 141
153 - if ( ! $this->modes ) {
142 + if ( empty( $this->modes ) ) {
154 143 $this->modes = array(
155 144 'list' => __( 'List View', 'formidable' ),
156 145 'excerpt' => __( 'Excerpt View', 'formidable' ),
157 146 );
@@ -177,9 +166,9 @@
177 166 *
178 167 * @uses FrmListHelper::set_pagination_args()
179 168 *
180 169 * @since 2.0.18
181 - *
170 + * @access public
182 171 * @abstract
183 172 */
184 173 public function prepare_items() {
185 174 die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' );
@@ -186,19 +175,15 @@
186 175 }
187 176
188 177 /**
189 178 * @since 3.0
190 - *
191 - * @param array $args
192 - *
193 - * @return array|string
194 179 */
195 180 protected function get_param( $args ) {
196 181 return FrmAppHelper::get_simple_request(
197 182 array(
198 183 'param' => $args['param'],
199 - 'default' => $args['default'] ?? '',
200 - 'sanitize' => $args['sanitize'] ?? 'sanitize_title',
184 + 'default' => isset( $args['default'] ) ? $args['default'] : '',
185 + 'sanitize' => isset( $args['sanitize'] ) ? $args['sanitize'] : 'sanitize_title',
201 186 'type' => 'request',
202 187 )
203 188 );
204 189 }
@@ -206,8 +191,10 @@
206 191 /**
207 192 * An internal method that sets all the necessary pagination arguments
208 193 *
209 194 * @param array $args An associative array with information about the pagination.
195 + *
196 + * @access protected
210 197 */
211 198 protected function set_pagination_args( $args ) {
212 199 $args = wp_parse_args(
213 200 $args,
@@ -234,8 +221,9 @@
234 221 /**
235 222 * Access the pagination args.
236 223 *
237 224 * @since 2.0.18
225 + * @access public
238 226 *
239 227 * @param string $key Pagination argument to retrieve. Common values include 'total_items',
240 228 * 'total_pages', 'per_page', or 'infinite_scroll'.
241 229 *
@@ -241,13 +229,15 @@
241 229 *
242 230 * @return int Number of items that correspond to the given pagination argument.
243 231 */
244 232 public function get_pagination_arg( $key ) {
245 - if ( 'page' === $key ) {
233 + if ( 'page' == $key ) {
246 234 return $this->get_pagenum();
247 235 }
248 236
249 - return $this->_pagination_args[ $key ] ?? null;
237 + if ( isset( $this->_pagination_args[ $key ] ) ) {
238 + return $this->_pagination_args[ $key ];
239 + }
250 240 }
251 241
252 242 /**
253 243 * Whether the table has items to display or not
@@ -252,8 +242,9 @@
252 242 /**
253 243 * Whether the table has items to display or not
254 244 *
255 245 * @since 2.0.18
246 + * @access public
256 247 *
257 248 * @return bool
258 249 */
259 250 public function has_items() {
@@ -263,8 +254,9 @@
263 254 /**
264 255 * Message to be displayed when there are no items
265 256 *
266 257 * @since 2.0.18
258 + * @access public
267 259 */
268 260 public function no_items() {
269 261 esc_html_e( 'No items found.', 'formidable' );
270 262 }
@@ -272,8 +264,9 @@
272 264 /**
273 265 * Display the search box.
274 266 *
275 267 * @since 2.0.18
268 + * @access public
276 269 *
277 270 * @param string $text The search button text.
278 271 * @param string $input_id The search input id.
279 272 */
@@ -288,13 +281,8 @@
288 281
289 282 FrmAppHelper::show_search_box( compact( 'text', 'input_id' ) );
290 283 }
291 284
292 - /**
293 - * @param string $param_name
294 - *
295 - * @return void
296 - */
297 285 private function hidden_search_inputs( $param_name ) {
298 286 if ( ! empty( $_REQUEST[ $param_name ] ) ) {
299 287 $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
300 288 echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
@@ -305,8 +293,9 @@
305 293 * Get an associative array ( id => link ) with the list
306 294 * of views available on this table.
307 295 *
308 296 * @since 2.0.18
297 + * @access protected
309 298 *
310 299 * @return array
311 300 */
312 301 protected function get_views() {
@@ -316,8 +305,9 @@
316 305 /**
317 306 * Display the list of views available on this table.
318 307 *
319 308 * @since 2.0.18
309 + * @access public
320 310 */
321 311 public function views() {
322 312 $views = $this->get_views();
323 313 /**
@@ -331,14 +321,13 @@
331 321 * @param array $views An array of available list table views.
332 322 */
333 323 $views = apply_filters( 'views_' . $this->screen->id, $views );
334 324
335 - if ( ! $views ) {
325 + if ( empty( $views ) ) {
336 326 return;
337 327 }
338 328
339 329 echo "<ul class='subsubsub'>\n";
340 -
341 330 foreach ( $views as $class => $view ) {
342 331 $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
343 332 }
344 333 echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -349,8 +338,9 @@
349 338 * Get an associative array ( option_name => option_title ) with the list
350 339 * of bulk actions available on this table.
351 340 *
352 341 * @since 2.0.18
342 + * @access protected
353 343 *
354 344 * @return array
355 345 */
356 346 protected function get_bulk_actions() {
@@ -360,8 +350,9 @@
360 350 /**
361 351 * Display the bulk actions dropdown.
362 352 *
363 353 * @since 2.0.18
354 + * @access protected
364 355 *
365 356 * @param string $which The location of the bulk actions: 'top' or 'bottom'.
366 357 * This is designated as optional for backwards-compatibility.
367 358 */
@@ -393,17 +384,16 @@
393 384 if ( empty( $this->_actions ) ) {
394 385 return;
395 386 }
396 387
397 - echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>';
388 + echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_attr__( 'Select bulk action', 'formidable' ) . '</label>';
398 389 echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
399 - echo "<option value='-1' selected='selected'>" . esc_html__( 'Bulk Actions', 'formidable' ) . "</option>\n";
390 + echo "<option value='-1' selected='selected'>" . esc_attr__( 'Bulk Actions', 'formidable' ) . "</option>\n";
400 391
401 392 foreach ( $this->_actions as $name => $title ) {
402 393 $params = array(
403 394 'value' => $name,
404 395 );
405 -
406 396 if ( 'edit' === $name ) {
407 397 $params['class'] = 'hide-if-no-js';
408 398 }
409 399
@@ -417,21 +407,9 @@
417 407 if ( isset( $this->_actions['bulk_delete'] ) ) {
418 408 $verify = $this->confirm_bulk_delete();
419 409
420 410 if ( $verify ) {
421 - $confirm_delete_attributes = array(
422 - 'id' => 'confirm-bulk-delete-' . $which,
423 - 'class' => 'frm-hidden',
424 - 'tabindex' => '-1',
425 - 'aria-hidden' => 'true',
426 - 'href' => 'confirm-bulk-delete',
427 - 'data-loaded-from' => $this->loaded_from(),
428 - 'data-frmverify' => $verify,
429 - 'data-frmverify-btn' => 'frm-button-red',
430 - );
431 -
432 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
433 - echo '<a ' . FrmAppHelper::array_to_html_params( $confirm_delete_attributes ) . '></a>';
411 + 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>";
434 412 }
435 413 }
436 414
437 415 submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
@@ -448,18 +426,18 @@
448 426 /**
449 427 * Get the current action selected from the bulk actions dropdown.
450 428 *
451 429 * @since 2.0.18
430 + * @access public
452 431 *
453 - * @return false|string The action name or False if no action was selected
432 + * @return string|false The action name or False if no action was selected
454 433 */
455 434 public function current_action() {
456 - if ( ! empty( $_REQUEST['filter_action'] ) ) {
435 + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
457 436 return false;
458 437 }
459 438
460 439 $action = $this->get_bulk_action( 'action' );
461 -
462 440 if ( $action === false ) {
463 441 $action = $this->get_bulk_action( 'action2' );
464 442 }
465 443
@@ -465,13 +443,8 @@
465 443
466 444 return $action;
467 445 }
468 446
469 - /**
470 - * @param string $action_name
471 - *
472 - * @return false|string
473 - */
474 447 private function get_bulk_action( $action_name ) {
475 448 $action = false;
476 449 $action_param = $this->get_param(
477 450 array(
@@ -478,10 +451,8 @@
478 451 'param' => $action_name,
479 452 'sanitize' => 'sanitize_text_field',
480 453 )
481 454 );
482 -
483 - // phpcs:ignore Universal.Operators.StrictComparisons
484 455 if ( $action_param && - 1 != $action_param ) {
485 456 $action = $action_param;
486 457 }
487 458
@@ -491,8 +462,9 @@
491 462 /**
492 463 * Generate row actions div
493 464 *
494 465 * @since 2.0.18
466 + * @access protected
495 467 *
496 468 * @param array $actions The list of actions.
497 469 * @param bool $always_visible Whether the actions should be always visible.
498 470 *
@@ -499,25 +471,26 @@
499 471 * @return string
500 472 */
501 473 protected function row_actions( $actions, $always_visible = false ) {
502 474 $action_count = count( $actions );
503 - $i = 0;
504 475
476 + $i = 0;
477 +
505 478 if ( ! $action_count ) {
506 479 return '';
507 480 }
508 481
509 482 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
510 -
511 483 foreach ( $actions as $action => $link ) {
512 - ++$i;
513 - $sep = $i === $action_count ? '' : ' | ';
484 + ++ $i;
485 + ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
514 486 $out .= "<span class='$action'>$link$sep</span>";
515 487 }
488 + $out .= '</div>';
516 489
517 - $out .= '</div>';
490 + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
518 491
519 - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' );
492 + return $out;
520 493 }
521 494
522 495 /**
523 496 * Display a view switcher
@@ -522,8 +495,9 @@
522 495 /**
523 496 * Display a view switcher
524 497 *
525 498 * @since 2.0.18
499 + * @access protected
526 500 *
527 501 * @param string $current_mode
528 502 */
529 503 protected function view_switcher( $current_mode ) {
@@ -532,10 +506,8 @@
532 506 <div class="view-switch">
533 507 <?php
534 508 foreach ( $this->modes as $mode => $title ) {
535 509 $classes = array( 'view-' . $mode );
536 -
537 - // phpcs:ignore Universal.Operators.StrictComparisons
538 510 if ( $current_mode == $mode ) {
539 511 $classes[] = 'current';
540 512 }
541 513
@@ -554,8 +526,9 @@
554 526 /**
555 527 * Get the current page number
556 528 *
557 529 * @since 2.0.18
530 + * @access public
558 531 *
559 532 * @return int
560 533 */
561 534 public function get_pagenum() {
@@ -571,8 +544,9 @@
571 544 /**
572 545 * Get number of items to display on a single page
573 546 *
574 547 * @since 2.0.18
548 + * @access protected
575 549 *
576 550 * @param string $option
577 551 * @param int $default
578 552 *
@@ -579,10 +553,9 @@
579 553 * @return int
580 554 */
581 555 protected function get_items_per_page( $option, $default = 20 ) {
582 556 $per_page = (int) get_user_option( $option );
583 -
584 - if ( ! $per_page || $per_page < 1 ) {
557 + if ( empty( $per_page ) || $per_page < 1 ) {
585 558 $per_page = $default;
586 559 }
587 560
588 561 /**
@@ -604,8 +577,9 @@
604 577 /**
605 578 * Display the pagination.
606 579 *
607 580 * @since 2.0.18
581 + * @access protected
608 582 *
609 583 * @param string $which
610 584 */
611 585 protected function pagination( $which ) {
@@ -615,9 +589,8 @@
615 589
616 590 $total_items = $this->_pagination_args['total_items'];
617 591 $total_pages = $this->_pagination_args['total_pages'];
618 592 $infinite_scroll = false;
619 -
620 593 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
621 594 $infinite_scroll = $this->_pagination_args['infinite_scroll'];
622 595 }
623 596
@@ -623,14 +596,17 @@
623 596
624 597 /* translators: %s: Number of items */
625 598 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
626 599
627 - $current = $this->get_pagenum();
628 - $page_links = array();
600 + $current = $this->get_pagenum();
601 +
602 + $page_links = array();
603 +
629 604 $total_pages_before = '<span class="paging-input">';
630 605 $total_pages_after = '</span>';
631 - $disable = $this->disabled_pages( $total_pages );
632 606
607 + $disable = $this->disabled_pages( $total_pages );
608 +
633 609 $page_links[] = $this->add_page_link(
634 610 array(
635 611 'page' => 'first',
636 612 'arrow' => '&laquo;',
@@ -647,9 +623,9 @@
647 623 'disabled' => $disable['prev'],
648 624 )
649 625 );
650 626
651 - if ( 'bottom' === $which ) {
627 + if ( 'bottom' == $which ) {
652 628 $html_current_page = $current;
653 629 $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
654 630 } else {
655 631 $html_current_page = sprintf(
@@ -658,9 +634,8 @@
658 634 $current,
659 635 strlen( $total_pages )
660 636 );
661 637 }
662 -
663 638 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
664 639
665 640 /* translators: %1$s: Current page number, %2$s: Total pages */
666 641 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'formidable' ), $html_current_page, $html_total_pages ) . $total_pages_after;
@@ -683,15 +658,13 @@
683 658 )
684 659 );
685 660
686 661 $pagination_links_class = 'pagination-links';
687 -
688 - if ( $infinite_scroll ) {
662 + if ( ! empty( $infinite_scroll ) ) {
689 663 $pagination_links_class = ' hide-if-js';
690 664 }
665 + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>';
691 666
692 - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
693 -
694 667 if ( $total_pages ) {
695 668 $page_class = $total_pages < 2 ? ' one-page' : '';
696 669 } else {
697 670 $page_class = ' no-pages';
@@ -700,13 +673,8 @@
700 673
701 674 echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
702 675 }
703 676
704 - /**
705 - * @param int $total_pages
706 - *
707 - * @return array
708 - */
709 677 private function disabled_pages( $total_pages ) {
710 678 $current = $this->get_pagenum();
711 679 $disable = array(
712 680 'first' => false,
@@ -714,21 +682,19 @@
714 682 'prev' => false,
715 683 'next' => false,
716 684 );
717 685
718 - // phpcs:ignore Universal.Operators.StrictComparisons
719 686 if ( $current == 1 ) {
720 687 $disable['first'] = true;
721 688 $disable['prev'] = true;
722 - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons
689 + } elseif ( $current == 2 ) {
723 690 $disable['first'] = true;
724 691 }
725 692
726 - // phpcs:ignore Universal.Operators.StrictComparisons
727 693 if ( $current == $total_pages ) {
728 694 $disable['last'] = true;
729 695 $disable['next'] = true;
730 - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons
696 + } elseif ( $current == $total_pages - 1 ) {
731 697 $disable['last'] = true;
732 698 }
733 699
734 700 return $disable;
@@ -733,13 +699,8 @@
733 699
734 700 return $disable;
735 701 }
736 702
737 - /**
738 - * @param string $link
739 - *
740 - * @return string
741 - */
742 703 private function link_label( $link ) {
743 704 $labels = array(
744 705 'first' => __( 'First page', 'formidable' ),
745 706 'last' => __( 'Last page', 'formidable' ),
@@ -751,34 +712,26 @@
751 712 }
752 713
753 714 private function current_url() {
754 715 $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
716 +
755 717 return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
756 718 }
757 719
758 - /**
759 - * @param array $atts
760 - *
761 - * @return string
762 - */
763 720 private function add_page_link( $atts ) {
764 - return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts );
721 + if ( $atts['disabled'] ) {
722 + $link = $this->add_disabled_link( $atts['arrow'] );
723 + } else {
724 + $link = $this->add_active_link( $atts );
725 + }
726 +
727 + return $link;
765 728 }
766 729
767 - /**
768 - * @param string $label
769 - *
770 - * @return string
771 - */
772 730 private function add_disabled_link( $label ) {
773 731 return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>';
774 732 }
775 733
776 - /**
777 - * @param array $atts
778 - *
779 - * @return string
780 - */
781 734 private function add_active_link( $atts ) {
782 735 $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) );
783 736 $label = $this->link_label( $atts['page'] );
784 737
@@ -799,8 +752,9 @@
799 752 *
800 753 * The second format will make the initial sorting order be descending
801 754 *
802 755 * @since 2.0.18
756 + * @access protected
803 757 *
804 758 * @return array
805 759 */
806 760 protected function get_sortable_columns() {
@@ -810,8 +764,9 @@
810 764 /**
811 765 * Gets the name of the default primary column.
812 766 *
813 767 * @since 4.3.0
768 + * @access protected
814 769 *
815 770 * @return string Name of the default primary column, in this case, an empty string.
816 771 */
817 772 protected function get_default_primary_column_name() {
@@ -835,8 +790,9 @@
835 790 /**
836 791 * Gets the name of the primary column.
837 792 *
838 793 * @since 4.3.0
794 + * @access protected
839 795 *
840 796 * @return string The name of the primary column.
841 797 */
842 798 protected function get_primary_column_name() {
@@ -858,9 +814,9 @@
858 814 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
859 815 */
860 816 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
861 817
862 - if ( ! $column || ! isset( $columns[ $column ] ) ) {
818 + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
863 819 $column = $default;
864 820 }
865 821
866 822 return $column;
@@ -869,8 +825,9 @@
869 825 /**
870 826 * Get a list of all, hidden and sortable columns, with filter applied
871 827 *
872 828 * @since 2.0.18
829 + * @access protected
873 830 *
874 831 * @return array
875 832 */
876 833 protected function get_column_info() {
@@ -878,9 +835,8 @@
878 835 if ( is_array( $this->_column_headers ) ) {
879 836 // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
880 837 // In 4.3, we added a fourth argument for primary column.
881 838 $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
882 -
883 839 foreach ( $this->_column_headers as $key => $value ) {
884 840 $column_headers[ $key ] = $value;
885 841 }
886 842
@@ -886,10 +842,11 @@
886 842
887 843 return $column_headers;
888 844 }
889 845
890 - $columns = get_column_headers( $this->screen );
891 - $hidden = get_hidden_columns( $this->screen );
846 + $columns = get_column_headers( $this->screen );
847 + $hidden = get_hidden_columns( $this->screen );
848 +
892 849 $sortable_columns = $this->get_sortable_columns();
893 850 /**
894 851 * Filter the list table sortable columns for a specific screen.
895 852 *
@@ -902,9 +859,8 @@
902 859 */
903 860 $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
904 861
905 862 $sortable = array();
906 -
907 863 foreach ( $_sortable as $id => $data ) {
908 864 if ( empty( $data ) ) {
909 865 continue;
910 866 }
@@ -909,9 +865,8 @@
909 865 continue;
910 866 }
911 867
912 868 $data = (array) $data;
913 -
914 869 if ( ! isset( $data[1] ) ) {
915 870 $data[1] = false;
916 871 }
917 872
@@ -928,14 +883,15 @@
928 883 /**
929 884 * Return number of visible columns
930 885 *
931 886 * @since 2.0.18
887 + * @access public
932 888 *
933 889 * @return int
934 890 */
935 891 public function get_column_count() {
936 892 list ( $columns, $hidden ) = $this->get_column_info();
937 - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
893 + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
938 894
939 895 return count( $columns ) - count( $hidden );
940 896 }
941 897
@@ -942,45 +898,49 @@
942 898 /**
943 899 * Print column headers, accounting for hidden and sortable columns.
944 900 *
945 901 * @since 2.0.18
902 + * @access public
946 903 *
947 904 * @staticvar int $cb_counter
948 905 *
949 906 * @param bool $with_id Whether to set the id attribute or not.
950 - *
951 - * @return void
952 907 */
953 - public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Files.LineLength.LineTooLong
908 + public function print_column_headers( $with_id = true ) {
954 909 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
955 910
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';
911 + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
912 + $current_url = remove_query_arg( 'paged', $current_url );
960 913
961 - FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
914 + if ( isset( $_GET['orderby'] ) ) {
915 + $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
916 + } else {
917 + $current_orderby = '';
918 + }
962 919
920 + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
921 + $current_order = 'desc';
922 + } else {
923 + $current_order = 'asc';
924 + }
925 +
963 926 if ( ! empty( $columns['cb'] ) ) {
964 927 static $cb_counter = 1;
965 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
966 - $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
967 - ++$cb_counter;
928 + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
929 + $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
930 + $cb_counter ++;
968 931 }
969 932
970 933 foreach ( $columns as $column_key => $column_display_name ) {
971 - $class = array( 'manage-column', "column-$column_key" );
972 - $aria_sort_attr = '';
973 - $order_text = '';
934 + $class = array( 'manage-column', "column-$column_key" );
974 935
975 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
976 936 if ( in_array( $column_key, $hidden ) ) {
977 937 $class[] = 'hidden';
978 938 }
979 939
980 - if ( 'cb' === $column_key ) {
940 + if ( 'cb' == $column_key ) {
981 941 $class[] = 'check-column';
982 - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
942 + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
983 943 $class[] = 'num';
984 944 }
985 945
986 946 if ( $column_key === $primary || $column_key === 'name' ) {
@@ -989,19 +949,10 @@
989 949
990 950 if ( isset( $sortable[ $column_key ] ) ) {
991 951 list( $orderby, $desc_first ) = $sortable[ $column_key ];
992 952
993 - // phpcs:ignore Universal.Operators.StrictComparisons
994 953 if ( $current_orderby == $orderby ) {
995 - // The sorted column. The `aria-sort` attribute must be set only on the sorted column.
996 - if ( 'asc' === $current_order ) {
997 - $order = 'desc';
998 - $aria_sort_attr = ' aria-sort="ascending"';
999 - } else {
1000 - $order = 'asc';
1001 - $aria_sort_attr = ' aria-sort="descending"';
1002 - }
1003 -
954 + $order = 'asc' == $current_order ? 'desc' : 'asc';
1004 955 $class[] = 'sorted';
1005 956 $class[] = $current_order;
1006 957 } else {
1007 958 $order = $desc_first ? 'desc' : 'asc';
@@ -1006,41 +957,19 @@
1006 957 } else {
1007 958 $order = $desc_first ? 'desc' : 'asc';
1008 959 $class[] = 'sortable';
1009 960 $class[] = $desc_first ? 'asc' : 'desc';
1010 -
1011 - /* translators: Hidden accessibility text. */
1012 - $asc_text = __( 'Sort ascending.', 'formidable' );
1013 - /* translators: Hidden accessibility text. */
1014 - $desc_text = __( 'Sort descending.', 'formidable' );
1015 - $order_text = 'asc' === $order ? $asc_text : $desc_text;
1016 - }//end if
1017 -
1018 - if ( '' !== $order_text ) {
1019 - $order_text = ' <span class="screen-reader-text">' . $order_text . '</span>';
1020 961 }
1021 962
1022 - $column_display_name = sprintf(
1023 - '<a href="%1$s">' .
1024 - '<span>%2$s</span>' .
1025 - '<span class="sorting-indicators">' .
1026 - '<span class="sorting-indicator asc" aria-hidden="true"></span>' .
1027 - '<span class="sorting-indicator desc" aria-hidden="true"></span>' .
1028 - '</span>' .
1029 - '%3$s' .
1030 - '</a>',
1031 - esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
1032 - $column_display_name,
1033 - $order_text
1034 - );
1035 - }//end if
963 + $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>';
964 + }
1036 965
1037 - $tag = 'cb' === $column_key ? 'td' : 'th';
1038 - $scope = 'th' === $tag ? 'scope="col"' : '';
966 + $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
967 + $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1039 968 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
1040 969
1041 - if ( $class ) {
1042 - $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
970 + if ( ! empty( $class ) ) {
971 + $class = "class='" . esc_attr( join( ' ', $class ) ) . "'";
1043 972 }
1044 973
1045 974 if ( ! $this->has_min_items() && ! $with_id ) {
1046 975 // Hide the labels but show the border.
@@ -1045,9 +974,9 @@
1045 974 if ( ! $this->has_min_items() && ! $with_id ) {
1046 975 // Hide the labels but show the border.
1047 976 $column_display_name = '';
1048 977 }
1049 - echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
978 + echo "<$tag $scope $id $class>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1050 979 }//end foreach
1051 980 }
1052 981
1053 982 /**
@@ -1053,26 +982,18 @@
1053 982 /**
1054 983 * Display the table
1055 984 *
1056 985 * @since 2.0.18
1057 - *
1058 - * @param array $args
1059 - *
1060 - * @return void
986 + * @access public
1061 987 */
1062 - public function display( $args = array() ) {
988 + public function display() {
1063 989 $singular = $this->_args['singular'];
1064 990 $tbody_params = array();
1065 -
1066 991 if ( $singular ) {
1067 992 $tbody_params['data-wp-lists'] = 'list:' . $singular;
1068 993 }
1069 994
1070 - if ( $this->should_display( $args, 'display-top-nav' ) ) {
1071 - $this->display_tablenav( 'top' );
1072 - }
1073 - $this->screen->render_screen_reader_content( 'heading_list' );
1074 -
995 + $this->display_tablenav( 'top' );
1075 996 ?>
1076 997 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1077 998 <?php if ( $this->has_min_items( 1 ) ) { ?>
1078 999 <thead>
@@ -1085,9 +1006,9 @@
1085 1006 <tbody id="the-list"<?php FrmAppHelper::array_to_html_params( $tbody_params, true ); ?>>
1086 1007 <?php $this->display_rows_or_placeholder(); ?>
1087 1008 </tbody>
1088 1009
1089 - <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?>
1010 + <?php if ( $this->has_min_items( 1 ) ) { ?>
1090 1011 <tfoot>
1091 1012 <tr>
1092 1013 <?php $this->print_column_headers( false ); ?>
1093 1014 </tr>
@@ -1094,29 +1015,16 @@
1094 1015 </tfoot>
1095 1016 <?php } ?>
1096 1017 </table>
1097 1018 <?php
1098 - if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1099 - $this->display_tablenav( 'bottom' );
1100 - }
1019 + $this->display_tablenav( 'bottom' );
1101 1020 }
1102 1021
1103 1022 /**
1104 - * Determines if a particular feature or element should be displayed.
1105 - *
1106 - * @param array $args An associative array of arguments.
1107 - * @param string $settings The specific setting key to check within the arguments array.
1108 - *
1109 - * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false.
1110 - */
1111 - protected function should_display( $args, $settings ) {
1112 - return ! isset( $args[ $settings ] ) || false !== $args[ $settings ];
1113 - }
1114 -
1115 - /**
1116 1023 * Get a list of CSS classes for the list table table tag.
1117 1024 *
1118 1025 * @since 2.0.18
1026 + * @access protected
1119 1027 *
1120 1028 * @return array List of CSS classes for the table tag.
1121 1029 */
1122 1030 protected function get_table_classes() {
@@ -1126,8 +1034,9 @@
1126 1034 /**
1127 1035 * Generate the table navigation above or below the table
1128 1036 *
1129 1037 * @since 2.0.18
1038 + * @access protected
1130 1039 *
1131 1040 * @param string $which
1132 1041 */
1133 1042 protected function display_tablenav( $which ) {
@@ -1132,9 +1041,8 @@
1132 1041 */
1133 1042 protected function display_tablenav( $which ) {
1134 1043 if ( 'top' === $which ) {
1135 1044 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1136 -
1137 1045 if ( ! $this->has_min_items( 1 ) ) {
1138 1046 // Don't show bulk actions if no items.
1139 1047 return;
1140 1048 }
@@ -1162,12 +1070,8 @@
1162 1070 * Use this to exclude the footer labels and bulk items.
1163 1071 * When close together, it feels like duplicates.
1164 1072 *
1165 1073 * @since 4.07
1166 - *
1167 - * @param int $limit
1168 - *
1169 - * @return bool
1170 1074 */
1171 1075 protected function has_min_items( $limit = 5 ) {
1172 1076 return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit );
1173 1077 }
@@ -1175,8 +1079,9 @@
1175 1079 /**
1176 1080 * Extra controls to be displayed between bulk actions and pagination
1177 1081 *
1178 1082 * @since 2.0.18
1083 + * @access protected
1179 1084 *
1180 1085 * @param string $which
1181 1086 */
1182 1087 protected function extra_tablenav( $which ) {
@@ -1185,8 +1090,9 @@
1185 1090 /**
1186 1091 * Generate the tbody element for the list table.
1187 1092 *
1188 1093 * @since 2.0.18
1094 + * @access public
1189 1095 */
1190 1096 public function display_rows_or_placeholder() {
1191 1097 if ( $this->has_items() ) {
1192 1098 $this->display_rows();
@@ -1200,8 +1106,9 @@
1200 1106 /**
1201 1107 * Generates content for a single row of the table
1202 1108 *
1203 1109 * @since 2.0.18
1110 + * @access public
1204 1111 *
1205 1112 * @param object $item The current item.
1206 1113 */
1207 1114 public function single_row( $item ) {
@@ -1213,8 +1120,9 @@
1213 1120 /**
1214 1121 * Generates the columns for a single row of the table
1215 1122 *
1216 1123 * @since 2.0.18
1124 + * @access protected
1217 1125 *
1218 1126 * @param object $item The current item.
1219 1127 */
1220 1128 protected function single_row_columns( $item ) {
@@ -1221,14 +1129,12 @@
1221 1129 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1222 1130
1223 1131 foreach ( $columns as $column_name => $column_display_name ) {
1224 1132 $classes = "$column_name column-$column_name";
1225 -
1226 1133 if ( $primary === $column_name ) {
1227 1134 $classes .= ' has-row-actions column-primary';
1228 1135 }
1229 1136
1230 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1231 1137 if ( in_array( $column_name, $hidden ) ) {
1232 1138 $classes .= ' hidden';
1233 1139 }
1234 1140
@@ -1259,8 +1165,9 @@
1259 1165 /**
1260 1166 * Generates and display row actions links for the list table.
1261 1167 *
1262 1168 * @since 4.3.0
1169 + * @access protected
1263 1170 *
1264 1171 * @param object $item The item being acted upon.
1265 1172 * @param string $column_name Current column name.
1266 1173 * @param string $primary Primary column name.
@@ -1267,9 +1174,9 @@
1267 1174 *
1268 1175 * @return string The row actions output. In this case, an empty string.
1269 1176 */
1270 1177 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
1178 + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : '';
1272 1179 }
1273 1180
1274 1181 /**
1275 1182 * Handle an incoming ajax request (called from admin-ajax.php)
@@ -1274,14 +1181,14 @@
1274 1181 /**
1275 1182 * Handle an incoming ajax request (called from admin-ajax.php)
1276 1183 *
1277 1184 * @since 2.0.18
1185 + * @access public
1278 1186 */
1279 1187 public function ajax_response() {
1280 1188 $this->prepare_items();
1281 1189
1282 1190 ob_start();
1283 -
1284 1191 if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1285 1192 $this->display_rows();
1286 1193 } else {
1287 1194 $this->display_rows_or_placeholder();
@@ -1286,9 +1193,10 @@
1286 1193 } else {
1287 1194 $this->display_rows_or_placeholder();
1288 1195 }
1289 1196
1290 - $rows = ob_get_clean();
1197 + $rows = ob_get_clean();
1198 +
1291 1199 $response = array( 'rows' => $rows );
1292 1200
1293 1201 if ( isset( $this->_pagination_args['total_items'] ) ) {
1294 1202 $response['total_items_i18n'] = sprintf(
@@ -1296,9 +1204,8 @@
1296 1204 _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
1297 1205 number_format_i18n( $this->_pagination_args['total_items'] )
1298 1206 );
1299 1207 }
1300 -
1301 1208 if ( isset( $this->_pagination_args['total_pages'] ) ) {
1302 1209 $response['total_pages'] = $this->_pagination_args['total_pages'];
1303 1210 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1304 1211 }
@@ -1308,9 +1215,9 @@
1308 1215
1309 1216 /**
1310 1217 * Send required variables to JavaScript land
1311 1218 *
1312 - * @return void
1219 + * @access public
1313 1220 */
1314 1221 public function _js_vars() {
1315 1222 $args = array(
1316 1223 'class' => get_class( $this ),