PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.14
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.14
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/controllers/FrmEntriesController.php +51 -45 6.36.14 View file →
@@ -9,9 +9,9 @@
9 9 FrmAppHelper::force_capability( 'frm_view_entries' );
10 10
11 11 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
12 12
13 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
13 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
14 14 if ( ! $views_installed ) {
15 15 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' );
16 16 }
17 17
@@ -35,9 +35,11 @@
35 35 add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
36 36 }
37 37 }
38 38
39 - /* Display in Back End */
39 + /**
40 + * Display in Back End.
41 + */
40 42 public static function route() {
41 43 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
42 44 FrmAppHelper::include_svg();
43 45
@@ -80,13 +82,14 @@
80 82
81 83 if ( $form_id ) {
82 84 self::get_columns_for_form( $form_id, $columns );
83 85 } else {
84 - $columns[ $form_id . '_form_id' ] = __( 'Form', 'formidable' );
85 - $columns[ $form_id . '_name' ] = __( 'Entry Name', 'formidable' );
86 - $columns[ $form_id . '_user_id' ] = __( 'Created By', 'formidable' );
86 + $columns[ $form_id . '_form_id' ] = esc_html__( 'Form', 'formidable' );
87 + $columns[ $form_id . '_name' ] = esc_html__( 'Entry Name', 'formidable' );
88 + $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' );
87 89 }
88 90
91 + $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' );
89 92 $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
90 93 $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
91 94 self::maybe_add_ip_col( $form_id, $columns );
92 95
@@ -96,9 +99,9 @@
96 99 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
97 100 add_screen_option(
98 101 'per_page',
99 102 array(
100 - 'label' => __( 'Entries', 'formidable' ),
103 + 'label' => esc_html__( 'Entries', 'formidable' ),
101 104 'default' => 20,
102 105 'option' => 'formidable_page_formidable_entries_per_page',
103 106 )
104 107 );
@@ -124,9 +127,9 @@
124 127 if ( FrmField::is_no_save_field( $form_col->type ) ) {
125 128 continue;
126 129 }
127 130
128 - $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] );
131 + $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] );
129 132 if ( $has_child_fields ) {
130 133 self::add_subform_cols( $form_col, $form_id, $columns );
131 134 } else {
132 135 self::add_field_cols( $form_col, $form_id, $columns );
@@ -162,9 +165,9 @@
162 165 $col_id .= '-_-form' . $field->form_id;
163 166 }
164 167
165 168 $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
166 - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status';
169 + $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status';
167 170 if ( $has_separate_value && ! $is_post_status ) {
168 171 $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
169 172 }
170 173
@@ -187,10 +190,10 @@
187 190 $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
188 191 }
189 192
190 193 global $frm_vars;
191 - //add a check so we don't create a loop
192 - $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
194 + // Add a check so we don't create a loop.
195 + $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
193 196
194 197 return $check;
195 198 }
196 199
@@ -204,9 +207,10 @@
204 207 }
205 208
206 209 global $frm_vars;
207 210 if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
208 - return; // Don't continue if there's no previous value.
211 + // Don't continue if there's no previous value.
212 + return;
209 213 }
210 214
211 215 foreach ( $meta_value as $mk => $mv ) {
212 216 // Remove blank values.
@@ -264,9 +268,9 @@
264 268 return sanitize_title( $menu_name ) . '_page_formidable-entries';
265 269 }
266 270
267 271 public static function save_per_page( $save, $option, $value ) {
268 - if ( $option == 'formidable_page_formidable_entries_per_page' ) {
272 + if ( $option === 'formidable_page_formidable_entries_per_page' ) {
269 273 $save = (int) $value;
270 274 }
271 275
272 276 return $save;
@@ -284,8 +288,14 @@
284 288 $form_id . '_item_key' => 'item_key',
285 289 $form_id . '_is_draft' => 'is_draft',
286 290 );
287 291
292 + if ( ! $form_id ) {
293 + $columns[ $form_id . '_user_id' ] = 'user_id';
294 + $columns[ $form_id . '_name' ] = 'name';
295 + $columns[ $form_id . '_form_id' ] = 'form_id';
296 + }
297 +
288 298 foreach ( $fields as $field ) {
289 299 if ( self::field_supports_sorting( $field ) ) {
290 300 $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
291 301 }
@@ -350,9 +360,9 @@
350 360 foreach ( (array) $result as $r ) {
351 361 if ( ! empty( $r ) ) {
352 362 list( $form_prefix, $field_key ) = explode( '_', $r );
353 363
354 - if ( (int) $form_prefix == (int) $form_id ) {
364 + if ( (int) $form_prefix === (int) $form_id ) {
355 365 $hidden[] = $r;
356 366 }
357 367
358 368 unset( $form_prefix );
@@ -384,9 +394,9 @@
384 394 }
385 395
386 396 if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
387 397 $result[] = $col_key;
388 - $i--;
398 + --$i;
389 399 }
390 400
391 401 unset( $col_key, $col );
392 402 }
@@ -431,18 +441,20 @@
431 441 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
432 442 }
433 443
434 444 private static function get_delete_form_time( $form, &$errors ) {
435 - if ( 'trash' == $form->status ) {
445 + if ( 'trash' === $form->status ) {
436 446 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
437 - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
447 + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? $form->options['trash_time'] : time() ) );
438 448
439 449 /* translators: %1$s: Time string */
440 - $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
450 + $errors['trash'] = sprintf( __( 'This form is in the trash and is scheduled to be deleted permanently in %s along with any entries.', 'formidable' ), $time_to_delete );
441 451 }
442 452 }
443 453
444 - /* Back End CRUD */
454 + /**
455 + * Back End CRUD.
456 + */
445 457 public static function show( $id = 0 ) {
446 458 FrmAppHelper::permission_check( 'frm_view_entries' );
447 459
448 460 if ( ! $id ) {
@@ -454,12 +466,15 @@
454 466 }
455 467
456 468 $entry = FrmEntry::getOne( $id, true );
457 469 if ( ! $entry ) {
458 - echo '<div id="form_show_entry_page" class="wrap">' .
459 - esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
460 - '</div>';
461 -
470 + FrmAppController::show_error_modal(
471 + array(
472 + 'title' => __( 'You can\'t view the entry', 'formidable' ),
473 + 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ),
474 + 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
475 + )
476 + );
462 477 return;
463 478 }
464 479
465 480 $data = $entry->description;
@@ -469,9 +484,9 @@
469 484
470 485 $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
471 486 $form = FrmForm::getOne( $entry->form_id );
472 487
473 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
488 + include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php';
474 489 }
475 490
476 491 /**
477 492 * Destroy an entry from the admin page.
@@ -481,9 +496,15 @@
481 496 */
482 497 public static function destroy() {
483 498 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
484 499 if ( false !== $permission_error ) {
485 - wp_die( esc_html( $permission_error ) );
500 + $error_args = array(
501 + 'title' => __( 'Verification failed', 'formidable' ),
502 + 'body' => $permission_error,
503 + 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
504 + );
505 + FrmAppController::show_error_modal( $error_args );
506 + return;
486 507 }
487 508
488 509 $params = FrmForm::get_admin_params();
489 510
@@ -498,18 +519,8 @@
498 519
499 520 self::display_list( $message );
500 521 }
501 522
502 - /**
503 - * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite.
504 - */
505 - public static function destroy_all() {
506 - _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' );
507 - if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) {
508 - FrmProEntriesController::destroy_all();
509 - }
510 - }
511 -
512 523 public static function process_entry( $errors = '', $ajax = false ) {
513 524 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
514 525 if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
515 526 return;
@@ -616,9 +627,9 @@
616 627 FrmEntry::clear_cache();
617 628 }
618 629
619 630 /**
620 - * @param $atts
631 + * @param array $atts
621 632 *
622 633 * @return array|string
623 634 */
624 635 public static function show_entry_shortcode( $atts ) {
@@ -645,9 +656,10 @@
645 656 'exclude_fields' => '',
646 657 'include_fields' => '',
647 658 'include_extras' => '',
648 659 'inline_style' => 1,
649 - 'child_array' => false, // return embedded fields as nested array
660 + // Return embedded fields as nested array.
661 + 'child_array' => false,
650 662 'line_breaks' => true,
651 663 'array_separator' => ', ',
652 664 );
653 665 $defaults = apply_filters( 'frm_show_entry_defaults', $defaults );
@@ -689,20 +701,14 @@
689 701 /**
690 702 * Add or remove information in the entry sidebar.
691 703 *
692 704 * @since 5.5.2
705 + *
693 706 * @param array $data
707 + * @param array{entry:\stdClass} $entry
694 708 */
695 709 $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) );
696 710 }
697 711
698 - include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
699 - }
700 -
701 - /**
702 - * @deprecated 4.0
703 - */
704 - public static function contextual_help( $help, $screen_id, $screen ) {
705 - _deprecated_function( __METHOD__, '4.0' );
706 - return $help;
712 + include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
707 713 }
708 714 }