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 +182 -300 6.285.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,13 +282,8 @@
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 287 if ( ! empty( $_REQUEST[ $param_name ] ) ) {
309 288 $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
310 289 echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
@@ -315,8 +294,9 @@
315 294 * Get an associative array ( id => link ) with the list
316 295 * of views available on this table.
317 296 *
318 297 * @since 2.0.18
298 + * @access protected
319 299 *
320 300 * @return array
321 301 */
322 302 protected function get_views() {
@@ -326,8 +306,9 @@
326 306 /**
327 307 * Display the list of views available on this table.
328 308 *
329 309 * @since 2.0.18
310 + * @access public
330 311 */
331 312 public function views() {
332 313 $views = $this->get_views();
333 314 /**
@@ -341,18 +322,17 @@
341 322 * @param array $views An array of available list table views.
342 323 */
343 324 $views = apply_filters( 'views_' . $this->screen->id, $views );
344 325
345 - if ( ! $views ) {
326 + if ( empty( $views ) ) {
346 327 return;
347 328 }
348 329
349 330 echo "<ul class='subsubsub'>\n";
350 -
351 331 foreach ( $views as $class => $view ) {
352 332 $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
353 333 }
354 - echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
334 + echo implode( " |</li>\n", $views ) . "</li>\n"; // WPCS: XSS ok.
355 335 echo '</ul>';
356 336 }
357 337
358 338 /**
@@ -359,8 +339,9 @@
359 339 * Get an associative array ( option_name => option_title ) with the list
360 340 * of bulk actions available on this table.
361 341 *
362 342 * @since 2.0.18
343 + * @access protected
363 344 *
364 345 * @return array
365 346 */
366 347 protected function get_bulk_actions() {
@@ -370,8 +351,9 @@
370 351 /**
371 352 * Display the bulk actions dropdown.
372 353 *
373 354 * @since 2.0.18
355 + * @access protected
374 356 *
375 357 * @param string $which The location of the bulk actions: 'top' or 'bottom'.
376 358 * This is designated as optional for backwards-compatibility.
377 359 */
@@ -397,30 +379,22 @@
397 379
398 380 $two = '';
399 381 } else {
400 382 $two = '2';
401 - }//end if
383 + }
402 384
403 385 if ( empty( $this->_actions ) ) {
404 386 return;
405 387 }
406 388
407 - 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>';
408 390 echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
409 - 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";
410 392
411 393 foreach ( $this->_actions as $name => $title ) {
412 - $params = array(
413 - 'value' => $name,
414 - );
394 + $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
415 395
416 - if ( 'edit' === $name ) {
417 - $params['class'] = 'hide-if-no-js';
418 - }
419 -
420 - echo "\t<option ";
421 - FrmAppHelper::array_to_html_params( $params, true );
422 - echo '>' . esc_html( $title ) . '</option>' . "\n";
396 + echo "\t<option value='" . esc_attr( $name ) . "'$class>" . esc_html( $title ) . "</option>\n"; // WPCS: XSS ok.
423 397 }
424 398
425 399 echo "</select>\n";
426 400
@@ -427,21 +401,9 @@
427 401 if ( isset( $this->_actions['bulk_delete'] ) ) {
428 402 $verify = $this->confirm_bulk_delete();
429 403
430 404 if ( $verify ) {
431 - $confirm_delete_attributes = array(
432 - 'id' => 'confirm-bulk-delete-' . $which,
433 - 'class' => 'frm-hidden',
434 - 'tabindex' => '-1',
435 - 'aria-hidden' => 'true',
436 - 'href' => 'confirm-bulk-delete',
437 - 'data-loaded-from' => $this->loaded_from(),
438 - 'data-frmverify' => $verify,
439 - 'data-frmverify-btn' => 'frm-button-red',
440 - );
441 -
442 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
443 - 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>";
444 406 }
445 407 }
446 408
447 409 submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
@@ -458,38 +420,35 @@
458 420 /**
459 421 * Get the current action selected from the bulk actions dropdown.
460 422 *
461 423 * @since 2.0.18
424 + * @access public
462 425 *
463 - * @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
464 427 */
465 428 public function current_action() {
466 - if ( ! empty( $_REQUEST['filter_action'] ) ) {
429 + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
467 430 return false;
468 431 }
469 432
470 433 $action = $this->get_bulk_action( 'action' );
434 + if ( $action === false ) {
435 + $action = $this->get_bulk_action( 'action2' );
436 + }
471 437
472 - return $action === false ? $this->get_bulk_action( 'action2' ) : $action;
438 + return $action;
473 439 }
474 440
475 - /**
476 - * @param string $action_name
477 - *
478 - * @return false|string
479 - */
480 - private function get_bulk_action( $action_name ) {
441 + private static function get_bulk_action( $action_name ) {
481 442 $action = false;
482 - $action_param = $this->get_param(
443 + $action_param = self::get_param(
483 444 array(
484 445 'param' => $action_name,
485 446 'sanitize' => 'sanitize_text_field',
486 447 )
487 448 );
488 -
489 - // phpcs:ignore Universal.Operators.StrictComparisons
490 449 if ( $action_param && - 1 != $action_param ) {
491 - return $action_param;
450 + $action = $action_param;
492 451 }
493 452
494 453 return $action;
495 454 }
@@ -497,11 +456,12 @@
497 456 /**
498 457 * Generate row actions div
499 458 *
500 459 * @since 2.0.18
460 + * @access protected
501 461 *
502 - * @param array $actions The list of actions.
503 - * @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
504 464 *
505 465 * @return string
506 466 */
507 467 protected function row_actions( $actions, $always_visible = false ) {
@@ -506,24 +466,25 @@
506 466 */
507 467 protected function row_actions( $actions, $always_visible = false ) {
508 468 $action_count = count( $actions );
509 469
470 + $i = 0;
471 +
510 472 if ( ! $action_count ) {
511 473 return '';
512 474 }
513 475
514 - $i = 0;
515 476 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
516 -
517 477 foreach ( $actions as $action => $link ) {
518 - ++$i;
519 - $sep = $i === $action_count ? '' : ' | ';
478 + ++ $i;
479 + ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
520 480 $out .= "<span class='$action'>$link$sep</span>";
521 481 }
482 + $out .= '</div>';
522 483
523 - $out .= '</div>';
484 + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
524 485
525 - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' );
486 + return $out;
526 487 }
527 488
528 489 /**
529 490 * Display a view switcher
@@ -528,13 +489,13 @@
528 489 /**
529 490 * Display a view switcher
530 491 *
531 492 * @since 2.0.18
493 + * @access protected
532 494 *
533 495 * @param string $current_mode
534 496 */
535 497 protected function view_switcher( $current_mode ) {
536 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
537 498 ?>
538 499 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/>
539 500 <div class="view-switch">
540 501 <?php
@@ -539,10 +500,8 @@
539 500 <div class="view-switch">
540 501 <?php
541 502 foreach ( $this->modes as $mode => $title ) {
542 503 $classes = array( 'view-' . $mode );
543 -
544 - // phpcs:ignore Universal.Operators.StrictComparisons
545 504 if ( $current_mode == $mode ) {
546 505 $classes[] = 'current';
547 506 }
548 507
@@ -555,9 +514,8 @@
555 514 }
556 515 ?>
557 516 </div>
558 517 <?php
559 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
560 518 }
561 519
562 520 /**
563 521 * Get the current page number
@@ -562,8 +520,9 @@
562 520 /**
563 521 * Get the current page number
564 522 *
565 523 * @since 2.0.18
524 + * @access public
566 525 *
567 526 * @return int
568 527 */
569 528 public function get_pagenum() {
@@ -579,18 +538,18 @@
579 538 /**
580 539 * Get number of items to display on a single page
581 540 *
582 541 * @since 2.0.18
542 + * @access protected
583 543 *
584 544 * @param string $option
585 - * @param int $default
545 + * @param int $default
586 546 *
587 547 * @return int
588 548 */
589 549 protected function get_items_per_page( $option, $default = 20 ) {
590 550 $per_page = (int) get_user_option( $option );
591 -
592 - if ( ! $per_page || $per_page < 1 ) {
551 + if ( empty( $per_page ) || $per_page < 1 ) {
593 552 $per_page = $default;
594 553 }
595 554
596 555 /**
@@ -612,8 +571,9 @@
612 571 /**
613 572 * Display the pagination.
614 573 *
615 574 * @since 2.0.18
575 + * @access protected
616 576 *
617 577 * @param string $which
618 578 */
619 579 protected function pagination( $which ) {
@@ -623,9 +583,8 @@
623 583
624 584 $total_items = $this->_pagination_args['total_items'];
625 585 $total_pages = $this->_pagination_args['total_pages'];
626 586 $infinite_scroll = false;
627 -
628 587 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
629 588 $infinite_scroll = $this->_pagination_args['infinite_scroll'];
630 589 }
631 590
@@ -631,14 +590,17 @@
631 590
632 591 /* translators: %s: Number of items */
633 592 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
634 593
635 - $current = $this->get_pagenum();
636 - $page_links = array();
594 + $current = $this->get_pagenum();
595 +
596 + $page_links = array();
597 +
637 598 $total_pages_before = '<span class="paging-input">';
638 599 $total_pages_after = '</span>';
639 - $disable = $this->disabled_pages( $total_pages );
640 600
601 + $disable = $this->disabled_pages( $total_pages );
602 +
641 603 $page_links[] = $this->add_page_link(
642 604 array(
643 605 'page' => 'first',
644 606 'arrow' => '&laquo;',
@@ -655,20 +617,19 @@
655 617 'disabled' => $disable['prev'],
656 618 )
657 619 );
658 620
659 - if ( 'bottom' === $which ) {
621 + if ( 'bottom' == $which ) {
660 622 $html_current_page = $current;
661 - $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">';
662 624 } else {
663 625 $html_current_page = sprintf(
664 626 "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
665 - '<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>',
666 628 $current,
667 629 strlen( $total_pages )
668 630 );
669 631 }
670 -
671 632 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
672 633
673 634 /* translators: %1$s: Current page number, %2$s: Total pages */
674 635 $page_links[] = $total_pages_before . sprintf( _x( '%1$s of %2$s', 'paging', 'formidable' ), $html_current_page, $html_total_pages ) . $total_pages_after;
@@ -691,15 +652,13 @@
691 652 )
692 653 );
693 654
694 655 $pagination_links_class = 'pagination-links';
695 -
696 - if ( $infinite_scroll ) {
656 + if ( ! empty( $infinite_scroll ) ) {
697 657 $pagination_links_class = ' hide-if-js';
698 658 }
659 + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>';
699 660
700 - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
701 -
702 661 if ( $total_pages ) {
703 662 $page_class = $total_pages < 2 ? ' one-page' : '';
704 663 } else {
705 664 $page_class = ' no-pages';
@@ -705,16 +664,11 @@
705 664 $page_class = ' no-pages';
706 665 }
707 666 $this->_pagination = "<div class='tablenav-pages" . esc_attr( $page_class ) . "'>$output</div>";
708 667
709 - echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
668 + echo $this->_pagination; // WPCS: XSS ok.
710 669 }
711 670
712 - /**
713 - * @param int $total_pages
714 - *
715 - * @return array
716 - */
717 671 private function disabled_pages( $total_pages ) {
718 672 $current = $this->get_pagenum();
719 673 $disable = array(
720 674 'first' => false,
@@ -722,21 +676,19 @@
722 676 'prev' => false,
723 677 'next' => false,
724 678 );
725 679
726 - // phpcs:ignore Universal.Operators.StrictComparisons
727 680 if ( $current == 1 ) {
728 681 $disable['first'] = true;
729 682 $disable['prev'] = true;
730 - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons
683 + } elseif ( $current == 2 ) {
731 684 $disable['first'] = true;
732 685 }
733 686
734 - // phpcs:ignore Universal.Operators.StrictComparisons
735 687 if ( $current == $total_pages ) {
736 688 $disable['last'] = true;
737 689 $disable['next'] = true;
738 - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons
690 + } elseif ( $current == $total_pages - 1 ) {
739 691 $disable['last'] = true;
740 692 }
741 693
742 694 return $disable;
@@ -741,13 +693,8 @@
741 693
742 694 return $disable;
743 695 }
744 696
745 - /**
746 - * @param string $link
747 - *
748 - * @return string
749 - */
750 697 private function link_label( $link ) {
751 698 $labels = array(
752 699 'first' => __( 'First page', 'formidable' ),
753 700 'last' => __( 'Last page', 'formidable' ),
@@ -759,34 +706,26 @@
759 706 }
760 707
761 708 private function current_url() {
762 709 $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
710 +
763 711 return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
764 712 }
765 713
766 - /**
767 - * @param array $atts
768 - *
769 - * @return string
770 - */
771 714 private function add_page_link( $atts ) {
772 - 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;
773 722 }
774 723
775 - /**
776 - * @param string $label
777 - *
778 - * @return string
779 - */
780 724 private function add_disabled_link( $label ) {
781 725 return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>';
782 726 }
783 727
784 - /**
785 - * @param array $atts
786 - *
787 - * @return string
788 - */
789 728 private function add_active_link( $atts ) {
790 729 $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) );
791 730 $label = $this->link_label( $atts['page'] );
792 731
@@ -807,8 +746,9 @@
807 746 *
808 747 * The second format will make the initial sorting order be descending
809 748 *
810 749 * @since 2.0.18
750 + * @access protected
811 751 *
812 752 * @return array
813 753 */
814 754 protected function get_sortable_columns() {
@@ -818,8 +758,9 @@
818 758 /**
819 759 * Gets the name of the default primary column.
820 760 *
821 761 * @since 4.3.0
762 + * @access protected
822 763 *
823 764 * @return string Name of the default primary column, in this case, an empty string.
824 765 */
825 766 protected function get_default_primary_column_name() {
@@ -826,9 +767,9 @@
826 767 $columns = $this->get_columns();
827 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.
771 + // so let's fall back to the first non-checkbox column.
831 772 foreach ( $columns as $col => $column_name ) {
832 773 if ( 'cb' === $col ) {
833 774 continue;
834 775 }
@@ -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
@@ -894,10 +836,11 @@
894 836
895 837 return $column_headers;
896 838 }
897 839
898 - $columns = get_column_headers( $this->screen );
899 - $hidden = get_hidden_columns( $this->screen );
840 + $columns = get_column_headers( $this->screen );
841 + $hidden = get_hidden_columns( $this->screen );
842 +
900 843 $sortable_columns = $this->get_sortable_columns();
901 844 /**
902 845 * Filter the list table sortable columns for a specific screen.
903 846 *
@@ -910,16 +853,14 @@
910 853 */
911 854 $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
912 855
913 856 $sortable = array();
914 -
915 857 foreach ( $_sortable as $id => $data ) {
916 - if ( ! $data ) {
858 + if ( empty( $data ) ) {
917 859 continue;
918 860 }
919 861
920 862 $data = (array) $data;
921 -
922 863 if ( ! isset( $data[1] ) ) {
923 864 $data[1] = false;
924 865 }
925 866
@@ -936,14 +877,15 @@
936 877 /**
937 878 * Return number of visible columns
938 879 *
939 880 * @since 2.0.18
881 + * @access public
940 882 *
941 883 * @return int
942 884 */
943 885 public function get_column_count() {
944 886 list ( $columns, $hidden ) = $this->get_column_info();
945 - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
887 + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
946 888
947 889 return count( $columns ) - count( $hidden );
948 890 }
949 891
@@ -950,49 +892,53 @@
950 892 /**
951 893 * Print column headers, accounting for hidden and sortable columns.
952 894 *
953 895 * @since 2.0.18
896 + * @access public
954 897 *
955 898 * @staticvar int $cb_counter
956 899 *
957 - * @param bool $with_id Whether to set the id attribute or not.
958 - *
959 - * @return void
900 + * @param bool $with_id Whether to set the id attribute or not
960 901 */
961 - 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 ) {
962 903 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
963 904
964 - $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
965 - $current_url = remove_query_arg( 'paged', $current_url );
966 - $current_orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( wp_unslash( $_GET['orderby'] ) ) : '';
967 - $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 );
968 907
969 - 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 + }
970 913
914 + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
915 + $current_order = 'desc';
916 + } else {
917 + $current_order = 'asc';
918 + }
919 +
971 920 if ( ! empty( $columns['cb'] ) ) {
972 921 static $cb_counter = 1;
973 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . esc_html__( 'Select All', 'formidable' ) . '</label>';
974 - $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
975 - ++$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 ++;
976 925 }
977 926
978 927 foreach ( $columns as $column_key => $column_display_name ) {
979 - $class = array( 'manage-column', "column-$column_key" );
980 - $aria_sort_attr = '';
981 - $order_text = '';
928 + $class = array( 'manage-column', "column-$column_key" );
982 929
983 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
984 930 if ( in_array( $column_key, $hidden ) ) {
985 931 $class[] = 'hidden';
986 932 }
987 933
988 - if ( 'cb' === $column_key ) {
934 + if ( 'cb' == $column_key ) {
989 935 $class[] = 'check-column';
990 - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
936 + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
991 937 $class[] = 'num';
992 938 }
993 939
994 - if ( $column_key === $primary || $column_key === 'name' ) {
940 + if ( $column_key === $primary ) {
995 941 $class[] = 'column-primary';
996 942 }
997 943
998 944 if ( isset( $sortable[ $column_key ] ) ) {
@@ -997,19 +943,10 @@
997 943
998 944 if ( isset( $sortable[ $column_key ] ) ) {
999 945 list( $orderby, $desc_first ) = $sortable[ $column_key ];
1000 946
1001 - // phpcs:ignore Universal.Operators.StrictComparisons
1002 947 if ( $current_orderby == $orderby ) {
1003 - // The sorted column. The `aria-sort` attribute must be set only on the sorted column.
1004 - if ( 'asc' === $current_order ) {
1005 - $order = 'desc';
1006 - $aria_sort_attr = ' aria-sort="ascending"';
1007 - } else {
1008 - $order = 'asc';
1009 - $aria_sort_attr = ' aria-sort="descending"';
1010 - }
1011 -
948 + $order = 'asc' == $current_order ? 'desc' : 'asc';
1012 949 $class[] = 'sorted';
1013 950 $class[] = $current_order;
1014 951 } else {
1015 952 $order = $desc_first ? 'desc' : 'asc';
@@ -1014,41 +951,19 @@
1014 951 } else {
1015 952 $order = $desc_first ? 'desc' : 'asc';
1016 953 $class[] = 'sortable';
1017 954 $class[] = $desc_first ? 'asc' : 'desc';
1018 -
1019 - /* translators: Hidden accessibility text. */
1020 - $asc_text = __( 'Sort ascending.', 'formidable' );
1021 - /* translators: Hidden accessibility text. */
1022 - $desc_text = __( 'Sort descending.', 'formidable' );
1023 - $order_text = 'asc' === $order ? $asc_text : $desc_text;
1024 - }//end if
1025 -
1026 - if ( '' !== $order_text ) {
1027 - $order_text = ' <span class="screen-reader-text">' . $order_text . '</span>';
1028 955 }
1029 956
1030 - $column_display_name = sprintf(
1031 - '<a href="%1$s">' .
1032 - '<span>%2$s</span>' .
1033 - '<span class="sorting-indicators">' .
1034 - '<span class="sorting-indicator asc" aria-hidden="true"></span>' .
1035 - '<span class="sorting-indicator desc" aria-hidden="true"></span>' .
1036 - '</span>' .
1037 - '%3$s' .
1038 - '</a>',
1039 - esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
1040 - $column_display_name,
1041 - $order_text
1042 - );
1043 - }//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 + }
1044 959
1045 - $tag = 'cb' === $column_key ? 'td' : 'th';
1046 - $scope = 'th' === $tag ? 'scope="col"' : '';
960 + $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
961 + $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1047 962 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
1048 963
1049 - if ( $class ) {
1050 - $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
964 + if ( ! empty( $class ) ) {
965 + $class = "class='" . esc_attr( join( ' ', $class ) ) . "'";
1051 966 }
1052 967
1053 968 if ( ! $this->has_min_items() && ! $with_id ) {
1054 969 // Hide the labels but show the border.
@@ -1053,10 +968,10 @@
1053 968 if ( ! $this->has_min_items() && ! $with_id ) {
1054 969 // Hide the labels but show the border.
1055 970 $column_display_name = '';
1056 971 }
1057 - echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1058 - }//end foreach
972 + echo "<$tag $scope $id $class>$column_display_name</$tag>"; // WPCS: XSS ok.
973 + }
1059 974 }
1060 975
1061 976 /**
1062 977 * Display the table
@@ -1061,27 +976,14 @@
1061 976 /**
1062 977 * Display the table
1063 978 *
1064 979 * @since 2.0.18
1065 - *
1066 - * @param array $args
1067 - *
1068 - * @return void
980 + * @access public
1069 981 */
1070 - public function display( $args = array() ) {
1071 - $singular = $this->_args['singular'];
1072 - $tbody_params = array();
982 + public function display() {
983 + $singular = $this->_args['singular'];
1073 984
1074 - if ( $singular ) {
1075 - $tbody_params['data-wp-lists'] = 'list:' . $singular;
1076 - }
1077 -
1078 - if ( $this->should_display( $args, 'display-top-nav' ) ) {
1079 - $this->display_tablenav( 'top' );
1080 - }
1081 - $this->screen->render_screen_reader_content( 'heading_list' );
1082 -
1083 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
985 + $this->display_tablenav( 'top' );
1084 986 ?>
1085 987 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1086 988 <?php if ( $this->has_min_items( 1 ) ) { ?>
1087 989 <thead>
@@ -1090,13 +992,13 @@
1090 992 </tr>
1091 993 </thead>
1092 994 <?php } ?>
1093 995
1094 - <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. ?>>
1095 997 <?php $this->display_rows_or_placeholder(); ?>
1096 998 </tbody>
1097 999
1098 - <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?>
1000 + <?php if ( $this->has_min_items( 1 ) ) { ?>
1099 1001 <tfoot>
1100 1002 <tr>
1101 1003 <?php $this->print_column_headers( false ); ?>
1102 1004 </tr>
@@ -1103,31 +1005,16 @@
1103 1005 </tfoot>
1104 1006 <?php } ?>
1105 1007 </table>
1106 1008 <?php
1107 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1108 -
1109 - if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1110 - $this->display_tablenav( 'bottom' );
1111 - }
1009 + $this->display_tablenav( 'bottom' );
1112 1010 }
1113 1011
1114 1012 /**
1115 - * Determines if a particular feature or element should be displayed.
1116 - *
1117 - * @param array $args An associative array of arguments.
1118 - * @param string $settings The specific setting key to check within the arguments array.
1119 - *
1120 - * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false.
1121 - */
1122 - protected function should_display( $args, $settings ) {
1123 - return ! isset( $args[ $settings ] ) || false !== $args[ $settings ];
1124 - }
1125 -
1126 - /**
1127 1013 * Get a list of CSS classes for the list table table tag.
1128 1014 *
1129 1015 * @since 2.0.18
1016 + * @access protected
1130 1017 *
1131 1018 * @return array List of CSS classes for the table tag.
1132 1019 */
1133 1020 protected function get_table_classes() {
@@ -1137,24 +1024,23 @@
1137 1024 /**
1138 1025 * Generate the table navigation above or below the table
1139 1026 *
1140 1027 * @since 2.0.18
1028 + * @access protected
1141 1029 *
1142 1030 * @param string $which
1143 1031 */
1144 1032 protected function display_tablenav( $which ) {
1145 - if ( 'top' === $which ) {
1033 + if ( 'top' == $which ) {
1146 1034 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1147 -
1148 1035 if ( ! $this->has_min_items( 1 ) ) {
1149 1036 // Don't show bulk actions if no items.
1150 1037 return;
1151 1038 }
1152 1039 } elseif ( ! $this->has_min_items() ) {
1153 - // 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.
1154 1041 return;
1155 1042 }
1156 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1157 1043 ?>
1158 1044 <div class="tablenav <?php echo esc_attr( $which ); ?>">
1159 1045
1160 1046 <div class="alignleft actions bulkactions">
@@ -1167,9 +1053,8 @@
1167 1053
1168 1054 <br class="clear"/>
1169 1055 </div>
1170 1056 <?php
1171 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1172 1057 }
1173 1058
1174 1059 /**
1175 1060 * Use this to exclude the footer labels and bulk items.
@@ -1175,12 +1060,8 @@
1175 1060 * Use this to exclude the footer labels and bulk items.
1176 1061 * When close together, it feels like duplicates.
1177 1062 *
1178 1063 * @since 4.07
1179 - *
1180 - * @param int $limit
1181 - *
1182 - * @return bool
1183 1064 */
1184 1065 protected function has_min_items( $limit = 5 ) {
1185 1066 return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit );
1186 1067 }
@@ -1188,8 +1069,9 @@
1188 1069 /**
1189 1070 * Extra controls to be displayed between bulk actions and pagination
1190 1071 *
1191 1072 * @since 2.0.18
1073 + * @access protected
1192 1074 *
1193 1075 * @param string $which
1194 1076 */
1195 1077 protected function extra_tablenav( $which ) {
@@ -1198,8 +1080,9 @@
1198 1080 /**
1199 1081 * Generate the tbody element for the list table.
1200 1082 *
1201 1083 * @since 2.0.18
1084 + * @access public
1202 1085 */
1203 1086 public function display_rows_or_placeholder() {
1204 1087 if ( $this->has_items() ) {
1205 1088 $this->display_rows();
@@ -1213,10 +1096,11 @@
1213 1096 /**
1214 1097 * Generates content for a single row of the table
1215 1098 *
1216 1099 * @since 2.0.18
1100 + * @access public
1217 1101 *
1218 - * @param object $item The current item.
1102 + * @param object $item The current item
1219 1103 */
1220 1104 public function single_row( $item ) {
1221 1105 echo '<tr>';
1222 1106 $this->single_row_columns( $item );
@@ -1226,10 +1110,11 @@
1226 1110 /**
1227 1111 * Generates the columns for a single row of the table
1228 1112 *
1229 1113 * @since 2.0.18
1114 + * @access protected
1230 1115 *
1231 - * @param object $item The current item.
1116 + * @param object $item The current item
1232 1117 */
1233 1118 protected function single_row_columns( $item ) {
1234 1119 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1235 1120
@@ -1234,40 +1119,43 @@
1234 1119 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1235 1120
1236 1121 foreach ( $columns as $column_name => $column_display_name ) {
1237 1122 $classes = "$column_name column-$column_name";
1238 -
1239 1123 if ( $primary === $column_name ) {
1240 1124 $classes .= ' has-row-actions column-primary';
1241 1125 }
1242 1126
1243 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1244 1127 if ( in_array( $column_name, $hidden ) ) {
1245 1128 $classes .= ' hidden';
1246 1129 }
1247 1130
1248 - $params = array(
1249 - 'class' => $classes,
1250 - // Comments column uses HTML in the display name with screen reader text.
1251 - // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
1252 - 'data-colname' => $column_display_name,
1253 - );
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 ) . '"';
1254 1134
1255 - if ( 'cb' === $column_name ) {
1135 + $attributes = 'class="' . esc_attr( $classes ) . '" ' . $data;
1136 +
1137 + if ( 'cb' == $column_name ) {
1256 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>';
1257 1152 } else {
1258 - echo '<td ';
1259 - FrmAppHelper::array_to_html_params( $params, true );
1260 - echo '>';
1261 -
1262 - if ( method_exists( $this, 'column_' . $column_name ) ) {
1263 - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1264 - }
1265 -
1266 - 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.
1267 1155 echo '</td>';
1268 1156 }
1269 - }//end foreach
1157 + }
1270 1158 }
1271 1159
1272 1160 /**
1273 1161 * Generates and display row actions links for the list table.
@@ -1272,8 +1160,9 @@
1272 1160 /**
1273 1161 * Generates and display row actions links for the list table.
1274 1162 *
1275 1163 * @since 4.3.0
1164 + * @access protected
1276 1165 *
1277 1166 * @param object $item The item being acted upon.
1278 1167 * @param string $column_name Current column name.
1279 1168 * @param string $primary Primary column name.
@@ -1280,9 +1169,9 @@
1280 1169 *
1281 1170 * @return string The row actions output. In this case, an empty string.
1282 1171 */
1283 1172 protected function handle_row_actions( $item, $column_name, $primary ) {
1284 - 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>' : '';
1285 1174 }
1286 1175
1287 1176 /**
1288 1177 * Handle an incoming ajax request (called from admin-ajax.php)
@@ -1287,14 +1176,14 @@
1287 1176 /**
1288 1177 * Handle an incoming ajax request (called from admin-ajax.php)
1289 1178 *
1290 1179 * @since 2.0.18
1180 + * @access public
1291 1181 */
1292 1182 public function ajax_response() {
1293 1183 $this->prepare_items();
1294 1184
1295 1185 ob_start();
1296 -
1297 1186 if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1298 1187 $this->display_rows();
1299 1188 } else {
1300 1189 $this->display_rows_or_placeholder();
@@ -1299,9 +1188,10 @@
1299 1188 } else {
1300 1189 $this->display_rows_or_placeholder();
1301 1190 }
1302 1191
1303 - $rows = ob_get_clean();
1192 + $rows = ob_get_clean();
1193 +
1304 1194 $response = array( 'rows' => $rows );
1305 1195
1306 1196 if ( isset( $this->_pagination_args['total_items'] ) ) {
1307 1197 $response['total_items_i18n'] = sprintf(
@@ -1309,9 +1199,8 @@
1309 1199 _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
1310 1200 number_format_i18n( $this->_pagination_args['total_items'] )
1311 1201 );
1312 1202 }
1313 -
1314 1203 if ( isset( $this->_pagination_args['total_pages'] ) ) {
1315 1204 $response['total_pages'] = $this->_pagination_args['total_pages'];
1316 1205 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1317 1206 }
@@ -1321,9 +1210,9 @@
1321 1210
1322 1211 /**
1323 1212 * Send required variables to JavaScript land
1324 1213 *
1325 - * @return void
1214 + * @access public
1326 1215 */
1327 1216 public function _js_vars() {
1328 1217 $args = array(
1329 1218 'class' => get_class( $this ),
@@ -1333,13 +1222,6 @@
1333 1222 ),
1334 1223 );
1335 1224
1336 1225 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1337 - }
1338 -
1339 - /**
1340 - * @return string
1341 - */
1342 - protected function loaded_from() {
1343 - return '';
1344 1226 }
1345 1227 }