PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.1
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | classes/helpers/FrmListHelper.php +168 -271 6.305.1 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
@@ -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,14 +322,13 @@
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 334 echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
@@ -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,23 +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 394 $params = array(
415 395 'value' => $name,
416 396 );
417 -
418 397 if ( 'edit' === $name ) {
419 398 $params['class'] = 'hide-if-no-js';
420 399 }
421 400
@@ -429,21 +408,9 @@
429 408 if ( isset( $this->_actions['bulk_delete'] ) ) {
430 409 $verify = $this->confirm_bulk_delete();
431 410
432 411 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>';
412 + 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 413 }
447 414 }
448 415
449 416 submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
@@ -460,26 +427,25 @@
460 427 /**
461 428 * Get the current action selected from the bulk actions dropdown.
462 429 *
463 430 * @since 2.0.18
431 + * @access public
464 432 *
465 - * @return false|string The action name or False if no action was selected
433 + * @return string|false The action name or False if no action was selected
466 434 */
467 435 public function current_action() {
468 - if ( ! empty( $_REQUEST['filter_action'] ) ) {
436 + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
469 437 return false;
470 438 }
471 439
472 440 $action = $this->get_bulk_action( 'action' );
441 + if ( $action === false ) {
442 + $action = $this->get_bulk_action( 'action2' );
443 + }
473 444
474 - return $action === false ? $this->get_bulk_action( 'action2' ) : $action;
445 + return $action;
475 446 }
476 447
477 - /**
478 - * @param string $action_name
479 - *
480 - * @return false|string
481 - */
482 448 private function get_bulk_action( $action_name ) {
483 449 $action = false;
484 450 $action_param = $this->get_param(
485 451 array(
@@ -486,12 +452,10 @@
486 452 'param' => $action_name,
487 453 'sanitize' => 'sanitize_text_field',
488 454 )
489 455 );
490 -
491 - // phpcs:ignore Universal.Operators.StrictComparisons
492 456 if ( $action_param && - 1 != $action_param ) {
493 - return $action_param;
457 + $action = $action_param;
494 458 }
495 459
496 460 return $action;
497 461 }
@@ -499,11 +463,12 @@
499 463 /**
500 464 * Generate row actions div
501 465 *
502 466 * @since 2.0.18
467 + * @access protected
503 468 *
504 - * @param array $actions The list of actions.
505 - * @param bool $always_visible Whether the actions should be always visible.
469 + * @param array $actions The list of actions
470 + * @param bool $always_visible Whether the actions should be always visible
506 471 *
507 472 * @return string
508 473 */
509 474 protected function row_actions( $actions, $always_visible = false ) {
@@ -508,24 +473,25 @@
508 473 */
509 474 protected function row_actions( $actions, $always_visible = false ) {
510 475 $action_count = count( $actions );
511 476
477 + $i = 0;
478 +
512 479 if ( ! $action_count ) {
513 480 return '';
514 481 }
515 482
516 - $i = 0;
517 483 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
518 -
519 484 foreach ( $actions as $action => $link ) {
520 - ++$i;
521 - $sep = $i === $action_count ? '' : ' | ';
485 + ++ $i;
486 + ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
522 487 $out .= "<span class='$action'>$link$sep</span>";
523 488 }
489 + $out .= '</div>';
524 490
525 - $out .= '</div>';
491 + $out .= '<button type="button" class="toggle-row"><span class="screen-reader-text">' . __( 'Show more details', 'formidable' ) . '</span></button>';
526 492
527 - return $out . ( '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' );
493 + return $out;
528 494 }
529 495
530 496 /**
531 497 * Display a view switcher
@@ -530,13 +496,13 @@
530 496 /**
531 497 * Display a view switcher
532 498 *
533 499 * @since 2.0.18
500 + * @access protected
534 501 *
535 502 * @param string $current_mode
536 503 */
537 504 protected function view_switcher( $current_mode ) {
538 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
539 505 ?>
540 506 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/>
541 507 <div class="view-switch">
542 508 <?php
@@ -541,10 +507,9 @@
541 507 <div class="view-switch">
542 508 <?php
543 509 foreach ( $this->modes as $mode => $title ) {
544 510 $classes = array( 'view-' . $mode );
545 -
546 - if ( $current_mode === $mode ) {
511 + if ( $current_mode == $mode ) {
547 512 $classes[] = 'current';
548 513 }
549 514
550 515 printf(
@@ -556,9 +521,8 @@
556 521 }
557 522 ?>
558 523 </div>
559 524 <?php
560 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
561 525 }
562 526
563 527 /**
564 528 * Get the current page number
@@ -563,8 +527,9 @@
563 527 /**
564 528 * Get the current page number
565 529 *
566 530 * @since 2.0.18
531 + * @access public
567 532 *
568 533 * @return int
569 534 */
570 535 public function get_pagenum() {
@@ -580,18 +545,18 @@
580 545 /**
581 546 * Get number of items to display on a single page
582 547 *
583 548 * @since 2.0.18
549 + * @access protected
584 550 *
585 551 * @param string $option
586 - * @param int $default
552 + * @param int $default
587 553 *
588 554 * @return int
589 555 */
590 556 protected function get_items_per_page( $option, $default = 20 ) {
591 557 $per_page = (int) get_user_option( $option );
592 -
593 - if ( ! $per_page || $per_page < 1 ) {
558 + if ( empty( $per_page ) || $per_page < 1 ) {
594 559 $per_page = $default;
595 560 }
596 561
597 562 /**
@@ -613,13 +578,14 @@
613 578 /**
614 579 * Display the pagination.
615 580 *
616 581 * @since 2.0.18
582 + * @access protected
617 583 *
618 584 * @param string $which
619 585 */
620 586 protected function pagination( $which ) {
621 - if ( ! $this->_pagination_args ) {
587 + if ( empty( $this->_pagination_args ) ) {
622 588 return;
623 589 }
624 590
625 591 $total_items = $this->_pagination_args['total_items'];
@@ -624,9 +590,8 @@
624 590
625 591 $total_items = $this->_pagination_args['total_items'];
626 592 $total_pages = $this->_pagination_args['total_pages'];
627 593 $infinite_scroll = false;
628 -
629 594 if ( isset( $this->_pagination_args['infinite_scroll'] ) ) {
630 595 $infinite_scroll = $this->_pagination_args['infinite_scroll'];
631 596 }
632 597
@@ -632,14 +597,17 @@
632 597
633 598 /* translators: %s: Number of items */
634 599 $output = '<span class="displaying-num">' . sprintf( _n( '%s item', '%s items', $total_items, 'formidable' ), number_format_i18n( $total_items ) ) . '</span>';
635 600
636 - $current = $this->get_pagenum();
637 - $page_links = array();
601 + $current = $this->get_pagenum();
602 +
603 + $page_links = array();
604 +
638 605 $total_pages_before = '<span class="paging-input">';
639 606 $total_pages_after = '</span>';
640 - $disable = $this->disabled_pages( $total_pages );
641 607
608 + $disable = $this->disabled_pages( $total_pages );
609 +
642 610 $page_links[] = $this->add_page_link(
643 611 array(
644 612 'page' => 'first',
645 613 'arrow' => '&laquo;',
@@ -656,20 +624,19 @@
656 624 'disabled' => $disable['prev'],
657 625 )
658 626 );
659 627
660 - if ( 'bottom' === $which ) {
628 + if ( 'bottom' == $which ) {
661 629 $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">';
630 + $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
663 631 } else {
664 632 $html_current_page = sprintf(
665 633 "%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>',
634 + '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>',
667 635 $current,
668 636 strlen( $total_pages )
669 637 );
670 638 }
671 -
672 639 $html_total_pages = sprintf( "<span class='total-pages'>%s</span>", number_format_i18n( $total_pages ) );
673 640
674 641 /* translators: %1$s: Current page number, %2$s: Total pages */
675 642 $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 +659,13 @@
692 659 )
693 660 );
694 661
695 662 $pagination_links_class = 'pagination-links';
696 -
697 - if ( $infinite_scroll ) {
663 + if ( ! empty( $infinite_scroll ) ) {
698 664 $pagination_links_class = ' hide-if-js';
699 665 }
666 + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>';
700 667
701 - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
702 -
703 668 if ( $total_pages ) {
704 669 $page_class = $total_pages < 2 ? ' one-page' : '';
705 670 } else {
706 671 $page_class = ' no-pages';
@@ -709,13 +674,8 @@
709 674
710 675 echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
711 676 }
712 677
713 - /**
714 - * @param int $total_pages
715 - *
716 - * @return array
717 - */
718 678 private function disabled_pages( $total_pages ) {
719 679 $current = $this->get_pagenum();
720 680 $disable = array(
721 681 'first' => false,
@@ -723,21 +683,19 @@
723 683 'prev' => false,
724 684 'next' => false,
725 685 );
726 686
727 - // phpcs:ignore Universal.Operators.StrictComparisons
728 687 if ( $current == 1 ) {
729 688 $disable['first'] = true;
730 689 $disable['prev'] = true;
731 - } elseif ( $current == 2 ) { // phpcs:ignore Universal.Operators.StrictComparisons
690 + } elseif ( $current == 2 ) {
732 691 $disable['first'] = true;
733 692 }
734 693
735 - // phpcs:ignore Universal.Operators.StrictComparisons
736 694 if ( $current == $total_pages ) {
737 695 $disable['last'] = true;
738 696 $disable['next'] = true;
739 - } elseif ( $current == $total_pages - 1 ) { // phpcs:ignore Universal.Operators.StrictComparisons
697 + } elseif ( $current == $total_pages - 1 ) {
740 698 $disable['last'] = true;
741 699 }
742 700
743 701 return $disable;
@@ -742,13 +700,8 @@
742 700
743 701 return $disable;
744 702 }
745 703
746 - /**
747 - * @param string $link
748 - *
749 - * @return string
750 - */
751 704 private function link_label( $link ) {
752 705 $labels = array(
753 706 'first' => __( 'First page', 'formidable' ),
754 707 'last' => __( 'Last page', 'formidable' ),
@@ -760,34 +713,26 @@
760 713 }
761 714
762 715 private function current_url() {
763 716 $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
717 +
764 718 return remove_query_arg( array( 'hotkeys_highlight_last', 'hotkeys_highlight_first' ), $current_url );
765 719 }
766 720
767 - /**
768 - * @param array $atts
769 - *
770 - * @return string
771 - */
772 721 private function add_page_link( $atts ) {
773 - return $atts['disabled'] ? $this->add_disabled_link( $atts['arrow'] ) : $this->add_active_link( $atts );
722 + if ( $atts['disabled'] ) {
723 + $link = $this->add_disabled_link( $atts['arrow'] );
724 + } else {
725 + $link = $this->add_active_link( $atts );
726 + }
727 +
728 + return $link;
774 729 }
775 730
776 - /**
777 - * @param string $label
778 - *
779 - * @return string
780 - */
781 731 private function add_disabled_link( $label ) {
782 732 return '<span class="tablenav-pages-navspan button disabled" aria-hidden="true">' . $label . '</span>';
783 733 }
784 734
785 - /**
786 - * @param array $atts
787 - *
788 - * @return string
789 - */
790 735 private function add_active_link( $atts ) {
791 736 $url = esc_url( add_query_arg( 'paged', $atts['number'], $this->current_url() ) );
792 737 $label = $this->link_label( $atts['page'] );
793 738
@@ -808,8 +753,9 @@
808 753 *
809 754 * The second format will make the initial sorting order be descending
810 755 *
811 756 * @since 2.0.18
757 + * @access protected
812 758 *
813 759 * @return array
814 760 */
815 761 protected function get_sortable_columns() {
@@ -819,17 +765,19 @@
819 765 /**
820 766 * Gets the name of the default primary column.
821 767 *
822 768 * @since 4.3.0
769 + * @access protected
823 770 *
824 771 * @return string Name of the default primary column, in this case, an empty string.
825 772 */
826 773 protected function get_default_primary_column_name() {
827 - $column = '';
774 + $columns = $this->get_columns();
775 + $column = '';
828 776
829 777 // 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 ) {
778 + // so let's fall back to the first non-checkbox column.
779 + foreach ( $columns as $col => $column_name ) {
832 780 if ( 'cb' === $col ) {
833 781 continue;
834 782 }
835 783
@@ -843,8 +791,9 @@
843 791 /**
844 792 * Gets the name of the primary column.
845 793 *
846 794 * @since 4.3.0
795 + * @access protected
847 796 *
848 797 * @return string The name of the primary column.
849 798 */
850 799 protected function get_primary_column_name() {
@@ -851,9 +800,9 @@
851 800 $columns = $this->get_columns();
852 801 $default = $this->get_default_primary_column_name();
853 802
854 803 // If the primary column doesn't exist fall back to the
855 - // First non-checkbox column.
804 + // first non-checkbox column.
856 805 if ( ! isset( $columns[ $default ] ) ) {
857 806 $default = self::get_default_primary_column_name();
858 807 }
859 808
@@ -866,10 +815,10 @@
866 815 * @param string $context Screen ID for specific list table, e.g. 'plugins'.
867 816 */
868 817 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
869 818
870 - if ( ! $column || ! isset( $columns[ $column ] ) ) {
871 - return $default;
819 + if ( empty( $column ) || ! isset( $columns[ $column ] ) ) {
820 + $column = $default;
872 821 }
873 822
874 823 return $column;
875 824 }
@@ -877,18 +826,18 @@
877 826 /**
878 827 * Get a list of all, hidden and sortable columns, with filter applied
879 828 *
880 829 * @since 2.0.18
830 + * @access protected
881 831 *
882 832 * @return array
883 833 */
884 834 protected function get_column_info() {
885 835 // $_column_headers is already set / cached
886 - if ( is_array( $this->_column_headers ) ) {
836 + if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
887 837 // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
888 838 // In 4.3, we added a fourth argument for primary column.
889 839 $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
890 -
891 840 foreach ( $this->_column_headers as $key => $value ) {
892 841 $column_headers[ $key ] = $value;
893 842 }
894 843
@@ -896,8 +845,10 @@
896 845 }
897 846
898 847 $columns = get_column_headers( $this->screen );
899 848 $hidden = get_hidden_columns( $this->screen );
849 +
850 + $sortable_columns = $this->get_sortable_columns();
900 851 /**
901 852 * Filter the list table sortable columns for a specific screen.
902 853 *
903 854 * The dynamic portion of the hook name, `$this->screen->id`, refers
@@ -906,19 +857,17 @@
906 857 * @since 3.5.0
907 858 *
908 859 * @param array $sortable_columns An array of sortable columns.
909 860 */
910 - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
861 + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
911 862
912 863 $sortable = array();
913 -
914 864 foreach ( $_sortable as $id => $data ) {
915 - if ( ! $data ) {
865 + if ( empty( $data ) ) {
916 866 continue;
917 867 }
918 868
919 869 $data = (array) $data;
920 -
921 870 if ( ! isset( $data[1] ) ) {
922 871 $data[1] = false;
923 872 }
924 873
@@ -935,14 +884,15 @@
935 884 /**
936 885 * Return number of visible columns
937 886 *
938 887 * @since 2.0.18
888 + * @access public
939 889 *
940 890 * @return int
941 891 */
942 892 public function get_column_count() {
943 893 list ( $columns, $hidden ) = $this->get_column_info();
944 - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
894 + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
945 895
946 896 return count( $columns ) - count( $hidden );
947 897 }
948 898
@@ -949,49 +899,53 @@
949 899 /**
950 900 * Print column headers, accounting for hidden and sortable columns.
951 901 *
952 902 * @since 2.0.18
903 + * @access public
953 904 *
954 905 * @staticvar int $cb_counter
955 906 *
956 - * @param bool $with_id Whether to set the id attribute or not.
957 - *
958 - * @return void
907 + * @param bool $with_id Whether to set the id attribute or not
959 908 */
960 - public function print_column_headers( $with_id = true ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh, Generic.Metrics.CyclomaticComplexity.MaxExceeded, SlevomatCodingStandard.Files.LineLength.LineTooLong
909 + public function print_column_headers( $with_id = true ) {
961 910 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
962 911
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';
912 + $current_url = set_url_scheme( 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' ) );
913 + $current_url = remove_query_arg( 'paged', $current_url );
967 914
968 - FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
915 + if ( isset( $_GET['orderby'] ) ) {
916 + $current_orderby = sanitize_text_field( wp_unslash( $_GET['orderby'] ) );
917 + } else {
918 + $current_orderby = '';
919 + }
969 920
921 + if ( isset( $_GET['order'] ) && 'desc' == $_GET['order'] ) {
922 + $current_order = 'desc';
923 + } else {
924 + $current_order = 'asc';
925 + }
926 +
970 927 if ( ! empty( $columns['cb'] ) ) {
971 928 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;
929 + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
930 + $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
931 + $cb_counter ++;
975 932 }
976 933
977 934 foreach ( $columns as $column_key => $column_display_name ) {
978 - $class = array( 'manage-column', "column-$column_key" );
979 - $aria_sort_attr = '';
980 - $order_text = '';
935 + $class = array( 'manage-column', "column-$column_key" );
981 936
982 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
983 937 if ( in_array( $column_key, $hidden ) ) {
984 938 $class[] = 'hidden';
985 939 }
986 940
987 - if ( 'cb' === $column_key ) {
941 + if ( 'cb' == $column_key ) {
988 942 $class[] = 'check-column';
989 - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
943 + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
990 944 $class[] = 'num';
991 945 }
992 946
993 - if ( $column_key === $primary || $column_key === 'name' ) {
947 + if ( $column_key === $primary ) {
994 948 $class[] = 'column-primary';
995 949 }
996 950
997 951 if ( isset( $sortable[ $column_key ] ) ) {
@@ -996,19 +950,10 @@
996 950
997 951 if ( isset( $sortable[ $column_key ] ) ) {
998 952 list( $orderby, $desc_first ) = $sortable[ $column_key ];
999 953
1000 - // phpcs:ignore Universal.Operators.StrictComparisons
1001 954 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 -
955 + $order = 'asc' == $current_order ? 'desc' : 'asc';
1011 956 $class[] = 'sorted';
1012 957 $class[] = $current_order;
1013 958 } else {
1014 959 $order = $desc_first ? 'desc' : 'asc';
@@ -1013,41 +958,19 @@
1013 958 } else {
1014 959 $order = $desc_first ? 'desc' : 'asc';
1015 960 $class[] = 'sortable';
1016 961 $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 962 }
1028 963
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
964 + $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>';
965 + }
1043 966
1044 - $tag = 'cb' === $column_key ? 'td' : 'th';
1045 - $scope = 'th' === $tag ? 'scope="col"' : '';
967 + $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
968 + $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
1046 969 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
1047 970
1048 - if ( $class ) {
1049 - $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
971 + if ( ! empty( $class ) ) {
972 + $class = "class='" . esc_attr( join( ' ', $class ) ) . "'";
1050 973 }
1051 974
1052 975 if ( ! $this->has_min_items() && ! $with_id ) {
1053 976 // Hide the labels but show the border.
@@ -1052,10 +975,10 @@
1052 975 if ( ! $this->has_min_items() && ! $with_id ) {
1053 976 // Hide the labels but show the border.
1054 977 $column_display_name = '';
1055 978 }
1056 - echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1057 - }//end foreach
979 + echo "<$tag $scope $id $class>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
980 + }
1058 981 }
1059 982
1060 983 /**
1061 984 * Display the table
@@ -1060,27 +983,18 @@
1060 983 /**
1061 984 * Display the table
1062 985 *
1063 986 * @since 2.0.18
1064 - *
1065 - * @param array $args
1066 - *
1067 - * @return void
987 + * @access public
1068 988 */
1069 - public function display( $args = array() ) {
989 + public function display() {
1070 990 $singular = $this->_args['singular'];
1071 991 $tbody_params = array();
1072 -
1073 992 if ( $singular ) {
1074 993 $tbody_params['data-wp-lists'] = 'list:' . $singular;
1075 994 }
1076 995
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
996 + $this->display_tablenav( 'top' );
1083 997 ?>
1084 998 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1085 999 <?php if ( $this->has_min_items( 1 ) ) { ?>
1086 1000 <thead>
@@ -1093,9 +1007,9 @@
1093 1007 <tbody id="the-list"<?php FrmAppHelper::array_to_html_params( $tbody_params, true ); ?>>
1094 1008 <?php $this->display_rows_or_placeholder(); ?>
1095 1009 </tbody>
1096 1010
1097 - <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?>
1011 + <?php if ( $this->has_min_items( 1 ) ) { ?>
1098 1012 <tfoot>
1099 1013 <tr>
1100 1014 <?php $this->print_column_headers( false ); ?>
1101 1015 </tr>
@@ -1102,31 +1016,16 @@
1102 1016 </tfoot>
1103 1017 <?php } ?>
1104 1018 </table>
1105 1019 <?php
1106 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1107 -
1108 - if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1109 - $this->display_tablenav( 'bottom' );
1110 - }
1020 + $this->display_tablenav( 'bottom' );
1111 1021 }
1112 1022
1113 1023 /**
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 1024 * Get a list of CSS classes for the list table table tag.
1127 1025 *
1128 1026 * @since 2.0.18
1027 + * @access protected
1129 1028 *
1130 1029 * @return array List of CSS classes for the table tag.
1131 1030 */
1132 1031 protected function get_table_classes() {
@@ -1136,8 +1035,9 @@
1136 1035 /**
1137 1036 * Generate the table navigation above or below the table
1138 1037 *
1139 1038 * @since 2.0.18
1039 + * @access protected
1140 1040 *
1141 1041 * @param string $which
1142 1042 */
1143 1043 protected function display_tablenav( $which ) {
@@ -1142,18 +1042,16 @@
1142 1042 */
1143 1043 protected function display_tablenav( $which ) {
1144 1044 if ( 'top' === $which ) {
1145 1045 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1146 -
1147 1046 if ( ! $this->has_min_items( 1 ) ) {
1148 1047 // Don't show bulk actions if no items.
1149 1048 return;
1150 1049 }
1151 1050 } elseif ( ! $this->has_min_items() ) {
1152 - // Don't show the bulk actions when there aren't many rows.
1051 + // don't show the bulk actions when there aren't many rows.
1153 1052 return;
1154 1053 }
1155 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
1156 1054 ?>
1157 1055 <div class="tablenav <?php echo esc_attr( $which ); ?>">
1158 1056
1159 1057 <div class="alignleft actions bulkactions">
@@ -1166,9 +1064,8 @@
1166 1064
1167 1065 <br class="clear"/>
1168 1066 </div>
1169 1067 <?php
1170 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
1171 1068 }
1172 1069
1173 1070 /**
1174 1071 * Use this to exclude the footer labels and bulk items.
@@ -1174,12 +1071,8 @@
1174 1071 * Use this to exclude the footer labels and bulk items.
1175 1072 * When close together, it feels like duplicates.
1176 1073 *
1177 1074 * @since 4.07
1178 - *
1179 - * @param int $limit
1180 - *
1181 - * @return bool
1182 1075 */
1183 1076 protected function has_min_items( $limit = 5 ) {
1184 1077 return $this->has_items() && ( $this->total_items === false || $this->total_items >= $limit );
1185 1078 }
@@ -1187,8 +1080,9 @@
1187 1080 /**
1188 1081 * Extra controls to be displayed between bulk actions and pagination
1189 1082 *
1190 1083 * @since 2.0.18
1084 + * @access protected
1191 1085 *
1192 1086 * @param string $which
1193 1087 */
1194 1088 protected function extra_tablenav( $which ) {
@@ -1197,8 +1091,9 @@
1197 1091 /**
1198 1092 * Generate the tbody element for the list table.
1199 1093 *
1200 1094 * @since 2.0.18
1095 + * @access public
1201 1096 */
1202 1097 public function display_rows_or_placeholder() {
1203 1098 if ( $this->has_items() ) {
1204 1099 $this->display_rows();
@@ -1212,10 +1107,11 @@
1212 1107 /**
1213 1108 * Generates content for a single row of the table
1214 1109 *
1215 1110 * @since 2.0.18
1111 + * @access public
1216 1112 *
1217 - * @param stdClass $item The current item.
1113 + * @param object $item The current item
1218 1114 */
1219 1115 public function single_row( $item ) {
1220 1116 echo '<tr>';
1221 1117 $this->single_row_columns( $item );
@@ -1225,10 +1121,11 @@
1225 1121 /**
1226 1122 * Generates the columns for a single row of the table
1227 1123 *
1228 1124 * @since 2.0.18
1125 + * @access protected
1229 1126 *
1230 - * @param object $item The current item.
1127 + * @param object $item The current item
1231 1128 */
1232 1129 protected function single_row_columns( $item ) {
1233 1130 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1234 1131
@@ -1233,14 +1130,12 @@
1233 1130 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1234 1131
1235 1132 foreach ( $columns as $column_name => $column_display_name ) {
1236 1133 $classes = "$column_name column-$column_name";
1237 -
1238 1134 if ( $primary === $column_name ) {
1239 1135 $classes .= ' has-row-actions column-primary';
1240 1136 }
1241 1137
1242 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
1243 1138 if ( in_array( $column_name, $hidden ) ) {
1244 1139 $classes .= ' hidden';
1245 1140 }
1246 1141
@@ -1252,8 +1147,16 @@
1252 1147 );
1253 1148
1254 1149 if ( 'cb' === $column_name ) {
1255 1150 echo '<th scope="row" class="check-column"></th>';
1151 + } elseif ( method_exists( $this, '_column_' . $column_name ) ) {
1152 + echo call_user_func( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1153 + array( $this, '_column_' . $column_name ),
1154 + $item,
1155 + $classes,
1156 + $data,
1157 + $primary
1158 + );
1256 1159 } else {
1257 1160 echo '<td ';
1258 1161 FrmAppHelper::array_to_html_params( $params, true );
1259 1162 echo '>';
@@ -1264,9 +1167,9 @@
1264 1167
1265 1168 echo $this->handle_row_actions( $item, $column_name, $primary ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1266 1169 echo '</td>';
1267 1170 }
1268 - }//end foreach
1171 + }
1269 1172 }
1270 1173
1271 1174 /**
1272 1175 * Generates and display row actions links for the list table.
@@ -1271,8 +1174,9 @@
1271 1174 /**
1272 1175 * Generates and display row actions links for the list table.
1273 1176 *
1274 1177 * @since 4.3.0
1178 + * @access protected
1275 1179 *
1276 1180 * @param object $item The item being acted upon.
1277 1181 * @param string $column_name Current column name.
1278 1182 * @param string $primary Primary column name.
@@ -1279,9 +1183,9 @@
1279 1183 *
1280 1184 * @return string The row actions output. In this case, an empty string.
1281 1185 */
1282 1186 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
1187 + return $column_name == $primary ? '<button type="button" class="toggle-row"><span class="screen-reader-text">' . esc_html__( 'Show more details', 'formidable' ) . '</span></button>' : '';
1284 1188 }
1285 1189
1286 1190 /**
1287 1191 * Handle an incoming ajax request (called from admin-ajax.php)
@@ -1286,14 +1190,14 @@
1286 1190 /**
1287 1191 * Handle an incoming ajax request (called from admin-ajax.php)
1288 1192 *
1289 1193 * @since 2.0.18
1194 + * @access public
1290 1195 */
1291 1196 public function ajax_response() {
1292 1197 $this->prepare_items();
1293 1198
1294 1199 ob_start();
1295 -
1296 1200 if ( ! empty( $_REQUEST['no_placeholder'] ) ) {
1297 1201 $this->display_rows();
1298 1202 } else {
1299 1203 $this->display_rows_or_placeholder();
@@ -1298,9 +1202,10 @@
1298 1202 } else {
1299 1203 $this->display_rows_or_placeholder();
1300 1204 }
1301 1205
1302 - $rows = ob_get_clean();
1206 + $rows = ob_get_clean();
1207 +
1303 1208 $response = array( 'rows' => $rows );
1304 1209
1305 1210 if ( isset( $this->_pagination_args['total_items'] ) ) {
1306 1211 $response['total_items_i18n'] = sprintf(
@@ -1308,9 +1213,8 @@
1308 1213 _n( '%s item', '%s items', $this->_pagination_args['total_items'], 'formidable' ),
1309 1214 number_format_i18n( $this->_pagination_args['total_items'] )
1310 1215 );
1311 1216 }
1312 -
1313 1217 if ( isset( $this->_pagination_args['total_pages'] ) ) {
1314 1218 $response['total_pages'] = $this->_pagination_args['total_pages'];
1315 1219 $response['total_pages_i18n'] = number_format_i18n( $this->_pagination_args['total_pages'] );
1316 1220 }
@@ -1320,9 +1224,9 @@
1320 1224
1321 1225 /**
1322 1226 * Send required variables to JavaScript land
1323 1227 *
1324 - * @return void
1228 + * @access public
1325 1229 */
1326 1230 public function _js_vars() {
1327 1231 $args = array(
1328 1232 'class' => get_class( $this ),
@@ -1332,13 +1236,6 @@
1332 1236 ),
1333 1237 );
1334 1238
1335 1239 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 1240 }
1344 1241 }