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