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 -107 6.34 → 6.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,23 +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 - $current_url = set_url_scheme(
213 - 'http://' . FrmAppHelper::get_server_value( 'HTTP_HOST' ) . FrmAppHelper::get_server_value( 'REQUEST_URI' )
214 - );
215 - $clear_url = remove_query_arg( 's', $current_url );
216 -
217 - echo '<p>';
218 - printf(
219 - /* translators: %1$s: Start link HTML, %2$s: End link HTML */
220 - esc_html__( 'No entries match your search. %1$sClear search%2$s', 'formidable' ),
221 - '<a href="' . esc_url( $clear_url ) . '">',
222 - '</a>'
223 - );
224 - echo '</p>';
225 193 return;
226 194 }
227 195
228 196 $form_id = $this->params['form'];
@@ -230,9 +198,8 @@
230 198
231 199 if ( $form_id ) {
232 200 $form = FrmForm::getOne( $form_id );
233 201 }
234 -
235 202 $has_form = ! empty( $form );
236 203
237 204 if ( ! $has_form ) {
238 205 $has_form = FrmForm::getAll( array(), '', 1 );
@@ -244,11 +211,8 @@
244 211 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/no_entries.php';
245 212 }
246 213
247 214 /**
248 - * @param string $text Text.
249 - * @param string $input_id Input ID.
250 - *
251 215 * @return void
252 216 */
253 217 public function search_box( $text, $input_id ) {
254 218 // Searching is a pro feature
@@ -254,56 +218,42 @@
254 218 // Searching is a pro feature
255 219 }
256 220
257 221 /**
258 - * @param string $which
259 - *
260 222 * @return void
261 223 */
262 224 protected function display_tablenav( $which ) {
263 - $is_footer = $which !== 'top';
264 -
225 + $is_footer = ( $which !== 'top' );
265 226 if ( $is_footer && ! empty( $this->items ) ) {
266 - $utm = array(
267 - 'campaign' => 'spam-protection',
268 - 'content' => 'entries-list-spam-protection',
269 - );
270 - // phpcs:disable Generic.WhiteSpace.ScopeIndent
271 227 ?>
272 228 <p>
273 229 <?php esc_html_e( 'Getting spam form submissions?', 'formidable' ); ?>
274 - <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">
275 231 <?php esc_html_e( 'Learn how to prevent them.', 'formidable' ); ?>
276 232 </a>
277 233 </p>
278 234 <?php
279 - // phpcs:enable Generic.WhiteSpace.ScopeIndent
280 235 }
281 236 parent::display_tablenav( $which );
282 237 }
283 238
284 239 /**
285 - * @param string $which
286 - *
287 240 * @return void
288 241 */
289 242 protected function extra_tablenav( $which ) {
290 243 $form_id = FrmAppHelper::simple_get( 'form', 'absint' );
244 + if ( $which === 'top' && ! $form_id ) {
245 + echo '<div class="alignleft actions">';
291 246
292 - if ( $which !== 'top' || $form_id ) {
293 - return;
294 - }
247 + // Override the referrer to prevent it from being used for the screen options.
248 + echo '<input type="hidden" name="_wp_http_referer" value="" />';
295 249
296 - echo '<div class="alignleft actions">';
250 + echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
297 251
298 - // Override the referrer to prevent it from being used for the screen options.
299 - echo '<input type="hidden" name="_wp_http_referer" value="" />';
300 -
301 - echo '<label for="form" class="screen-reader-text">' . esc_html__( 'Filter by form', 'formidable' ) . '</label>';
302 -
303 - FrmFormsHelper::forms_dropdown( 'form', $form_id, array( 'blank' => __( 'View all forms', 'formidable' ) ) );
304 - submit_button( __( 'Filter', 'formidable' ), 'filter_action action', '', false, array( 'id' => 'post-query-submit' ) );
305 - 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 + }
306 256 }
307 257
308 258 /**
309 259 * Gets the name of the primary column in the Entries screen
@@ -309,17 +259,18 @@
309 259 * Gets the name of the primary column in the Entries screen
310 260 *
311 261 * @since 2.0.14
312 262 *
313 - * @return string Primary column.
263 + * @return string $primary_column
314 264 */
315 265 protected function get_primary_column_name() {
316 - $columns = get_column_headers( $this->screen );
317 - $hidden = get_hidden_columns( $this->screen );
266 + $columns = get_column_headers( $this->screen );
267 + $hidden = get_hidden_columns( $this->screen );
268 +
318 269 $primary_column = '';
319 270
320 271 foreach ( $columns as $column_key => $column_display_name ) {
321 - if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden, true ) ) {
272 + if ( 'cb' !== $column_key && ! in_array( $column_key, $hidden ) ) {
322 273 $primary_column = $column_key;
323 274 break;
324 275 }
325 276 }
@@ -330,9 +281,8 @@
330 281 /**
331 282 * @since 6.12
332 283 *
333 284 * @param object $item
334 - *
335 285 * @return string
336 286 */
337 287 private static function get_entry_label( $item ) {
338 288 if ( $item->name ) {
@@ -342,11 +292,8 @@
342 292 return sprintf( __( 'Entry %d', 'formidable' ), $item->id );
343 293 }
344 294
345 295 /**
346 - * @param stdClass $item
347 - * @param string $style
348 - *
349 296 * @return string
350 297 */
351 298 public function single_row( $item, $style = '' ) {
352 299 // Set up the hover actions for this user
@@ -359,9 +306,9 @@
359 306
360 307 // Set up the checkbox ( because the user is editable, otherwise its empty )
361 308 $checkbox = "<input type='checkbox' name='item-action[]' id='cb-item-action-{$item->id}' value='{$item->id}' />";
362 309 /* translators: %s: Form name */
363 - $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>';
364 311
365 312 $r = "<tr id='item-action-{$item->id}'$style>";
366 313
367 314 list( $columns, $hidden, , $primary ) = $this->get_column_info();
@@ -375,9 +322,9 @@
375 322 $class .= ' column-primary';
376 323 }
377 324
378 325 if ( in_array( $column_name, $hidden, true ) ) {
379 - $class .= ' hidden';
326 + $class .= ' frm_hidden';
380 327 } elseif ( ! $action_col && ! in_array( $column_name, $action_columns, true ) ) {
381 328 $action_col = $column_name;
382 329 }
383 330
@@ -382,9 +329,10 @@
382 329 }
383 330
384 331 $attributes = 'class="' . esc_attr( $class ) . '"';
385 332 unset( $class );
386 - $attributes .= ' data-colname="' . $column_display_name . '"';
333 + $attributes .= ' data-colname="' . $column_display_name . '"';
334 +
387 335 $form_id = $this->params['form'] ? $this->params['form'] : 0;
388 336 $this->column_name = preg_replace( '/^(' . $form_id . '_)/', '', $column_name );
389 337
390 338 if ( $this->column_name === 'cb' ) {
@@ -389,12 +337,15 @@
389 337
390 338 if ( $this->column_name === 'cb' ) {
391 339 $r .= "<th scope='row' class='check-column'>$checkbox</th>";
392 340 } else {
393 - $val = in_array( $column_name, $hidden, true ) ? '' : $this->column_value( $item );
394 - $r .= "<td $attributes>";
341 + if ( in_array( $column_name, $hidden, true ) ) {
342 + $val = '';
343 + } else {
344 + $val = $this->column_value( $item );
345 + }
395 346
396 - // phpcs:ignore Universal.Operators.StrictComparisons
347 + $r .= "<td $attributes>";
397 348 if ( $column_name == $action_col ) {
398 349 $edit_link = admin_url( 'admin.php?page=formidable-entries&frm_action=edit&id=' . $item->id );
399 350 $r .= '<a href="' . esc_url( isset( $actions['edit'] ) ? $edit_link : $view_link ) . '" class="row-title" >' . $val . '</a> ';
400 351 $r .= $action_links;
@@ -400,14 +351,15 @@
400 351 $r .= $action_links;
401 352 } else {
402 353 $r .= $val;
403 354 }
404 -
405 355 $r .= '</td>';
406 - }//end if
356 + }
407 357 unset( $val );
408 358 }//end foreach
409 - return $r . '</tr>';
359 + $r .= '</tr>';
360 +
361 + return $r;
410 362 }
411 363
412 364 /**
413 365 * Get the column names that the logged in user can action on
@@ -419,10 +371,8 @@
419 371 }
420 372
421 373 /**
422 374 * @param object $item
423 - *
424 - * @return mixed
425 375 */
426 376 private function column_value( $item ) {
427 377 $col_name = $this->maybe_fix_column_name( $this->column_name );
428 378
@@ -450,9 +400,8 @@
450 400 break;
451 401 case 'form_id':
452 402 $form_id = $item->form_id;
453 403 $user_can_edit_forms = false === FrmAppHelper::permission_nonce_error( 'frm_edit_forms' );
454 -
455 404 if ( $user_can_edit_forms ) {
456 405 $val = FrmFormsHelper::edit_form_link( $form_id );
457 406 } else {
458 407 $val = FrmFormsHelper::edit_form_link_label( $form_id );
@@ -469,9 +418,8 @@
469 418 $val = $item->parent_item_id;
470 419 break;
471 420 default:
472 421 $val = apply_filters( 'frm_entries_' . $col_name . '_column', false, compact( 'item' ) );
473 -
474 422 if ( $val === false ) {
475 423 $this->get_column_value( $item, $val );
476 424 }
477 425
@@ -494,14 +442,13 @@
494 442 *
495 443 * @since 6.11.2
496 444 *
497 445 * @param string $column_name
498 - *
499 446 * @return string
500 447 */
501 448 private function maybe_fix_column_name( $column_name ) {
502 - if ( str_starts_with( $column_name, '0_' ) ) {
503 - return substr( $column_name, 2 );
449 + if ( 0 === strpos( $column_name, '0_' ) ) {
450 + $column_name = substr( $column_name, 2 );
504 451 }
505 452 return $column_name;
506 453 }
507 454
@@ -512,13 +459,13 @@
512 459 *
513 460 * @return void
514 461 */
515 462 private function get_actions( &$actions, $item, $view_link ) {
516 - $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>';
517 464
518 465 if ( current_user_can( 'frm_delete_entries' ) ) {
519 466 $delete_link = '?page=formidable-entries&frm_action=destroy&id=' . $item->id . '&form=' . $this->params['form'];
520 - $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>';
521 468 }
522 469
523 470 $actions = apply_filters( 'frm_row_actions', $actions, $item );
524 471 }
@@ -524,9 +471,9 @@
524 471 }
525 472
526 473 /**
527 474 * @param object $item
528 - * @param mixed $val
475 + * @param false $val
529 476 *
530 477 * @return void
531 478 */
532 479 private function get_column_value( $item, &$val ) {
@@ -531,9 +478,9 @@
531 478 */
532 479 private function get_column_value( $item, &$val ) {
533 480 $col_name = $this->column_name;
534 481
535 - if ( str_starts_with( $col_name, 'frmsep_' ) ) {
482 + if ( strpos( $col_name, 'frmsep_' ) === 0 ) {
536 483 $sep_val = true;
537 484 $col_name = str_replace( 'frmsep_', '', $col_name );
538 485 } else {
539 486 $sep_val = false;
@@ -538,14 +485,13 @@
538 485 } else {
539 486 $sep_val = false;
540 487 }
541 488
542 - if ( str_contains( $col_name, '-_-' ) ) {
489 + if ( strpos( $col_name, '-_-' ) ) {
543 490 list( $col_name, $embedded_field_id ) = explode( '-_-', $col_name );
544 491 }
545 492
546 493 $field = FrmField::getOne( $col_name );
547 -
548 494 if ( ! $field ) {
549 495 return;
550 496 }
551 497