PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.2.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.2.3
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 +64 -171 6.25.16.2.3 View file →
@@ -9,14 +9,11 @@
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();
13 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_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 - self::maybe_redirect_to_views_upsell();
17 - } else {
18 - self::maybe_redirect_to_views_index();
19 16 }
20 17
21 18 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
22 19 self::load_manage_entries_hooks();
@@ -23,73 +20,8 @@
23 20 }
24 21 }
25 22
26 23 /**
27 - * This function is called when views is installed.
28 - * The Views add-on uses a different URL for the Views tab than the upsell page.
29 - * If the user is on the upsell page, instead of showing a permission error on reload,
30 - * redirect to the views index page.
31 - *
32 - * @since 6.14.1
33 - *
34 - * @return void
35 - */
36 - private static function maybe_redirect_to_views_index() {
37 - if ( ! FrmAppHelper::is_admin_page( 'formidable-views' ) ) {
38 - return;
39 - }
40 -
41 - $query_args = array(
42 - 'post_type' => 'frm_display',
43 - );
44 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
45 -
46 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'edit.php' ) ) );
47 - die();
48 - }
49 -
50 - /**
51 - * This function is called when views is inactive.
52 - * A user may deactivate views but then try to reload the views index.
53 - * Instead of showing a permission error, redirect to the views upsell page.
54 - *
55 - * @since 6.14.1
56 - *
57 - * @return void
58 - */
59 - private static function maybe_redirect_to_views_upsell() {
60 - global $pagenow;
61 - if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) {
62 - return;
63 - }
64 -
65 - $query_args = array(
66 - 'page' => 'formidable-views',
67 - );
68 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
69 -
70 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) );
71 - die();
72 - }
73 -
74 - /**
75 - * @since 6.14.1
76 - *
77 - * @param array $query_args
78 - * @return array
79 - */
80 - private static function add_url_params_to_views_redirect_query_args( $query_args ) {
81 - $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 );
82 -
83 - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
84 - if ( $form_id ) {
85 - $query_args['form'] = $form_id;
86 - }
87 -
88 - return $query_args;
89 - }
90 -
91 - /**
92 24 * @since 2.05.07
93 25 */
94 26 private static function load_manage_entries_hooks() {
95 27 if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
@@ -99,15 +31,13 @@
99 31 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
100 32 add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
101 33 add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
102 34 } else {
103 - add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 );
35 + add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
104 36 }
105 37 }
106 38
107 - /**
108 - * Display in Back End.
109 - */
39 + /* Display in Back End */
110 40 public static function route() {
111 41 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
112 42 FrmAppHelper::include_svg();
113 43
@@ -132,12 +62,10 @@
132 62 *
133 63 * @since 3.0
134 64 */
135 65 public static function remove_screen_options( $show_screen, $screen ) {
136 - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
137 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
138 -
139 - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) {
66 + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
67 + if ( $screen->id == $menu_name . '_page_formidable-entries' ) {
140 68 $show_screen = false;
141 69 }
142 70
143 71 return $show_screen;
@@ -152,14 +80,13 @@
152 80
153 81 if ( $form_id ) {
154 82 self::get_columns_for_form( $form_id, $columns );
155 83 } else {
156 - $columns[ $form_id . '_form_id' ] = esc_html__( 'Form', 'formidable' );
157 - $columns[ $form_id . '_name' ] = esc_html__( 'Entry Name', 'formidable' );
158 - $columns[ $form_id . '_user_id' ] = esc_html__( 'Created By', 'formidable' );
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' );
159 87 }
160 88
161 - $columns[ $form_id . '_is_draft' ] = esc_html__( 'Entry Status', 'formidable' );
162 89 $columns[ $form_id . '_created_at' ] = __( 'Entry creation date', 'formidable' );
163 90 $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
164 91 self::maybe_add_ip_col( $form_id, $columns );
165 92
@@ -169,9 +96,9 @@
169 96 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
170 97 add_screen_option(
171 98 'per_page',
172 99 array(
173 - 'label' => esc_html__( 'Entries', 'formidable' ),
100 + 'label' => __( 'Entries', 'formidable' ),
174 101 'default' => 20,
175 102 'option' => 'formidable_page_formidable_entries_per_page',
176 103 )
177 104 );
@@ -197,9 +124,9 @@
197 124 if ( FrmField::is_no_save_field( $form_col->type ) ) {
198 125 continue;
199 126 }
200 127
201 - $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] );
128 + $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] );
202 129 if ( $has_child_fields ) {
203 130 self::add_subform_cols( $form_col, $form_id, $columns );
204 131 } else {
205 132 self::add_field_cols( $form_col, $form_id, $columns );
@@ -234,39 +161,17 @@
234 161 if ( $field->form_id != $form_id ) {
235 162 $col_id .= '-_-form' . $field->form_id;
236 163 }
237 164
238 - $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
239 - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status';
240 - $include_column_for_sep_val = $has_separate_value && ! $is_post_status;
241 - if ( $include_column_for_sep_val ) {
242 - $columns[ $form_id . '_frmsep_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val );
165 + $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';
167 + if ( $has_separate_value && ! $is_post_status ) {
168 + $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
243 169 }
244 170
245 - $columns[ $form_id . '_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, false );
171 + $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
246 172 }
247 173
248 - /**
249 - * Appends "(Value)" or "(Label)" to the field name if it's an option field that has a separate value/label.
250 - *
251 - * @since 6.25.1
252 - *
253 - * @param object $field
254 - * @param bool $include_column_for_sep_val
255 - * @param bool $is_value
256 - *
257 - * @return string
258 - */
259 - private static function maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, $is_value = true ) {
260 - $field_name = FrmAppHelper::truncate( $field->name, 35 );
261 - if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) {
262 - return $field_name;
263 - }
264 - $append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' );
265 -
266 - return sprintf( '%s (%s)', $field_name, $append_text );
267 - }
268 -
269 174 private static function maybe_add_ip_col( $form_id, &$columns ) {
270 175 if ( FrmAppHelper::ips_saved() ) {
271 176 $columns[ $form_id . '_ip' ] = 'IP';
272 177 }
@@ -282,10 +187,10 @@
282 187 $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
283 188 }
284 189
285 190 global $frm_vars;
286 - // Add a check so we don't create a loop.
287 - $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
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;
288 193
289 194 return $check;
290 195 }
291 196
@@ -299,10 +204,9 @@
299 204 }
300 205
301 206 global $frm_vars;
302 207 if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
303 - // Don't continue if there's no previous value.
304 - return;
208 + return; // Don't continue if there's no previous value.
305 209 }
306 210
307 211 foreach ( $meta_value as $mk => $mv ) {
308 212 // Remove blank values.
@@ -356,15 +260,13 @@
356 260 if ( empty( $menu_name ) ) {
357 261 $menu_name = FrmAppHelper::get_menu_name();
358 262 }
359 263
360 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
361 -
362 - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries';
264 + return sanitize_title( $menu_name ) . '_page_formidable-entries';
363 265 }
364 266
365 267 public static function save_per_page( $save, $option, $value ) {
366 - if ( $option === 'formidable_page_formidable_entries_per_page' ) {
268 + if ( $option == 'formidable_page_formidable_entries_per_page' ) {
367 269 $save = (int) $value;
368 270 }
369 271
370 272 return $save;
@@ -382,14 +284,8 @@
382 284 $form_id . '_item_key' => 'item_key',
383 285 $form_id . '_is_draft' => 'is_draft',
384 286 );
385 287
386 - if ( ! $form_id ) {
387 - $columns[ $form_id . '_user_id' ] = 'user_id';
388 - $columns[ $form_id . '_name' ] = 'name';
389 - $columns[ $form_id . '_form_id' ] = 'form_id';
390 - }
391 -
392 288 foreach ( $fields as $field ) {
393 289 if ( self::field_supports_sorting( $field ) ) {
394 290 $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
395 291 }
@@ -414,10 +310,8 @@
414 310 * @param mixed $result Option value from database for hidden columns in entries table.
415 311 * @return array
416 312 */
417 313 public static function hidden_columns( $result ) {
418 - global $frm_vars;
419 -
420 314 if ( ! is_array( $result ) ) {
421 315 // Force an unexpected value to be an array.
422 316 // Since $result is a filtered option and gets saved to the database, it's possible it could be a string.
423 317 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
@@ -423,16 +317,21 @@
423 317 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
424 318 $result = array();
425 319 }
426 320
427 - $form_id = FrmForm::get_current_form_id();
428 - $hidden = self::user_hidden_columns_for_form( $form_id, $result );
429 - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
430 - $max_columns = 11;
321 + $form_id = FrmForm::get_current_form_id();
431 322
323 + $hidden = self::user_hidden_columns_for_form( $form_id, $result );
324 +
325 + global $frm_vars;
326 + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
327 +
432 328 if ( ! empty( $hidden ) ) {
433 - $result = $hidden;
434 - $i = $i - count( $result );
329 + $result = $hidden;
330 + $i = $i - count( $result );
331 + $max_columns = 11;
332 + } else {
333 + $max_columns = 8;
435 334 }
436 335
437 336 if ( $i <= $max_columns ) {
438 337 return $result;
@@ -451,9 +350,9 @@
451 350 foreach ( (array) $result as $r ) {
452 351 if ( ! empty( $r ) ) {
453 352 list( $form_prefix, $field_key ) = explode( '_', $r );
454 353
455 - if ( (int) $form_prefix === (int) $form_id ) {
354 + if ( (int) $form_prefix == (int) $form_id ) {
456 355 $hidden[] = $r;
457 356 }
458 357
459 358 unset( $form_prefix );
@@ -466,12 +365,8 @@
466 365 /**
467 366 * Remove some columns by default when there are too many
468 367 *
469 368 * @since 2.05.07
470 - *
471 - * @param array $atts
472 - * @param array $result
473 - * @return void
474 369 */
475 370 private static function remove_excess_cols( $atts, &$result ) {
476 371 global $frm_vars;
477 372
@@ -489,9 +384,9 @@
489 384 }
490 385
491 386 if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
492 387 $result[] = $col_key;
493 - --$i;
388 + $i--;
494 389 }
495 390
496 391 unset( $col_key, $col );
497 392 }
@@ -536,20 +431,18 @@
536 431 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
537 432 }
538 433
539 434 private static function get_delete_form_time( $form, &$errors ) {
540 - if ( 'trash' === $form->status ) {
435 + if ( 'trash' == $form->status ) {
541 436 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
542 - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) );
437 + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
543 438
544 439 /* translators: %1$s: Time string */
545 - $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 );
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 );
546 441 }
547 442 }
548 443
549 - /**
550 - * Back End CRUD.
551 - */
444 + /* Back End CRUD */
552 445 public static function show( $id = 0 ) {
553 446 FrmAppHelper::permission_check( 'frm_view_entries' );
554 447
555 448 if ( ! $id ) {
@@ -561,15 +454,12 @@
561 454 }
562 455
563 456 $entry = FrmEntry::getOne( $id, true );
564 457 if ( ! $entry ) {
565 - FrmAppController::show_error_modal(
566 - array(
567 - 'title' => __( 'You can\'t view the entry', 'formidable' ),
568 - 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ),
569 - 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
570 - )
571 - );
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 +
572 462 return;
573 463 }
574 464
575 465 $data = $entry->description;
@@ -579,9 +469,9 @@
579 469
580 470 $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
581 471 $form = FrmForm::getOne( $entry->form_id );
582 472
583 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php';
473 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
584 474 }
585 475
586 476 /**
587 477 * Destroy an entry from the admin page.
@@ -591,15 +481,9 @@
591 481 */
592 482 public static function destroy() {
593 483 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
594 484 if ( false !== $permission_error ) {
595 - $error_args = array(
596 - 'title' => __( 'Verification failed', 'formidable' ),
597 - 'body' => $permission_error,
598 - 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
599 - );
600 - FrmAppController::show_error_modal( $error_args );
601 - return;
485 + wp_die( esc_html( $permission_error ) );
602 486 }
603 487
604 488 $params = FrmForm::get_admin_params();
605 489
@@ -614,8 +498,18 @@
614 498
615 499 self::display_list( $message );
616 500 }
617 501
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 +
618 512 public static function process_entry( $errors = '', $ajax = false ) {
619 513 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
620 514 if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
621 515 return;
@@ -627,13 +521,8 @@
627 521 if ( ! $form ) {
628 522 return;
629 523 }
630 524
631 - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' );
632 - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) {
633 - return;
634 - }
635 -
636 525 $params = FrmForm::get_params( $form );
637 526
638 527 if ( ! isset( $frm_vars['form_params'] ) ) {
639 528 $frm_vars['form_params'] = array();
@@ -727,9 +616,9 @@
727 616 FrmEntry::clear_cache();
728 617 }
729 618
730 619 /**
731 - * @param array $atts
620 + * @param $atts
732 621 *
733 622 * @return array|string
734 623 */
735 624 public static function show_entry_shortcode( $atts ) {
@@ -756,11 +645,9 @@
756 645 'exclude_fields' => '',
757 646 'include_fields' => '',
758 647 'include_extras' => '',
759 648 'inline_style' => 1,
760 - 'table_style' => '',
761 - // Return embedded fields as nested array.
762 - 'child_array' => false,
649 + 'child_array' => false, // return embedded fields as nested array
763 650 'line_breaks' => true,
764 651 'array_separator' => ', ',
765 652 );
766 653 $defaults = apply_filters( 'frm_show_entry_defaults', $defaults );
@@ -802,14 +689,20 @@
802 689 /**
803 690 * Add or remove information in the entry sidebar.
804 691 *
805 692 * @since 5.5.2
806 - *
807 693 * @param array $data
808 - * @param array{entry:\stdClass} $entry
809 694 */
810 695 $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) );
811 696 }
812 697
813 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
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;
814 707 }
815 708 }