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 +116 -155 6.255.0 View file →
@@ -8,14 +8,14 @@
8 8 * The current list of items
9 9 *
10 10 * @since 2.0.18
11 11 * @var array
12 + * @access public
12 13 */
13 14 public $items;
14 15
15 16 /**
16 17 * @since 4.07
17 - * @var bool|int
18 18 */
19 19 public $total_items = false;
20 20
21 21 /**
@@ -22,8 +22,9 @@
22 22 * Various information about the current table
23 23 *
24 24 * @since 2.0.18
25 25 * @var array
26 + * @access protected
26 27 */
27 28 protected $_args;
28 29
29 30 /**
@@ -37,10 +38,10 @@
37 38 /**
38 39 * The current screen
39 40 *
40 41 * @since 2.0.18
41 - *
42 - * @var \WP_Screen
42 + * @var object
43 + * @access protected
43 44 */
44 45 protected $screen;
45 46
46 47 /**
@@ -47,8 +48,9 @@
47 48 * Cached bulk actions
48 49 *
49 50 * @since 2.0.18
50 51 * @var array
52 + * @access private
51 53 */
52 54 private $_actions;
53 55
54 56 /**
@@ -55,8 +57,9 @@
55 57 * Cached pagination output
56 58 *
57 59 * @since 2.0.18
58 60 * @var string
61 + * @access private
59 62 */
60 63 private $_pagination;
61 64
62 65 /**
@@ -63,12 +66,14 @@
63 66 * The view switcher modes.
64 67 *
65 68 * @since 2.0.18
66 69 * @var array
70 + * @access protected
67 71 */
68 72 protected $modes = array();
69 73
70 74 /**
75 + *
71 76 * @var array
72 77 */
73 78 protected $params;
74 79
@@ -150,9 +155,9 @@
150 155 }
151 156
152 157 public function display_rows() {
153 158 foreach ( $this->items as $item ) {
154 - echo "\n\t", $this->single_row( $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
159 + echo "\n\t", $this->single_row( $item ); // WPCS: XSS ok.
155 160 }
156 161 }
157 162
158 163 /**
@@ -160,8 +165,9 @@
160 165 *
161 166 * @uses FrmListHelper::set_pagination_args()
162 167 *
163 168 * @since 2.0.18
169 + * @access public
164 170 * @abstract
165 171 */
166 172 public function prepare_items() {
167 173 die( 'function FrmListHelper::prepare_items() must be over-ridden in a sub-class.' );
@@ -173,10 +179,10 @@
173 179 protected function get_param( $args ) {
174 180 return FrmAppHelper::get_simple_request(
175 181 array(
176 182 'param' => $args['param'],
177 - 'default' => $args['default'] ?? '',
178 - 'sanitize' => $args['sanitize'] ?? 'sanitize_title',
183 + 'default' => isset( $args['default'] ) ? $args['default'] : '',
184 + 'sanitize' => isset( $args['sanitize'] ) ? $args['sanitize'] : 'sanitize_title',
179 185 'type' => 'request',
180 186 )
181 187 );
182 188 }
@@ -183,9 +189,13 @@
183 189
184 190 /**
185 191 * An internal method that sets all the necessary pagination arguments
186 192 *
187 - * @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
188 198 */
189 199 protected function set_pagination_args( $args ) {
190 200 $args = wp_parse_args(
191 201 $args,
@@ -212,8 +222,9 @@
212 222 /**
213 223 * Access the pagination args.
214 224 *
215 225 * @since 2.0.18
226 + * @access public
216 227 *
217 228 * @param string $key Pagination argument to retrieve. Common values include 'total_items',
218 229 * 'total_pages', 'per_page', or 'infinite_scroll'.
219 230 *
@@ -232,8 +243,9 @@
232 243 /**
233 244 * Whether the table has items to display or not
234 245 *
235 246 * @since 2.0.18
247 + * @access public
236 248 *
237 249 * @return bool
238 250 */
239 251 public function has_items() {
@@ -243,8 +255,9 @@
243 255 /**
244 256 * Message to be displayed when there are no items
245 257 *
246 258 * @since 2.0.18
259 + * @access public
247 260 */
248 261 public function no_items() {
249 262 esc_html_e( 'No items found.', 'formidable' );
250 263 }
@@ -252,11 +265,12 @@
252 265 /**
253 266 * Display the search box.
254 267 *
255 268 * @since 2.0.18
269 + * @access public
256 270 *
257 - * @param string $text The search button text.
258 - * @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
259 273 */
260 274 public function search_box( $text, $input_id ) {
261 275 if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
262 276 return;
@@ -280,8 +294,9 @@
280 294 * Get an associative array ( id => link ) with the list
281 295 * of views available on this table.
282 296 *
283 297 * @since 2.0.18
298 + * @access protected
284 299 *
285 300 * @return array
286 301 */
287 302 protected function get_views() {
@@ -291,8 +306,9 @@
291 306 /**
292 307 * Display the list of views available on this table.
293 308 *
294 309 * @since 2.0.18
310 + * @access public
295 311 */
296 312 public function views() {
297 313 $views = $this->get_views();
298 314 /**
@@ -314,9 +330,9 @@
314 330 echo "<ul class='subsubsub'>\n";
315 331 foreach ( $views as $class => $view ) {
316 332 $views[ $class ] = "\t" . '<li class="' . esc_attr( $class ) . '">' . $view;
317 333 }
318 - echo implode( " |</li>\n", $views ) . "</li>\n"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
334 + echo implode( " |</li>\n", $views ) . "</li>\n"; // WPCS: XSS ok.
319 335 echo '</ul>';
320 336 }
321 337
322 338 /**
@@ -323,8 +339,9 @@
323 339 * Get an associative array ( option_name => option_title ) with the list
324 340 * of bulk actions available on this table.
325 341 *
326 342 * @since 2.0.18
343 + * @access protected
327 344 *
328 345 * @return array
329 346 */
330 347 protected function get_bulk_actions() {
@@ -334,8 +351,9 @@
334 351 /**
335 352 * Display the bulk actions dropdown.
336 353 *
337 354 * @since 2.0.18
355 + * @access protected
338 356 *
339 357 * @param string $which The location of the bulk actions: 'top' or 'bottom'.
340 358 * This is designated as optional for backwards-compatibility.
341 359 */
@@ -361,29 +379,22 @@
361 379
362 380 $two = '';
363 381 } else {
364 382 $two = '2';
365 - }//end if
383 + }
366 384
367 385 if ( empty( $this->_actions ) ) {
368 386 return;
369 387 }
370 388
371 - 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>';
372 390 echo "<select name='action" . esc_attr( $two ) . "' id='bulk-action-selector-" . esc_attr( $which ) . "'>\n";
373 - 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";
374 392
375 393 foreach ( $this->_actions as $name => $title ) {
376 - $params = array(
377 - 'value' => $name,
378 - );
379 - if ( 'edit' === $name ) {
380 - $params['class'] = 'hide-if-no-js';
381 - }
394 + $class = 'edit' == $name ? ' class="hide-if-no-js"' : '';
382 395
383 - echo "\t<option ";
384 - FrmAppHelper::array_to_html_params( $params, true );
385 - echo '>' . esc_html( $title ) . '</option>' . "\n";
396 + echo "\t<option value='" . esc_attr( $name ) . "'$class>" . esc_html( $title ) . "</option>\n"; // WPCS: XSS ok.
386 397 }
387 398
388 399 echo "</select>\n";
389 400
@@ -390,21 +401,9 @@
390 401 if ( isset( $this->_actions['bulk_delete'] ) ) {
391 402 $verify = $this->confirm_bulk_delete();
392 403
393 404 if ( $verify ) {
394 - $confirm_delete_attributes = array(
395 - 'id' => 'confirm-bulk-delete-' . $which,
396 - 'class' => 'frm-hidden',
397 - 'tabindex' => '-1',
398 - 'aria-hidden' => 'true',
399 - 'href' => 'confirm-bulk-delete',
400 - 'data-loaded-from' => $this->loaded_from(),
401 - 'data-frmverify' => $verify,
402 - 'data-frmverify-btn' => 'frm-button-red',
403 - );
404 -
405 - // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
406 - 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>";
407 406 }
408 407 }
409 408
410 409 submit_button( __( 'Apply', 'formidable' ), 'action', '', false, array( 'id' => "doaction$two" ) );
@@ -421,13 +420,14 @@
421 420 /**
422 421 * Get the current action selected from the bulk actions dropdown.
423 422 *
424 423 * @since 2.0.18
424 + * @access public
425 425 *
426 - * @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
427 427 */
428 428 public function current_action() {
429 - if ( ! empty( $_REQUEST['filter_action'] ) ) {
429 + if ( isset( $_REQUEST['filter_action'] ) && ! empty( $_REQUEST['filter_action'] ) ) {
430 430 return false;
431 431 }
432 432
433 433 $action = $this->get_bulk_action( 'action' );
@@ -437,11 +437,11 @@
437 437
438 438 return $action;
439 439 }
440 440
441 - private function get_bulk_action( $action_name ) {
441 + private static function get_bulk_action( $action_name ) {
442 442 $action = false;
443 - $action_param = $this->get_param(
443 + $action_param = self::get_param(
444 444 array(
445 445 'param' => $action_name,
446 446 'sanitize' => 'sanitize_text_field',
447 447 )
@@ -456,11 +456,12 @@
456 456 /**
457 457 * Generate row actions div
458 458 *
459 459 * @since 2.0.18
460 + * @access protected
460 461 *
461 - * @param array $actions The list of actions.
462 - * @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
463 464 *
464 465 * @return string
465 466 */
466 467 protected function row_actions( $actions, $always_visible = false ) {
@@ -473,10 +474,10 @@
473 474 }
474 475
475 476 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
476 477 foreach ( $actions as $action => $link ) {
477 - ++$i;
478 - $sep = $i == $action_count ? '' : ' | ';
478 + ++ $i;
479 + ( $i == $action_count ) ? $sep = '' : $sep = ' | ';
479 480 $out .= "<span class='$action'>$link$sep</span>";
480 481 }
481 482 $out .= '</div>';
482 483
@@ -488,8 +489,9 @@
488 489 /**
489 490 * Display a view switcher
490 491 *
491 492 * @since 2.0.18
493 + * @access protected
492 494 *
493 495 * @param string $current_mode
494 496 */
495 497 protected function view_switcher( $current_mode ) {
@@ -518,8 +520,9 @@
518 520 /**
519 521 * Get the current page number
520 522 *
521 523 * @since 2.0.18
524 + * @access public
522 525 *
523 526 * @return int
524 527 */
525 528 public function get_pagenum() {
@@ -535,11 +538,12 @@
535 538 /**
536 539 * Get number of items to display on a single page
537 540 *
538 541 * @since 2.0.18
542 + * @access protected
539 543 *
540 544 * @param string $option
541 - * @param int $default
545 + * @param int $default
542 546 *
543 547 * @return int
544 548 */
545 549 protected function get_items_per_page( $option, $default = 20 ) {
@@ -567,8 +571,9 @@
567 571 /**
568 572 * Display the pagination.
569 573 *
570 574 * @since 2.0.18
575 + * @access protected
571 576 *
572 577 * @param string $which
573 578 */
574 579 protected function pagination( $which ) {
@@ -650,9 +655,9 @@
650 655 $pagination_links_class = 'pagination-links';
651 656 if ( ! empty( $infinite_scroll ) ) {
652 657 $pagination_links_class = ' hide-if-js';
653 658 }
654 - $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . implode( "\n", $page_links ) . '</span>';
659 + $output .= "\n" . '<span class="' . esc_attr( $pagination_links_class ) . '">' . join( "\n", $page_links ) . '</span>';
655 660
656 661 if ( $total_pages ) {
657 662 $page_class = $total_pages < 2 ? ' one-page' : '';
658 663 } else {
@@ -659,9 +664,9 @@
659 664 $page_class = ' no-pages';
660 665 }
661 666 $this->_pagination = "<div class='tablenav-pages" . esc_attr( $page_class ) . "'>$output</div>";
662 667
663 - echo $this->_pagination; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
668 + echo $this->_pagination; // WPCS: XSS ok.
664 669 }
665 670
666 671 private function disabled_pages( $total_pages ) {
667 672 $current = $this->get_pagenum();
@@ -741,8 +746,9 @@
741 746 *
742 747 * The second format will make the initial sorting order be descending
743 748 *
744 749 * @since 2.0.18
750 + * @access protected
745 751 *
746 752 * @return array
747 753 */
748 754 protected function get_sortable_columns() {
@@ -752,8 +758,9 @@
752 758 /**
753 759 * Gets the name of the default primary column.
754 760 *
755 761 * @since 4.3.0
762 + * @access protected
756 763 *
757 764 * @return string Name of the default primary column, in this case, an empty string.
758 765 */
759 766 protected function get_default_primary_column_name() {
@@ -777,8 +784,9 @@
777 784 /**
778 785 * Gets the name of the primary column.
779 786 *
780 787 * @since 4.3.0
788 + * @access protected
781 789 *
782 790 * @return string The name of the primary column.
783 791 */
784 792 protected function get_primary_column_name() {
@@ -811,14 +819,15 @@
811 819 /**
812 820 * Get a list of all, hidden and sortable columns, with filter applied
813 821 *
814 822 * @since 2.0.18
823 + * @access protected
815 824 *
816 825 * @return array
817 826 */
818 827 protected function get_column_info() {
819 828 // $_column_headers is already set / cached
820 - if ( is_array( $this->_column_headers ) ) {
829 + if ( isset( $this->_column_headers ) && is_array( $this->_column_headers ) ) {
821 830 // Back-compat for list tables that have been manually setting $_column_headers for horse reasons.
822 831 // In 4.3, we added a fourth argument for primary column.
823 832 $column_headers = array( array(), array(), array(), $this->get_primary_column_name() );
824 833 foreach ( $this->_column_headers as $key => $value ) {
@@ -868,14 +877,15 @@
868 877 /**
869 878 * Return number of visible columns
870 879 *
871 880 * @since 2.0.18
881 + * @access public
872 882 *
873 883 * @return int
874 884 */
875 885 public function get_column_count() {
876 886 list ( $columns, $hidden ) = $this->get_column_info();
877 - $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
887 + $hidden = array_intersect( array_keys( $columns ), array_filter( $hidden ) );
878 888
879 889 return count( $columns ) - count( $hidden );
880 890 }
881 891
@@ -882,13 +892,13 @@
882 892 /**
883 893 * Print column headers, accounting for hidden and sortable columns.
884 894 *
885 895 * @since 2.0.18
896 + * @access public
886 897 *
887 898 * @staticvar int $cb_counter
888 899 *
889 - * @param bool $with_id Whether to set the id attribute or not.
890 - * @return void
900 + * @param bool $with_id Whether to set the id attribute or not
891 901 */
892 902 public function print_column_headers( $with_id = true ) {
893 903 list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info();
894 904
@@ -906,33 +916,29 @@
906 916 } else {
907 917 $current_order = 'asc';
908 918 }
909 919
910 - FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
911 -
912 920 if ( ! empty( $columns['cb'] ) ) {
913 921 static $cb_counter = 1;
914 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
915 - $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
916 - ++$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 ++;
917 925 }
918 926
919 927 foreach ( $columns as $column_key => $column_display_name ) {
920 - $class = array( 'manage-column', "column-$column_key" );
921 - $aria_sort_attr = '';
922 - $order_text = '';
928 + $class = array( 'manage-column', "column-$column_key" );
923 929
924 930 if ( in_array( $column_key, $hidden ) ) {
925 931 $class[] = 'hidden';
926 932 }
927 933
928 - if ( 'cb' === $column_key ) {
934 + if ( 'cb' == $column_key ) {
929 935 $class[] = 'check-column';
930 - } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ), true ) ) {
936 + } elseif ( in_array( $column_key, array( 'posts', 'comments', 'links' ) ) ) {
931 937 $class[] = 'num';
932 938 }
933 939
934 - if ( $column_key === $primary || $column_key === 'name' ) {
940 + if ( $column_key === $primary ) {
935 941 $class[] = 'column-primary';
936 942 }
937 943
938 944 if ( isset( $sortable[ $column_key ] ) ) {
@@ -938,17 +944,9 @@
938 944 if ( isset( $sortable[ $column_key ] ) ) {
939 945 list( $orderby, $desc_first ) = $sortable[ $column_key ];
940 946
941 947 if ( $current_orderby == $orderby ) {
942 - // The sorted column. The `aria-sort` attribute must be set only on the sorted column.
943 - if ( 'asc' === $current_order ) {
944 - $order = 'desc';
945 - $aria_sort_attr = ' aria-sort="ascending"';
946 - } else {
947 - $order = 'asc';
948 - $aria_sort_attr = ' aria-sort="descending"';
949 - }
950 -
948 + $order = 'asc' == $current_order ? 'desc' : 'asc';
951 949 $class[] = 'sorted';
952 950 $class[] = $current_order;
953 951 } else {
954 952 $order = $desc_first ? 'desc' : 'asc';
@@ -953,41 +951,19 @@
953 951 } else {
954 952 $order = $desc_first ? 'desc' : 'asc';
955 953 $class[] = 'sortable';
956 954 $class[] = $desc_first ? 'asc' : 'desc';
957 -
958 - /* translators: Hidden accessibility text. */
959 - $asc_text = __( 'Sort ascending.', 'formidable' );
960 - /* translators: Hidden accessibility text. */
961 - $desc_text = __( 'Sort descending.', 'formidable' );
962 - $order_text = 'asc' === $order ? $asc_text : $desc_text;
963 - }//end if
964 -
965 - if ( '' !== $order_text ) {
966 - $order_text = ' <span class="screen-reader-text">' . $order_text . '</span>';
967 955 }
968 956
969 - $column_display_name = sprintf(
970 - '<a href="%1$s">' .
971 - '<span>%2$s</span>' .
972 - '<span class="sorting-indicators">' .
973 - '<span class="sorting-indicator asc" aria-hidden="true"></span>' .
974 - '<span class="sorting-indicator desc" aria-hidden="true"></span>' .
975 - '</span>' .
976 - '%3$s' .
977 - '</a>',
978 - esc_url( add_query_arg( compact( 'orderby', 'order' ), $current_url ) ),
979 - $column_display_name,
980 - $order_text
981 - );
982 - }//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 + }
983 959
984 - $tag = 'cb' === $column_key ? 'td' : 'th';
985 - $scope = 'th' === $tag ? 'scope="col"' : '';
960 + $tag = ( 'cb' === $column_key ) ? 'td' : 'th';
961 + $scope = ( 'th' === $tag ) ? 'scope="col"' : '';
986 962 $id = $with_id ? "id='" . esc_attr( $column_key ) . "'" : '';
987 963
988 964 if ( ! empty( $class ) ) {
989 - $class = "class='" . esc_attr( implode( ' ', $class ) ) . "'";
965 + $class = "class='" . esc_attr( join( ' ', $class ) ) . "'";
990 966 }
991 967
992 968 if ( ! $this->has_min_items() && ! $with_id ) {
993 969 // Hide the labels but show the border.
@@ -992,10 +968,10 @@
992 968 if ( ! $this->has_min_items() && ! $with_id ) {
993 969 // Hide the labels but show the border.
994 970 $column_display_name = '';
995 971 }
996 - echo "<$tag $scope $id $class $aria_sort_attr>$column_display_name</$tag>"; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
997 - }//end foreach
972 + echo "<$tag $scope $id $class>$column_display_name</$tag>"; // WPCS: XSS ok.
973 + }
998 974 }
999 975
1000 976 /**
1001 977 * Display the table
@@ -1000,21 +976,14 @@
1000 976 /**
1001 977 * Display the table
1002 978 *
1003 979 * @since 2.0.18
1004 - * @param array $args
980 + * @access public
1005 981 */
1006 - public function display( $args = array() ) {
1007 - $singular = $this->_args['singular'];
1008 - $tbody_params = array();
1009 - if ( $singular ) {
1010 - $tbody_params['data-wp-lists'] = 'list:' . $singular;
1011 - }
1012 - if ( $this->should_display( $args, 'display-top-nav' ) ) {
1013 - $this->display_tablenav( 'top' );
1014 - }
1015 - $this->screen->render_screen_reader_content( 'heading_list' );
982 + public function display() {
983 + $singular = $this->_args['singular'];
1016 984
985 + $this->display_tablenav( 'top' );
1017 986 ?>
1018 987 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1019 988 <?php if ( $this->has_min_items( 1 ) ) { ?>
1020 989 <thead>
@@ -1023,13 +992,13 @@
1023 992 </tr>
1024 993 </thead>
1025 994 <?php } ?>
1026 995
1027 - <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. ?>>
1028 997 <?php $this->display_rows_or_placeholder(); ?>
1029 998 </tbody>
1030 999
1031 - <?php if ( $this->has_min_items( 1 ) && $this->should_display( $args, 'display-bottom-headers' ) ) { ?>
1000 + <?php if ( $this->has_min_items( 1 ) ) { ?>
1032 1001 <tfoot>
1033 1002 <tr>
1034 1003 <?php $this->print_column_headers( false ); ?>
1035 1004 </tr>
@@ -1036,29 +1005,16 @@
1036 1005 </tfoot>
1037 1006 <?php } ?>
1038 1007 </table>
1039 1008 <?php
1040 - if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1041 - $this->display_tablenav( 'bottom' );
1042 - }
1009 + $this->display_tablenav( 'bottom' );
1043 1010 }
1044 1011
1045 1012 /**
1046 - * Determines if a particular feature or element should be displayed.
1047 - *
1048 - * @param array $args An associative array of arguments.
1049 - * @param string $settings The specific setting key to check within the arguments array.
1050 - *
1051 - * @return bool Returns true if the setting is not set or if it is not false; otherwise, returns false.
1052 - */
1053 - protected function should_display( $args, $settings ) {
1054 - return ! isset( $args[ $settings ] ) || false !== $args[ $settings ];
1055 - }
1056 -
1057 - /**
1058 1013 * Get a list of CSS classes for the list table table tag.
1059 1014 *
1060 1015 * @since 2.0.18
1016 + * @access protected
1061 1017 *
1062 1018 * @return array List of CSS classes for the table tag.
1063 1019 */
1064 1020 protected function get_table_classes() {
@@ -1068,13 +1024,14 @@
1068 1024 /**
1069 1025 * Generate the table navigation above or below the table
1070 1026 *
1071 1027 * @since 2.0.18
1028 + * @access protected
1072 1029 *
1073 1030 * @param string $which
1074 1031 */
1075 1032 protected function display_tablenav( $which ) {
1076 - if ( 'top' === $which ) {
1033 + if ( 'top' == $which ) {
1077 1034 wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false );
1078 1035 if ( ! $this->has_min_items( 1 ) ) {
1079 1036 // Don't show bulk actions if no items.
1080 1037 return;
@@ -1112,8 +1069,9 @@
1112 1069 /**
1113 1070 * Extra controls to be displayed between bulk actions and pagination
1114 1071 *
1115 1072 * @since 2.0.18
1073 + * @access protected
1116 1074 *
1117 1075 * @param string $which
1118 1076 */
1119 1077 protected function extra_tablenav( $which ) {
@@ -1122,8 +1080,9 @@
1122 1080 /**
1123 1081 * Generate the tbody element for the list table.
1124 1082 *
1125 1083 * @since 2.0.18
1084 + * @access public
1126 1085 */
1127 1086 public function display_rows_or_placeholder() {
1128 1087 if ( $this->has_items() ) {
1129 1088 $this->display_rows();
@@ -1137,10 +1096,11 @@
1137 1096 /**
1138 1097 * Generates content for a single row of the table
1139 1098 *
1140 1099 * @since 2.0.18
1100 + * @access public
1141 1101 *
1142 - * @param object $item The current item.
1102 + * @param object $item The current item
1143 1103 */
1144 1104 public function single_row( $item ) {
1145 1105 echo '<tr>';
1146 1106 $this->single_row_columns( $item );
@@ -1150,10 +1110,11 @@
1150 1110 /**
1151 1111 * Generates the columns for a single row of the table
1152 1112 *
1153 1113 * @since 2.0.18
1114 + * @access protected
1154 1115 *
1155 - * @param object $item The current item.
1116 + * @param object $item The current item
1156 1117 */
1157 1118 protected function single_row_columns( $item ) {
1158 1119 list( $columns, $hidden,, $primary ) = $this->get_column_info();
1159 1120
@@ -1166,30 +1127,35 @@
1166 1127 if ( in_array( $column_name, $hidden ) ) {
1167 1128 $classes .= ' hidden';
1168 1129 }
1169 1130
1170 - $params = array(
1171 - 'class' => $classes,
1172 - // Comments column uses HTML in the display name with screen reader text.
1173 - // Instead of using esc_attr(), we strip tags to get closer to a user-friendly string.
1174 - 'data-colname' => $column_display_name,
1175 - );
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 ) . '"';
1176 1134
1177 - if ( 'cb' === $column_name ) {
1135 + $attributes = 'class="' . esc_attr( $classes ) . '" ' . $data;
1136 +
1137 + if ( 'cb' == $column_name ) {
1178 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>';
1179 1152 } else {
1180 - echo '<td ';
1181 - FrmAppHelper::array_to_html_params( $params, true );
1182 - echo '>';
1183 -
1184 - if ( method_exists( $this, 'column_' . $column_name ) ) {
1185 - echo call_user_func( array( $this, 'column_' . $column_name ), $item ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1186 - }
1187 -
1188 - 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.
1189 1155 echo '</td>';
1190 1156 }
1191 - }//end foreach
1157 + }
1192 1158 }
1193 1159
1194 1160 /**
1195 1161 * Generates and display row actions links for the list table.
@@ -1194,8 +1160,9 @@
1194 1160 /**
1195 1161 * Generates and display row actions links for the list table.
1196 1162 *
1197 1163 * @since 4.3.0
1164 + * @access protected
1198 1165 *
1199 1166 * @param object $item The item being acted upon.
1200 1167 * @param string $column_name Current column name.
1201 1168 * @param string $primary Primary column name.
@@ -1209,8 +1176,9 @@
1209 1176 /**
1210 1177 * Handle an incoming ajax request (called from admin-ajax.php)
1211 1178 *
1212 1179 * @since 2.0.18
1180 + * @access public
1213 1181 */
1214 1182 public function ajax_response() {
1215 1183 $this->prepare_items();
1216 1184
@@ -1242,9 +1210,9 @@
1242 1210
1243 1211 /**
1244 1212 * Send required variables to JavaScript land
1245 1213 *
1246 - * @return void
1214 + * @access public
1247 1215 */
1248 1216 public function _js_vars() {
1249 1217 $args = array(
1250 1218 'class' => get_class( $this ),
@@ -1254,13 +1222,6 @@
1254 1222 ),
1255 1223 );
1256 1224
1257 1225 printf( "<script type='text/javascript'>list_args = %s;</script>\n", wp_json_encode( $args ) );
1258 - }
1259 -
1260 - /**
1261 - * @return string
1262 - */
1263 - protected function loaded_from() {
1264 - return '';
1265 1226 }
1266 1227 }