PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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 +44 -32 6.27 → trunk View file →
@@ -161,8 +161,11 @@
161 161 public function ajax_user_can() {
162 162 return current_user_can( 'administrator' );
163 163 }
164 164
165 + /**
166 + * @return array
167 + */
165 168 public function get_columns() {
166 169 return array();
167 170 }
168 171
@@ -222,10 +225,17 @@
222 225 $args['total_pages'] = ceil( $args['total_items'] / $args['per_page'] );
223 226 }
224 227
225 228 // Redirect if page number is invalid and headers are not already sent.
226 - if ( ! headers_sent() && ! wp_doing_ajax() && $args['total_pages'] > 0 && $this->get_pagenum() > $args['total_pages'] ) {
227 - wp_redirect( add_query_arg( 'paged', $args['total_pages'] ) );
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 );
228 238 exit;
229 239 }
230 240
231 241 $this->_pagination_args = $args;
@@ -294,12 +304,14 @@
294 304 *
295 305 * @return void
296 306 */
297 307 private function hidden_search_inputs( $param_name ) {
298 - if ( ! empty( $_REQUEST[ $param_name ] ) ) {
299 - $value = sanitize_text_field( wp_unslash( $_REQUEST[ $param_name ] ) );
300 - echo '<input type="hidden" name="' . esc_attr( $param_name ) . '" value="' . esc_attr( $value ) . '" />';
308 + if ( empty( $_REQUEST[ $param_name ] ) ) {
309 + return;
301 310 }
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 ) . '" />';
302 314 }
303 315
304 316 /**
305 317 * Get an associative array ( id => link ) with the list
@@ -389,9 +401,9 @@
389 401 } else {
390 402 $two = '2';
391 403 }//end if
392 404
393 - if ( empty( $this->_actions ) ) {
405 + if ( ! $this->_actions ) {
394 406 return;
395 407 }
396 408
397 409 echo "<label for='bulk-action-selector-" . esc_attr( $which ) . "' class='screen-reader-text'>" . esc_html__( 'Select bulk action', 'formidable' ) . '</label>';
@@ -458,13 +470,9 @@
458 470 }
459 471
460 472 $action = $this->get_bulk_action( 'action' );
461 473
462 - if ( $action === false ) {
463 - $action = $this->get_bulk_action( 'action2' );
464 - }
465 -
466 - return $action;
474 + return $action === false ? $this->get_bulk_action( 'action2' ) : $action;
467 475 }
468 476
469 477 /**
470 478 * @param string $action_name
@@ -481,9 +489,9 @@
481 489 );
482 490
483 491 // phpcs:ignore Universal.Operators.StrictComparisons
484 492 if ( $action_param && - 1 != $action_param ) {
485 - $action = $action_param;
493 + return $action_param;
486 494 }
487 495
488 496 return $action;
489 497 }
@@ -499,14 +507,14 @@
499 507 * @return string
500 508 */
501 509 protected function row_actions( $actions, $always_visible = false ) {
502 510 $action_count = count( $actions );
503 - $i = 0;
504 511
505 512 if ( ! $action_count ) {
506 513 return '';
507 514 }
508 515
516 + $i = 0;
509 517 $out = '<div class="' . ( $always_visible ? 'row-actions visible' : 'row-actions' ) . '">';
510 518
511 519 foreach ( $actions as $action => $link ) {
512 520 ++$i;
@@ -526,8 +534,9 @@
526 534 *
527 535 * @param string $current_mode
528 536 */
529 537 protected function view_switcher( $current_mode ) {
538 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
530 539 ?>
531 540 <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>"/>
532 541 <div class="view-switch">
533 542 <?php
@@ -533,10 +542,9 @@
533 542 <?php
534 543 foreach ( $this->modes as $mode => $title ) {
535 544 $classes = array( 'view-' . $mode );
536 545
537 - // phpcs:ignore Universal.Operators.StrictComparisons
538 - if ( $current_mode == $mode ) {
546 + if ( $current_mode === $mode ) {
539 547 $classes[] = 'current';
540 548 }
541 549
542 550 printf(
@@ -548,8 +556,9 @@
548 556 }
549 557 ?>
550 558 </div>
551 559 <?php
560 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
552 561 }
553 562
554 563 /**
555 564 * Get the current page number
@@ -608,9 +617,9 @@
608 617 *
609 618 * @param string $which
610 619 */
611 620 protected function pagination( $which ) {
612 - if ( empty( $this->_pagination_args ) ) {
621 + if ( ! $this->_pagination_args ) {
613 622 return;
614 623 }
615 624
616 625 $total_items = $this->_pagination_args['total_items'];
@@ -649,13 +658,13 @@
649 658 );
650 659
651 660 if ( 'bottom' === $which ) {
652 661 $html_current_page = $current;
653 - $total_pages_before = '<span class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
662 + $total_pages_before = '<span class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</span><span id="table-paging" class="paging-input">';
654 663 } else {
655 664 $html_current_page = sprintf(
656 665 "%s<input class='current-page' id='current-page-selector' type='text' name='paged' value='%s' size='%d' aria-describedby='table-paging' />",
657 - '<label for="current-page-selector" class="screen-reader-text">' . __( 'Current Page', 'formidable' ) . '</label>',
666 + '<label for="current-page-selector" class="screen-reader-text">' . esc_html__( 'Current Page', 'formidable' ) . '</label>',
658 667 $current,
659 668 strlen( $total_pages )
660 669 );
661 670 }
@@ -814,14 +823,13 @@
814 823 *
815 824 * @return string Name of the default primary column, in this case, an empty string.
816 825 */
817 826 protected function get_default_primary_column_name() {
818 - $columns = $this->get_columns();
819 - $column = '';
827 + $column = '';
820 828
821 829 // We need a primary defined so responsive views show something,
822 - // so let's fall back to the first non-checkbox column.
823 - foreach ( $columns as $col => $column_name ) {
830 + // So let's fall back to the first non-checkbox column.
831 + foreach ( $this->get_columns() as $col => $column_name ) {
824 832 if ( 'cb' === $col ) {
825 833 continue;
826 834 }
827 835
@@ -843,9 +851,9 @@
843 851 $columns = $this->get_columns();
844 852 $default = $this->get_default_primary_column_name();
845 853
846 854 // If the primary column doesn't exist fall back to the
847 - // first non-checkbox column.
855 + // First non-checkbox column.
848 856 if ( ! isset( $columns[ $default ] ) ) {
849 857 $default = self::get_default_primary_column_name();
850 858 }
851 859
@@ -859,9 +867,9 @@
859 867 */
860 868 $column = apply_filters( 'list_table_primary_column', $default, $this->screen->id );
861 869
862 870 if ( ! $column || ! isset( $columns[ $column ] ) ) {
863 - $column = $default;
871 + return $default;
864 872 }
865 873
866 874 return $column;
867 875 }
@@ -886,11 +894,10 @@
886 894
887 895 return $column_headers;
888 896 }
889 897
890 - $columns = get_column_headers( $this->screen );
891 - $hidden = get_hidden_columns( $this->screen );
892 - $sortable_columns = $this->get_sortable_columns();
898 + $columns = get_column_headers( $this->screen );
899 + $hidden = get_hidden_columns( $this->screen );
893 900 /**
894 901 * Filter the list table sortable columns for a specific screen.
895 902 *
896 903 * The dynamic portion of the hook name, `$this->screen->id`, refers
@@ -899,14 +906,14 @@
899 906 * @since 3.5.0
900 907 *
901 908 * @param array $sortable_columns An array of sortable columns.
902 909 */
903 - $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $sortable_columns );
910 + $_sortable = apply_filters( "manage_{$this->screen->id}_sortable_columns", $this->get_sortable_columns() );
904 911
905 912 $sortable = array();
906 913
907 914 foreach ( $_sortable as $id => $data ) {
908 - if ( empty( $data ) ) {
915 + if ( ! $data ) {
909 916 continue;
910 917 }
911 918
912 919 $data = (array) $data;
@@ -961,9 +968,9 @@
961 968 FrmAppController::apply_saved_sort_preference( $current_orderby, $current_order );
962 969
963 970 if ( ! empty( $columns['cb'] ) ) {
964 971 static $cb_counter = 1;
965 - $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . __( 'Select All', 'formidable' ) . '</label>';
972 + $columns['cb'] = '<label class="screen-reader-text" for="cb-select-all-' . $cb_counter . '">' . esc_html__( 'Select All', 'formidable' ) . '</label>';
966 973 $columns['cb'] .= '<input id="cb-select-all-' . esc_attr( $cb_counter ) . '" type="checkbox" />';
967 974 ++$cb_counter;
968 975 }
969 976
@@ -1071,8 +1078,9 @@
1071 1078 $this->display_tablenav( 'top' );
1072 1079 }
1073 1080 $this->screen->render_screen_reader_content( 'heading_list' );
1074 1081
1082 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
1075 1083 ?>
1076 1084 <table class="wp-list-table <?php echo esc_attr( implode( ' ', $this->get_table_classes() ) ); ?>">
1077 1085 <?php if ( $this->has_min_items( 1 ) ) { ?>
1078 1086 <thead>
@@ -1094,8 +1102,10 @@
1094 1102 </tfoot>
1095 1103 <?php } ?>
1096 1104 </table>
1097 1105 <?php
1106 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
1107 +
1098 1108 if ( $this->should_display( $args, 'display-bottom-nav' ) ) {
1099 1109 $this->display_tablenav( 'bottom' );
1100 1110 }
1101 1111 }
@@ -1138,11 +1148,12 @@
1138 1148 // Don't show bulk actions if no items.
1139 1149 return;
1140 1150 }
1141 1151 } elseif ( ! $this->has_min_items() ) {
1142 - // don't show the bulk actions when there aren't many rows.
1152 + // Don't show the bulk actions when there aren't many rows.
1143 1153 return;
1144 1154 }
1155 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
1145 1156 ?>
1146 1157 <div class="tablenav <?php echo esc_attr( $which ); ?>">
1147 1158
1148 1159 <div class="alignleft actions bulkactions">
@@ -1155,8 +1166,9 @@
1155 1166
1156 1167 <br class="clear"/>
1157 1168 </div>
1158 1169 <?php
1170 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
1159 1171 }
1160 1172
1161 1173 /**
1162 1174 * Use this to exclude the footer labels and bulk items.
@@ -1201,9 +1213,9 @@
1201 1213 * Generates content for a single row of the table
1202 1214 *
1203 1215 * @since 2.0.18
1204 1216 *
1205 - * @param object $item The current item.
1217 + * @param stdClass $item The current item.
1206 1218 */
1207 1219 public function single_row( $item ) {
1208 1220 echo '<tr>';
1209 1221 $this->single_row_columns( $item );