PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.7.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.7.2
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 +56 -314 6.266.7.2 View file →
@@ -4,23 +4,16 @@
4 4 }
5 5
6 6 class FrmEntriesController {
7 7
8 - /**
9 - * @return void
10 - */
11 8 public static function menu() {
12 9 FrmAppHelper::force_capability( 'frm_view_entries' );
13 10
14 11 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
15 12
16 - $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
17 -
13 + $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) ? FrmProAppHelper::views_is_installed() : FrmAppHelper::pro_is_installed();
18 14 if ( ! $views_installed ) {
19 15 add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' );
20 - self::maybe_redirect_to_views_upsell();
21 - } else {
22 - self::maybe_redirect_to_views_index();
23 16 }
24 17
25 18 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
26 19 self::load_manage_entries_hooks();
@@ -27,79 +20,9 @@
27 20 }
28 21 }
29 22
30 23 /**
31 - * This function is called when views is installed.
32 - * The Views add-on uses a different URL for the Views tab than the upsell page.
33 - * If the user is on the upsell page, instead of showing a permission error on reload,
34 - * redirect to the views index page.
35 - *
36 - * @since 6.14.1
37 - *
38 - * @return void
39 - */
40 - private static function maybe_redirect_to_views_index() {
41 - if ( ! FrmAppHelper::is_admin_page( 'formidable-views' ) ) {
42 - return;
43 - }
44 -
45 - $query_args = array(
46 - 'post_type' => 'frm_display',
47 - );
48 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
49 -
50 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'edit.php' ) ) );
51 - die();
52 - }
53 -
54 - /**
55 - * This function is called when views is inactive.
56 - * A user may deactivate views but then try to reload the views index.
57 - * Instead of showing a permission error, redirect to the views upsell page.
58 - *
59 - * @since 6.14.1
60 - *
61 - * @return void
62 - */
63 - private static function maybe_redirect_to_views_upsell() {
64 - global $pagenow;
65 -
66 - if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) {
67 - return;
68 - }
69 -
70 - $query_args = array(
71 - 'page' => 'formidable-views',
72 - );
73 - $query_args = self::add_url_params_to_views_redirect_query_args( $query_args );
74 -
75 - wp_safe_redirect( add_query_arg( $query_args, admin_url( 'admin.php' ) ) );
76 - die();
77 - }
78 -
79 - /**
80 - * @since 6.14.1
81 - *
82 - * @param array $query_args
83 - *
84 - * @return array
85 - */
86 - private static function add_url_params_to_views_redirect_query_args( $query_args ) {
87 - $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 );
88 -
89 - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
90 -
91 - if ( $form_id ) {
92 - $query_args['form'] = $form_id;
93 - }
94 -
95 - return $query_args;
96 - }
97 -
98 - /**
99 24 * @since 2.05.07
100 - *
101 - * @return void
102 25 */
103 26 private static function load_manage_entries_hooks() {
104 27 if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
105 28 $menu_name = FrmAppHelper::get_menu_name();
@@ -108,16 +31,14 @@
108 31 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
109 32 add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
110 33 add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
111 34 } else {
112 - 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 );
113 36 }
114 37 }
115 38
116 39 /**
117 40 * Display in Back End.
118 - *
119 - * @return mixed
120 41 */
121 42 public static function route() {
122 43 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
123 44 FrmAppHelper::include_svg();
@@ -128,15 +49,13 @@
128 49 return self::$action();
129 50
130 51 default:
131 52 do_action( 'frm_entry_action_route', $action );
132 -
133 53 if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
134 54 return;
135 55 }
136 56
137 - self::display_list();
138 - return;
57 + return self::display_list();
139 58 }
140 59 }
141 60
142 61 /**
@@ -143,19 +62,12 @@
143 62 * Prevent the "screen options" tab from showing when
144 63 * editing or creating an entry
145 64 *
146 65 * @since 3.0
147 - *
148 - * @param bool $show_screen Whether to show the screen options tab.
149 - * @param object $screen The current screen object.
150 - *
151 - * @return bool
152 66 */
153 67 public static function remove_screen_options( $show_screen, $screen ) {
154 - $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
155 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
156 -
157 - if ( $screen->id === $menu_name . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries' ) {
68 + $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
69 + if ( $screen->id == $menu_name . '_page_formidable-entries' ) {
158 70 $show_screen = false;
159 71 }
160 72
161 73 return $show_screen;
@@ -160,13 +72,8 @@
160 72
161 73 return $show_screen;
162 74 }
163 75
164 - /**
165 - * @param array $columns
166 - *
167 - * @return array
168 - */
169 76 public static function manage_columns( $columns ) {
170 77 global $frm_vars;
171 78 $form_id = FrmForm::get_current_form_id();
172 79
@@ -188,9 +95,8 @@
188 95
189 96 $frm_vars['cols'] = $columns;
190 97
191 98 $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
192 -
193 99 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
194 100 add_screen_option(
195 101 'per_page',
196 102 array(
@@ -203,14 +109,8 @@
203 109
204 110 return $columns;
205 111 }
206 112
207 - /**
208 - * @param int|string $form_id
209 - * @param array $columns
210 - *
211 - * @return void
212 - */
213 113 private static function get_columns_for_form( $form_id, &$columns ) {
214 114 $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
215 115
216 116 /**
@@ -227,10 +127,9 @@
227 127 if ( FrmField::is_no_save_field( $form_col->type ) ) {
228 128 continue;
229 129 }
230 130
231 - $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] );
232 -
131 + $has_child_fields = $form_col->type == 'form' && isset( $form_col->field_options['form_select'] ) && ! empty( $form_col->field_options['form_select'] );
233 132 if ( $has_child_fields ) {
234 133 self::add_subform_cols( $form_col, $form_id, $columns );
235 134 } else {
236 135 self::add_field_cols( $form_col, $form_id, $columns );
@@ -239,18 +138,11 @@
239 138 }
240 139
241 140 /**
242 141 * @since 3.01
243 - *
244 - * @param object $field The field object.
245 - * @param int|string $form_id The form ID.
246 - * @param array $columns The columns array.
247 - *
248 - * @return void
249 142 */
250 143 private static function add_subform_cols( $field, $form_id, &$columns ) {
251 144 $sub_form_cols = FrmField::get_all_for_form( $field->field_options['form_select'] );
252 -
253 145 if ( empty( $sub_form_cols ) ) {
254 146 return;
255 147 }
256 148
@@ -265,62 +157,24 @@
265 157 }
266 158
267 159 /**
268 160 * @since 3.01
269 - *
270 - * @param object $field The field object.
271 - * @param int|string $form_id The form ID.
272 - * @param array $columns The columns array.
273 - *
274 - * @return void
275 161 */
276 162 private static function add_field_cols( $field, $form_id, &$columns ) {
277 163 $col_id = $field->field_key;
278 -
279 164 if ( $field->form_id != $form_id ) {
280 165 $col_id .= '-_-form' . $field->form_id;
281 166 }
282 167
283 - $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
284 - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status';
285 - $include_column_for_sep_val = $has_separate_value && ! $is_post_status;
286 -
287 - if ( $include_column_for_sep_val ) {
288 - $columns[ $form_id . '_frmsep_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val );
168 + $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
169 + $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] == 'post_status';
170 + if ( $has_separate_value && ! $is_post_status ) {
171 + $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
289 172 }
290 173
291 - $columns[ $form_id . '_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, false );
174 + $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
292 175 }
293 176
294 - /**
295 - * Appends "(Value)" or "(Label)" to the field name if it's an option field that has a separate value/label.
296 - *
297 - * @since 6.25.1
298 - *
299 - * @param object $field
300 - * @param bool $include_column_for_sep_val
301 - * @param bool $is_value
302 - *
303 - * @return string
304 - */
305 - private static function maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, $is_value = true ) {
306 - $field_name = FrmAppHelper::truncate( $field->name, 35 );
307 -
308 - if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) {
309 - return $field_name;
310 - }
311 -
312 - $append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' );
313 -
314 - return sprintf( '%s (%s)', $field_name, $append_text );
315 - }
316 -
317 - /**
318 - * @param int|string $form_id The form ID.
319 - * @param array $columns The columns array.
320 - *
321 - * @return void
322 - */
323 177 private static function maybe_add_ip_col( $form_id, &$columns ) {
324 178 if ( FrmAppHelper::ips_saved() ) {
325 179 $columns[ $form_id . '_ip' ] = 'IP';
326 180 }
@@ -325,20 +179,10 @@
325 179 $columns[ $form_id . '_ip' ] = 'IP';
326 180 }
327 181 }
328 182
329 - /**
330 - * @param bool $check The check value.
331 - * @param int $object_id The object ID.
332 - * @param string $meta_key The meta key.
333 - * @param mixed $meta_value The meta value.
334 - * @param mixed $prev_value The previous value.
335 - *
336 - * @return bool
337 - */
338 183 public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
339 184 $this_page_name = self::hidden_column_key();
340 -
341 185 if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
342 186 return $check;
343 187 }
344 188
@@ -347,9 +191,9 @@
347 191 }
348 192
349 193 global $frm_vars;
350 194 // Add a check so we don't create a loop.
351 - $frm_vars['prev_hidden_cols'] = ! empty( $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
195 + $frm_vars['prev_hidden_cols'] = ( isset( $frm_vars['prev_hidden_cols'] ) && $frm_vars['prev_hidden_cols'] ) ? false : $prev_value;
352 196
353 197 return $check;
354 198 }
355 199
@@ -354,25 +198,16 @@
354 198 }
355 199
356 200 /**
357 201 * Add hidden columns back from other forms
358 - *
359 - * @param int $meta_id The meta ID.
360 - * @param int $object_id The object ID.
361 - * @param string $meta_key The meta key.
362 - * @param array $meta_value The meta value.
363 - *
364 - * @return void
365 202 */
366 203 public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
367 204 $this_page_name = self::hidden_column_key();
368 -
369 205 if ( $meta_key != $this_page_name ) {
370 206 return;
371 207 }
372 208
373 209 global $frm_vars;
374 -
375 210 if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
376 211 // Don't continue if there's no previous value.
377 212 return;
378 213 }
@@ -396,10 +231,9 @@
396 231 }
397 232
398 233 $form_prefix = explode( '_', $prev_hidden );
399 234 $form_prefix = $form_prefix[0];
400 -
401 - if ( $form_prefix === $cur_form_prefix ) {
235 + if ( $form_prefix == $cur_form_prefix ) {
402 236 // Don't add back columns that are meant to be hidden.
403 237 continue;
404 238 }
405 239
@@ -415,12 +249,8 @@
415 249 }
416 250
417 251 /**
418 252 * @since 2.05.07
419 - *
420 - * @param string $menu_name
421 - *
422 - * @return string
423 253 */
424 254 private static function hidden_column_key( $menu_name = '' ) {
425 255 $base = self::base_column_key( $menu_name );
426 256
@@ -428,12 +258,8 @@
428 258 }
429 259
430 260 /**
431 261 * @since 2.05.07
432 - *
433 - * @param string $menu_name
434 - *
435 - * @return string
436 262 */
437 263 private static function base_column_key( $menu_name = '' ) {
438 264 if ( empty( $menu_name ) ) {
439 265 $menu_name = FrmAppHelper::get_menu_name();
@@ -438,22 +264,13 @@
438 264 if ( empty( $menu_name ) ) {
439 265 $menu_name = FrmAppHelper::get_menu_name();
440 266 }
441 267
442 - $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
443 -
444 - return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries';
268 + return sanitize_title( $menu_name ) . '_page_formidable-entries';
445 269 }
446 270
447 - /**
448 - * @param int $save
449 - * @param string $option
450 - * @param string $value
451 - *
452 - * @return int
453 - */
454 271 public static function save_per_page( $save, $option, $value ) {
455 - if ( $option === 'formidable_page_formidable_entries_per_page' ) {
272 + if ( $option == 'formidable_page_formidable_entries_per_page' ) {
456 273 $save = (int) $value;
457 274 }
458 275
459 276 return $save;
@@ -458,11 +275,8 @@
458 275
459 276 return $save;
460 277 }
461 278
462 - /**
463 - * @return array
464 - */
465 279 public static function sortable_columns() {
466 280 $form_id = FrmForm::get_current_form_id();
467 281 $fields = FrmField::get_all_for_form( $form_id );
468 282
@@ -474,14 +288,8 @@
474 288 $form_id . '_item_key' => 'item_key',
475 289 $form_id . '_is_draft' => 'is_draft',
476 290 );
477 291
478 - if ( ! $form_id ) {
479 - $columns[ $form_id . '_user_id' ] = 'user_id';
480 - $columns[ $form_id . '_name' ] = 'name';
481 - $columns[ $form_id . '_form_id' ] = 'form_id';
482 - }
483 -
484 292 foreach ( $fields as $field ) {
485 293 if ( self::field_supports_sorting( $field ) ) {
486 294 $columns[ $form_id . '_' . $field->field_key ] = 'meta_' . $field->id;
487 295 }
@@ -494,9 +302,8 @@
494 302 * Can't sort on checkboxes because they are sorted serialized.
495 303 * Some post content can be sorted but not everything.
496 304 *
497 305 * @param stdClass $field
498 - *
499 306 * @return bool
500 307 */
501 308 private static function field_supports_sorting( $field ) {
502 309 $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] );
@@ -504,14 +311,11 @@
504 311 }
505 312
506 313 /**
507 314 * @param mixed $result Option value from database for hidden columns in entries table.
508 - *
509 315 * @return array
510 316 */
511 317 public static function hidden_columns( $result ) {
512 - global $frm_vars;
513 -
514 318 if ( ! is_array( $result ) ) {
515 319 // Force an unexpected value to be an array.
516 320 // Since $result is a filtered option and gets saved to the database, it's possible it could be a string.
517 321 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
@@ -517,16 +321,21 @@
517 321 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
518 322 $result = array();
519 323 }
520 324
521 - $form_id = FrmForm::get_current_form_id();
522 - $hidden = self::user_hidden_columns_for_form( $form_id, $result );
523 - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
524 - $max_columns = 11;
325 + $form_id = FrmForm::get_current_form_id();
525 326
327 + $hidden = self::user_hidden_columns_for_form( $form_id, $result );
328 +
329 + global $frm_vars;
330 + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
331 +
526 332 if ( ! empty( $hidden ) ) {
527 - $result = $hidden;
528 - $i = $i - count( $result );
333 + $result = $hidden;
334 + $i = $i - count( $result );
335 + $max_columns = 11;
336 + } else {
337 + $max_columns = 8;
529 338 }
530 339
531 340 if ( $i <= $max_columns ) {
532 341 return $result;
@@ -538,22 +347,16 @@
538 347 }
539 348
540 349 /**
541 350 * @since 2.05.07
542 - *
543 - * @param int|string $form_id
544 - * @param mixed $result
545 - *
546 - * @return array
547 351 */
548 352 private static function user_hidden_columns_for_form( $form_id, $result ) {
549 353 $hidden = array();
550 -
551 354 foreach ( (array) $result as $r ) {
552 355 if ( ! empty( $r ) ) {
553 356 list( $form_prefix, $field_key ) = explode( '_', $r );
554 357
555 - if ( (int) $form_prefix === (int) $form_id ) {
358 + if ( (int) $form_prefix == (int) $form_id ) {
556 359 $hidden[] = $r;
557 360 }
558 361
559 362 unset( $form_prefix );
@@ -566,13 +369,8 @@
566 369 /**
567 370 * Remove some columns by default when there are too many
568 371 *
569 372 * @since 2.05.07
570 - *
571 - * @param array $atts
572 - * @param array $result
573 - *
574 - * @return void
575 373 */
576 374 private static function remove_excess_cols( $atts, &$result ) {
577 375 global $frm_vars;
578 376
@@ -590,9 +388,9 @@
590 388 }
591 389
592 390 if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
593 391 $result[] = $col_key;
594 - --$i;
392 + $i--;
595 393 }
596 394
597 395 unset( $col_key, $col );
598 396 }
@@ -597,14 +395,8 @@
597 395 unset( $col_key, $col );
598 396 }
599 397 }
600 398
601 - /**
602 - * @param string $message
603 - * @param array $errors
604 - *
605 - * @return void
606 - */
607 399 public static function display_list( $message = '', $errors = array() ) {
608 400 global $wpdb, $frm_vars;
609 401
610 402 $form = FrmForm::maybe_get_current_form();
@@ -625,12 +417,10 @@
625 417
626 418 $wp_list_table->prepare_items();
627 419
628 420 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
629 -
630 421 if ( $pagenum > $total_pages && $total_pages > 0 ) {
631 422 $url = add_query_arg( 'paged', $total_pages );
632 -
633 423 if ( headers_sent() ) {
634 424 FrmAppHelper::js_redirect( $url, true );
635 425 } else {
636 426 wp_redirect( esc_url_raw( $url ) );
@@ -644,30 +434,20 @@
644 434
645 435 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
646 436 }
647 437
648 - /**
649 - * @param object $form
650 - * @param array $errors
651 - *
652 - * @return void
653 - */
654 438 private static function get_delete_form_time( $form, &$errors ) {
655 - if ( 'trash' === $form->status ) {
439 + if ( 'trash' == $form->status ) {
656 440 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
657 - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) );
441 + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? ( $form->options['trash_time'] ) : time() ) );
658 442
659 443 /* translators: %1$s: Time string */
660 - $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 );
444 + $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 );
661 445 }
662 446 }
663 447
664 448 /**
665 449 * Back End CRUD.
666 - *
667 - * @param int $id
668 - *
669 - * @return void
670 450 */
671 451 public static function show( $id = 0 ) {
672 452 FrmAppHelper::permission_check( 'frm_view_entries' );
673 453
@@ -679,22 +459,17 @@
679 459 }
680 460 }
681 461
682 462 $entry = FrmEntry::getOne( $id, true );
463 + if ( ! $entry ) {
464 + echo '<div id="form_show_entry_page" class="wrap">' .
465 + esc_html__( 'You are trying to view an entry that does not exist.', 'formidable' ) .
466 + '</div>';
683 467
684 - if ( ! $entry ) {
685 - FrmAppController::show_error_modal(
686 - array(
687 - 'title' => __( 'You can\'t view the entry', 'formidable' ),
688 - 'body' => __( 'You are trying to view an entry that does not exist', 'formidable' ),
689 - 'cancel_url' => admin_url( 'admin.php?page=formidable' ),
690 - )
691 - );
692 468 return;
693 469 }
694 470
695 471 $data = $entry->description;
696 -
697 472 if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
698 473 $data = array( 'referrer' => $data );
699 474 }
700 475
@@ -700,9 +475,9 @@
700 475
701 476 $fields = FrmField::get_all_for_form( $entry->form_id, '', 'include' );
702 477 $form = FrmForm::getOne( $entry->form_id );
703 478
704 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php';
479 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/show.php' );
705 480 }
706 481
707 482 /**
708 483 * Destroy an entry from the admin page.
@@ -711,14 +486,13 @@
711 486 * @return void
712 487 */
713 488 public static function destroy() {
714 489 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
715 -
716 490 if ( false !== $permission_error ) {
717 491 $error_args = array(
718 - 'title' => __( 'Verification failed', 'formidable' ),
719 - 'body' => $permission_error,
720 - 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
492 + 'title' => __( 'Verification failed', 'formidable' ),
493 + 'body' => $permission_error,
494 + 'cancel_url' => admin_url( 'admin.php?page=formidable-entries' ),
721 495 );
722 496 FrmAppController::show_error_modal( $error_args );
723 497 return;
724 498 }
@@ -729,9 +503,8 @@
729 503 self::unlink_post( $params['id'] );
730 504 }
731 505
732 506 $message = '';
733 -
734 507 if ( FrmEntry::destroy( $params['id'] ) ) {
735 508 $message = __( 'Entry was successfully deleted', 'formidable' );
736 509 }
737 510
@@ -738,16 +511,19 @@
738 511 self::display_list( $message );
739 512 }
740 513
741 514 /**
742 - * @param array|string $errors
743 - * @param bool $ajax
744 - *
745 - * @return void
515 + * @deprecated 4.02.04 - Moved to Pro since it was unused in Lite.
746 516 */
517 + public static function destroy_all() {
518 + _deprecated_function( __METHOD__, '4.02.04', 'FrmProEntriesController::destroy_all' );
519 + if ( is_callable( 'FrmProEntriesController::destroy_all' ) ) {
520 + FrmProEntriesController::destroy_all();
521 + }
522 + }
523 +
747 524 public static function process_entry( $errors = '', $ajax = false ) {
748 525 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
749 -
750 526 if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
751 527 return;
752 528 }
753 529
@@ -753,19 +529,12 @@
753 529
754 530 global $frm_vars;
755 531
756 532 $form = FrmForm::getOne( $form_id );
757 -
758 533 if ( ! $form ) {
759 534 return;
760 535 }
761 536
762 - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' );
763 -
764 - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) {
765 - return;
766 - }
767 -
768 537 $params = FrmForm::get_params( $form );
769 538
770 539 if ( ! isset( $frm_vars['form_params'] ) ) {
771 540 $frm_vars['form_params'] = array();
@@ -792,9 +561,8 @@
792 561
793 562 if ( empty( $errors ) ) {
794 563 $_POST['frm_skip_cookie'] = 1;
795 564 $do_success = false;
796 -
797 565 if ( $params['action'] === 'create' ) {
798 566 if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
799 567 $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
800 568
@@ -803,9 +571,8 @@
803 571 }
804 572 }
805 573
806 574 do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
807 -
808 575 if ( $do_success ) {
809 576 FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
810 577 }
811 578 unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -824,17 +591,8 @@
824 591 public static function prepare_redirect_url( $url ) {
825 592 return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
826 593 }
827 594
828 - /**
829 - * Delete entry if redirected.
830 - *
831 - * @param string $url
832 - * @param object $form
833 - * @param array $atts
834 - *
835 - * @return string
836 - */
837 595 public static function delete_entry_before_redirect( $url, $form, $atts ) {
838 596 self::_delete_entry( $atts['id'], $form );
839 597
840 598 return $url;
@@ -843,23 +601,13 @@
843 601 /**
844 602 * Delete entry if not redirected.
845 603 *
846 604 * @param array $atts
847 - *
848 - * @return void
849 605 */
850 606 public static function delete_entry_after_save( $atts ) {
851 607 self::_delete_entry( $atts['entry_id'], $atts['form'] );
852 608 }
853 609
854 - /**
855 - * Delete entry if not redirected.
856 - *
857 - * @param int $entry_id
858 - * @param object $form
859 - *
860 - * @return void
861 - */
862 610 private static function _delete_entry( $entry_id, $form ) {
863 611 if ( ! $form ) {
864 612 return;
865 613 }
@@ -864,9 +612,8 @@
864 612 return;
865 613 }
866 614
867 615 FrmAppHelper::unserialize_or_decode( $form->options );
868 -
869 616 if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
870 617 self::unlink_post( $entry_id );
871 618 FrmEntry::destroy( $entry_id );
872 619 }
@@ -873,12 +620,8 @@
873 620 }
874 621
875 622 /**
876 623 * Unlink entry from post
877 - *
878 - * @param int $entry_id
879 - *
880 - * @return void
881 624 */
882 625 private static function unlink_post( $entry_id ) {
883 626 global $wpdb;
884 627 $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $entry_id ) );
@@ -914,9 +657,8 @@
914 657 'exclude_fields' => '',
915 658 'include_fields' => '',
916 659 'include_extras' => '',
917 660 'inline_style' => 1,
918 - 'table_style' => '',
919 661 // Return embedded fields as nested array.
920 662 'child_array' => false,
921 663 'line_breaks' => true,
922 664 'array_separator' => ', ',
@@ -943,13 +685,8 @@
943 685
944 686 return $formatted_entry;
945 687 }
946 688
947 - /**
948 - * @param false|object $entry
949 - *
950 - * @return void
951 - */
952 689 public static function entry_sidebar( $entry = false ) {
953 690 $data = array();
954 691 $id = 0;
955 692
@@ -958,9 +695,8 @@
958 695
959 696 if ( $entry ) {
960 697 $id = $entry->id;
961 698 $data = $entry->description;
962 -
963 699 if ( isset( $data['browser'] ) ) {
964 700 $browser = FrmEntriesHelper::get_browser( $data['browser'] );
965 701 }
966 702 /**
@@ -966,14 +702,20 @@
966 702 /**
967 703 * Add or remove information in the entry sidebar.
968 704 *
969 705 * @since 5.5.2
970 - *
971 706 * @param array $data
972 - * @param array{entry:\stdClass} $entry
973 707 */
974 708 $data = apply_filters( 'frm_sidebar_data', $data, compact( 'entry' ) );
975 709 }
976 710
977 - include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php';
711 + include( FrmAppHelper::plugin_path() . '/classes/views/frm-entries/sidebar-shared.php' );
712 + }
713 +
714 + /**
715 + * @deprecated 4.0
716 + */
717 + public static function contextual_help( $help, $screen_id, $screen ) {
718 + _deprecated_function( __METHOD__, '4.0' );
719 + return $help;
978 720 }
979 721 }