PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.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/FrmEntriesListHelper.php +53 -95 6.336.16.1 View file →
@@ -4,23 +4,18 @@
4 4 }
5 5
6 6 class FrmEntriesListHelper extends FrmListHelper {
7 7
8 - /**
9 - * @var string|null
10 - */
11 8 protected $column_name;
9 + protected $item;
10 + protected $field;
12 11
13 12 /**
14 13 * @since 4.07
15 - *
16 14 * @var bool|int
17 15 */
18 16 public $total_items = 0;
19 17
20 - /**
21 - * @param array $args
22 - */
23 18 public function __construct( $args ) {
24 19 parent::__construct( $args );
25 20 $this->screen->set_screen_reader_content(
26 21 array(
@@ -33,9 +28,10 @@
33 28 * @return void
34 29 */
35 30 public function prepare_items() {
36 31 $this->set_per_page();
37 - $s_query = array();
32 + $s_query = array();
33 +
38 34 $join_form_in_query = false;
39 35
40 36 $this->items = $this->get_entry_items( $s_query, $join_form_in_query );
41 37 $this->set_total_items( $s_query );
@@ -41,13 +37,8 @@
41 37 $this->set_total_items( $s_query );
42 38 $this->prepare_pagination();
43 39 }
44 40
45 - /**
46 - * @param array $s_query
47 - *
48 - * @return void
49 - */
50 41 protected function set_total_items( $s_query ) {
51 42 $this->total_items = FrmEntry::getRecordCount( $s_query );
52 43 }
53 44
@@ -54,10 +45,8 @@
54 45 /**
55 46 * Prepares pagination.
56 47 *
57 48 * @since 6.5.4
58 - *
59 - * @return void
60 49 */
61 50 protected function prepare_pagination() {
62 51 global $per_page;
63 52
@@ -72,10 +61,8 @@
72 61 /**
73 62 * Sets the global $per_page variable
74 63 *
75 64 * @since 6.5.4
76 - *
77 - * @return void
78 65 */
79 66 protected function set_per_page() {
80 67 global $per_page;
81 68 $per_page = $this->get_items_per_page( 'formidable_page_formidable_entries_per_page' );
@@ -91,16 +78,16 @@
91 78 */
92 79 protected function get_entry_items( &$s_query, &$join_form_in_query ) {
93 80 global $per_page;
94 81 $s_query = $this->get_search_query( $join_form_in_query );
82 + $order = $this->get_order_by();
95 83 $limit = $this->get_limit( $per_page );
96 84
97 - return FrmEntry::getAll( $s_query, $this->get_order_by(), $limit, true, $join_form_in_query );
85 + return FrmEntry::getAll( $s_query, $order, $limit, true, $join_form_in_query );
98 86 }
99 87
100 88 /**
101 89 * @since 6.5.4
102 - *
103 90 * @return string
104 91 */
105 92 protected function get_order_by() {
106 93 $orderby = self::get_param(
@@ -108,9 +95,15 @@
108 95 'param' => 'orderby',
109 96 'default' => 'id',
110 97 )
111 98 );
112 - $order = self::get_param(
99 +
100 + if ( strpos( $orderby, 'meta' ) !== false ) {
101 + $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
102 + $orderby .= in_array( $order_field_type, array( 'number', 'scale', 'star' ) ) ? '+0' : '';
103 + }
104 +
105 + $order = self::get_param(
113 106 array(
114 107 'param' => 'order',
115 108 'default' => 'DESC',
116 109 )
@@ -115,18 +108,8 @@
115 108 'default' => 'DESC',
116 109 )
117 110 );
118 111
119 - FrmAppController::apply_saved_sort_preference( $orderby, $order );
120 -
121 - if ( str_contains( $orderby, 'meta' ) ) {
122 - $order_field_type = FrmField::get_type( str_replace( 'meta_', '', $orderby ) );
123 -
124 - if ( in_array( $order_field_type, array( 'number', 'scale', 'star' ), true ) ) {
125 - $orderby .= '+0';
126 - }
127 - }
128 -
129 112 return FrmDb::esc_order( $orderby . ' ' . $order );
130 113 }
131 114
132 115 /**
@@ -132,9 +115,8 @@
132 115 /**
133 116 * @since 6.5.4
134 117 *
135 118 * @param int $per_page
136 - *
137 119 * @return string
138 120 */
139 121 protected function get_limit( $per_page ) {
140 122 $page = $this->get_pagenum();
@@ -151,9 +133,8 @@
151 133 /**
152 134 * @since 6.5.4
153 135 *
154 136 * @param bool $join_form_in_query
155 - *
156 137 * @return array
157 138 */
158 139 protected function get_search_query( &$join_form_in_query ) {
159 140 $form_id = $this->params['form'];
@@ -177,9 +158,9 @@
177 158 'sanitize' => 'sanitize_text_field',
178 159 )
179 160 );
180 161
181 - if ( $s !== '' && FrmAppHelper::pro_is_installed() ) {
162 + if ( $s != '' && FrmAppHelper::pro_is_installed() ) {
182 163 $fid = self::get_param( array( 'param' => 'fid' ) );
183 164 $s_query = FrmProEntriesHelper::get_search_str( $s_query, $s, $form_id, $fid );
184 165 }
185 166
@@ -189,9 +170,8 @@
189 170 /**
190 171 * @since 6.5.4
191 172 *
192 173 * @param int|string $form_id
193 - *
194 174 * @return array<int>
195 175 */
196 176 protected function get_form_ids( $form_id ) {
197 177 return array( (int) $form_id );
@@ -206,11 +186,11 @@
206 186 'param' => 's',
207 187 'sanitize' => 'sanitize_text_field',
208 188 )
209 189 );
190 + if ( ! empty( $s ) ) {
191 + esc_html_e( 'No Entries Found', 'formidable' );
210 192
211 - if ( $s ) {
212 - esc_html_e( 'No Entries Found', 'formidable' );
213 193 return;
214 194 }
215 195
216 196 $form_id = $this->params['form'];
@@ -218,9 +198,8 @@
218 198
219 199 if ( $form_id ) {
220 200 $form = FrmForm::getOne( $form_id );
221 201 }
222 -
223 202 $has_form = ! empty( $form );
224 203
225 204 if ( ! $has_form ) {
226 205 $has_form = FrmForm::getAll( array(), '', 1 );
@@ -232,11 +211,8 @@
232 211 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php';
233 212 }
234 213
235 214 /**
236 - * @param string $text Text.
237 - * @param string $input_id Input ID.
238 - *
239 215 * @return void
240 216 */
241 217 public function search_box( $text, $input_id ) {
242 218 // Searching is a pro feature
@@ -242,56 +218,42 @@
242 218 // Searching is a pro feature
243 219 }
244 220
245 221 /**
246 - * @param string $which
247 - *
248 222 * @return void
249 223 */
250 224 protected function display_tablenav( $which ) {
251 - $is_footer = $which !== 'top';
252 -
225 + $is_footer = ( $which !== 'top' );
253 226 if ( $is_footer && ! empty( $this->items ) ) {
254 - $utm = array(
255 - 'campaign' => 'spam-protection',
256 - 'content' => 'entries-list-spam-protection',
257 - );
258 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
259 227 ?>
260 228 <p>
261 229 <?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?>
262 - <a href="<?php echo esc_url( FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/add-spam-protection/' ) ); ?>" target="_blank">
230 + <a href="https://formidableforms.com/knowledgebase/add-spam-protection/" target="_blank">
263 231 <?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?>
264 232 </a>
265 233 </p>
266 234 <?php
267 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
268 235 }
269 236 parent::display_tablenav( $which );
270 237 }
271 238
272 239 /**
273 - * @param string $which
274 - *
275 240 * @return void
276 241 */
277 242 protected function extra_tablenav( $which ) {
278 243 $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
244 + if ( $which === 'top' && ! $form_id ) {
245 + echo '<div class="alignleft actions">';
279 246
280 - if ( $which !== 'top' || $form_id ) {
281 - return;
282 - }
247 + // Override the referrer to prevent it from being used for the screen options.
248 + echo '<input type="hidden" name="_wp_http_referer" value="" />';
283 249
284 - echo '<div class="alignleft actions">';
250 + echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
285 251
286 - // Override the referrer to prevent it from being used for the screen options.
287 - echo '<input type="hidden" name="_wp_http_referer" value="" />';
288 -
289 - echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
290 -
291 - FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
292 - submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
293 - echo '</div>';
252 + FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
253 + submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
254 + echo '</div>';
255 + }
294 256 }
295 257
296 258 /**
297 259 * Gets the name of the primary column in the Entries screen
@@ -297,17 +259,18 @@
297 259 * Gets the name of the primary column in the Entries screen
298 260 *
299 261 * @since 2.0.14
300 262 *
301 - * @return string Primary column.
263 + * @return string $primary_column
302 264 */
303 265 protected function get_primary_column_name() {
304 - $columns = get_column_headers( $this->screen );
305 - $hidden = get_hidden_columns( $this->screen );
266 + $columns = get_column_headers( $this->screen );
267 + $hidden = get_hidden_columns( $this->screen );
268 +
306 269 $primary_column = '';
307 270
308 271 foreach ( $columns as $column_key => $column_display_name ) {
309 - if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden, true ) ) {
272 + if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden ) ) {
310 273 $primary_column = $column_key;
311 274 break;
312 275 }
313 276 }
@@ -318,9 +281,8 @@
318 281 /**
319 282 * @since 6.12
320 283 *
321 284 * @param object $item
322 - *
323 285 * @return string
324 286 */
325 287 private static function get_entry_label( $item ) {
326 288 if ( $item->name ) {
@@ -330,11 +292,8 @@
330 292 return sprintf( __( 'Entry %d', 'formidable' ), $item->id );
331 293 }
332 294
333 295 /**
334 - * @param stdClass $item
335 - * @param string $style
336 - *
337 296 * @return string
338 297 */
339 298 public function single_row( $item, $style = '' ) {
340 299 // Set up the hover actions for this user
@@ -347,9 +306,9 @@
347 306
348 307 // Set up the checkbox ( because the user is editable, otherwise its empty )
349 308 $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
350 309 /* translators: %s: Form name */
351 - $checkbox .= "<label for='cb-item-action-{$item->id}'><span class='screen-reader-text'>" . esc_html( sprintf( __( 'Select %s', 'formidable' ), self::get_entry_label( $item ) ) ) . '</span></label>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
310 + $checkbox .= "<label for='cb-item-action-{$item->id}'><span class='screen-reader-text'>" . esc_html( sprintf( __( 'Select %s', 'formidable' ), self::get_entry_label( $item ) ) ) . '</span></label>';
352 311
353 312 $r = "<tr id='item-action-{$item->id}'$style>";
354 313
355 314 list( $columns, $hidden, , $primary ) = $this->get_column_info();
@@ -363,9 +322,9 @@
363 322 $class .= ' column-primary';
364 323 }
365 324
366 325 if ( in_array( $column_name, $hidden, true ) ) {
367 - $class .= ' hidden';
326 + $class .= ' frm_hidden';
368 327 } elseif ( ! $action_col && ! in_array( $column_name, $action_columns, true ) ) {
369 328 $action_col = $column_name;
370 329 }
371 330
@@ -370,9 +329,10 @@
370 329 }
371 330
372 331 $attributes = 'class="' . esc_attr( $class ) . '"';
373 332 unset( $class );
374 - $attributes .= ' data-colname="' . $column_display_name . '"';
333 + $attributes .= ' data-colname="' . $column_display_name . '"';
334 +
375 335 $form_id = $this->params['form'] ? $this->params['form'] : 0;
376 336 $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name );
377 337
378 338 if ( $this->column_name === 'cb' ) {
@@ -377,12 +337,15 @@
377 337
378 338 if ( $this->column_name === 'cb' ) {
379 339 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
380 340 } else {
381 - $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
382 - $r .= "<td $attributes>";
341 + if ( in_array( $column_name, $hidden, true ) ) {
342 + $val = '';
343 + } else {
344 + $val = $this->column_value( $item );
345 + }
383 346
384 - // phpcs:ignore Universal.Operators.StrictComparisons
347 + $r .= "<td $attributes>";
385 348 if ( $column_name == $action_col ) {
386 349 $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
387 350 $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
388 351 $r .= $action_links;
@@ -388,14 +351,15 @@
388 351 $r .= $action_links;
389 352 } else {
390 353 $r .= $val;
391 354 }
392 -
393 355 $r .= '</td>';
394 - }//end if
356 + }
395 357 unset( $val );
396 358 }//end foreach
397 - return $r . '</tr>';
359 + $r .= '</tr>';
360 +
361 + return $r;
398 362 }
399 363
400 364 /**
401 365 * Get the column names that the logged in user can action on
@@ -407,10 +371,8 @@
407 371 }
408 372
409 373 /**
410 374 * @param object $item
411 - *
412 - * @return mixed
413 375 */
414 376 private function column_value( $item ) {
415 377 $col_name = $this->maybe_fix_column_name( $this->column_name );
416 378
@@ -438,9 +400,8 @@
438 400 break;
439 401 case 'form_id':
440 402 $form_id = $item->form_id;
441 403 $user_can_edit_forms = false === FrmAppHelper::permission_nonce_error( 'frm_edit_forms' );
442 -
443 404 if ( $user_can_edit_forms ) {
444 405 $val = FrmFormsHelper::edit_form_link( $form_id );
445 406 } else {
446 407 $val = FrmFormsHelper::edit_form_link_label( $form_id );
@@ -457,9 +418,8 @@
457 418 $val = $item->parent_item_id;
458 419 break;
459 420 default:
460 421 $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
461 -
462 422 if ( $val === false ) {
463 423 $this->get_column_value( $item, $val );
464 424 }
465 425
@@ -482,14 +442,13 @@
482 442 *
483 443 * @since 6.11.2
484 444 *
485 445 * @param string $column_name
486 - *
487 446 * @return string
488 447 */
489 448 private function maybe_fix_column_name( $column_name ) {
490 - if ( str_starts_with( $column_name, '0_' ) ) {
491 - return substr( $column_name, 2 );
449 + if ( 0 === strpos( $column_name, '0_' ) ) {
450 + $column_name = substr( $column_name, 2 );
492 451 }
493 452 return $column_name;
494 453 }
495 454
@@ -500,13 +459,13 @@
500 459 *
501 460 * @return void
502 461 */
503 462 private function get_actions( &$actions, $item, $view_link ) {
504 - $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . esc_html__( 'View', 'formidable' ) . '</a>';
463 + $actions['view'] = '<a href="' . esc_url( $view_link ) . '">' . __( 'View', 'formidable' ) . '</a>';
505 464
506 465 if ( current_user_can( 'frm_delete_entries' ) ) {
507 466 $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
508 - $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . esc_html__( 'Delete', 'formidable' ) . '</a>'; // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
467 + $actions['delete'] = '<a href="' . esc_url( wp_nonce_url( $delete_link ) ) . '" class="submitdelete" data-frmverify="' . esc_attr__( 'Permanently delete this entry?', 'formidable' ) . '" data-frmverify-btn="frm-button-red">' . __( 'Delete', 'formidable' ) . '</a>';
509 468 }
510 469
511 470 $actions = apply_filters( 'frm_row_actions', $actions, $item );
512 471 }
@@ -512,9 +471,9 @@
512 471 }
513 472
514 473 /**
515 474 * @param object $item
516 - * @param mixed $val
475 + * @param false $val
517 476 *
518 477 * @return void
519 478 */
520 479 private function get_column_value( $item, &$val ) {
@@ -519,9 +478,9 @@
519 478 */
520 479 private function get_column_value( $item, &$val ) {
521 480 $col_name = $this->column_name;
522 481
523 - if ( str_starts_with( $col_name, 'frmsep_' ) ) {
482 + if ( strpos( $col_name, 'frmsep_' ) === 0 ) {
524 483 $sep_val = true;
525 484 $col_name = str_replace( 'frmsep_', '', $col_name );
526 485 } else {
527 486 $sep_val = false;
@@ -526,14 +485,13 @@
526 485 } else {
527 486 $sep_val = false;
528 487 }
529 488
530 - if ( str_contains( $col_name, '-_-' ) ) {
489 + if ( strpos( $col_name, '-_-' ) ) {
531 490 list( $col_name, $embedded_field_id ) = explode( '-_-', $col_name );
532 491 }
533 492
534 493 $field = FrmField::getOne( $col_name );
535 -
536 494 if ( ! $field ) {
537 495 return;
538 496 }
539 497