PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.18
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.18
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 +61 -245 6.276.18 View file →
@@ -4,20 +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 - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
11 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Entries', 'formidable' ), __( 'Entries', 'formidable' ), 'frm_view_entries', 'formidable-entries', 'FrmEntriesController::route' );
15 12
16 13 $views_installed = is_callable( 'FrmProAppHelper::views_is_installed' ) && FrmProAppHelper::views_is_installed();
17 -
18 14 if ( ! $views_installed ) {
19 - add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
15 + add_submenu_page( 'formidable', 'Formidable | ' . __( 'Views', 'formidable' ), __( 'Views', 'formidable' ), 'frm_view_entries', 'formidable-views', 'FrmFormsController::no_views' );
20 16 self::maybe_redirect_to_views_upsell();
21 17 } else {
22 18 self::maybe_redirect_to_views_index();
23 19 }
@@ -61,9 +57,8 @@
61 57 * @return void
62 58 */
63 59 private static function maybe_redirect_to_views_upsell() {
64 60 global $pagenow;
65 -
66 61 if ( 'edit.php' !== $pagenow || 'frm_display' !== FrmAppHelper::simple_get( 'post_type' ) ) {
67 62 return;
68 63 }
69 64
@@ -79,15 +74,14 @@
79 74 /**
80 75 * @since 6.14.1
81 76 *
82 77 * @param array $query_args
83 - *
84 78 * @return array
85 79 */
86 80 private static function add_url_params_to_views_redirect_query_args( $query_args ) {
87 81 $query_args['show_nav'] = FrmAppHelper::simple_get( 'show_nav', 'absint', 0 );
88 - $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
89 82
83 + $form_id = FrmAppHelper::simple_get( 'form', 'absint', 0 );
90 84 if ( $form_id ) {
91 85 $query_args['form'] = $form_id;
92 86 }
93 87
@@ -95,10 +89,8 @@
95 89 }
96 90
97 91 /**
98 92 * @since 2.05.07
99 - *
100 - * @return void
101 93 */
102 94 private static function load_manage_entries_hooks() {
103 95 if ( ! in_array( FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' ), array( 'edit', 'show', 'new', 'duplicate' ), true ) ) {
104 96 $menu_name = FrmAppHelper::get_menu_name();
@@ -107,16 +99,14 @@
107 99 add_filter( 'manage_' . $base . '_columns', 'FrmEntriesController::manage_columns' );
108 100 add_filter( 'get_user_option_' . self::hidden_column_key( $menu_name ), 'FrmEntriesController::hidden_columns' );
109 101 add_filter( 'manage_' . $base . '_sortable_columns', 'FrmEntriesController::sortable_columns' );
110 102 } else {
111 - add_filter( 'screen_options_show_screen', self::class . '::remove_screen_options', 10, 2 );
103 + add_filter( 'screen_options_show_screen', __CLASS__ . '::remove_screen_options', 10, 2 );
112 104 }
113 105 }
114 106
115 107 /**
116 108 * Display in Back End.
117 - *
118 - * @return mixed
119 109 */
120 110 public static function route() {
121 111 $action = FrmAppHelper::get_param( 'frm_action', '', 'get', 'sanitize_title' );
122 112 FrmAppHelper::include_svg();
@@ -127,15 +117,13 @@
127 117 return self::$action();
128 118
129 119 default:
130 120 do_action( 'frm_entry_action_route', $action );
131 -
132 121 if ( apply_filters( 'frm_entry_stop_action_route', false, $action ) ) {
133 - return null;
122 + return;
134 123 }
135 124
136 - self::display_list();
137 - return null;
125 + return self::display_list();
138 126 }
139 127 }
140 128
141 129 /**
@@ -142,13 +130,8 @@
142 130 * Prevent the "screen options" tab from showing when
143 131 * editing or creating an entry
144 132 *
145 133 * @since 3.0
146 - *
147 - * @param bool $show_screen Whether to show the screen options tab.
148 - * @param object $screen The current screen object.
149 - *
150 - * @return bool
151 134 */
152 135 public static function remove_screen_options( $show_screen, $screen ) {
153 136 $menu_name = sanitize_title( FrmAppHelper::get_menu_name() );
154 137 $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
@@ -159,13 +142,8 @@
159 142
160 143 return $show_screen;
161 144 }
162 145
163 - /**
164 - * @param array $columns
165 - *
166 - * @return array
167 - */
168 146 public static function manage_columns( $columns ) {
169 147 global $frm_vars;
170 148 $form_id = FrmForm::get_current_form_id();
171 149
@@ -185,11 +163,11 @@
185 163 $columns[ $form_id . '_updated_at' ] = __( 'Entry update date', 'formidable' );
186 164 self::maybe_add_ip_col( $form_id, $columns );
187 165
188 166 $frm_vars['cols'] = $columns;
189 - $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
190 167
191 - if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ), true ) ) {
168 + $action = FrmAppHelper::simple_get( 'frm_action', 'sanitize_title' );
169 + if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) && in_array( $action, array( '', 'list', 'destroy' ) ) ) {
192 170 add_screen_option(
193 171 'per_page',
194 172 array(
195 173 'label' => esc_html__( 'Entries', 'formidable' ),
@@ -201,14 +179,8 @@
201 179
202 180 return $columns;
203 181 }
204 182
205 - /**
206 - * @param int|string $form_id
207 - * @param array $columns
208 - *
209 - * @return void
210 - */
211 183 private static function get_columns_for_form( $form_id, &$columns ) {
212 184 $form_cols = FrmField::get_all_for_form( $form_id, '', 'include' );
213 185
214 186 /**
@@ -226,9 +198,8 @@
226 198 continue;
227 199 }
228 200
229 201 $has_child_fields = $form_col->type === 'form' && ! empty( $form_col->field_options['form_select'] );
230 -
231 202 if ( $has_child_fields ) {
232 203 self::add_subform_cols( $form_col, $form_id, $columns );
233 204 } else {
234 205 self::add_field_cols( $form_col, $form_id, $columns );
@@ -237,19 +208,12 @@
237 208 }
238 209
239 210 /**
240 211 * @since 3.01
241 - *
242 - * @param object $field The field object.
243 - * @param int|string $form_id The form ID.
244 - * @param array $columns The columns array.
245 - *
246 - * @return void
247 212 */
248 213 private static function add_subform_cols( $field, $form_id, &$columns ) {
249 214 $sub_form_cols = FrmField::get_all_for_form( $field->field_options['form_select'] );
250 -
251 - if ( ! $sub_form_cols ) {
215 + if ( empty( $sub_form_cols ) ) {
252 216 return;
253 217 }
254 218
255 219 foreach ( $sub_form_cols as $k => $sub_form_col ) {
@@ -256,9 +220,8 @@
256 220 if ( FrmField::is_no_save_field( $sub_form_col->type ) ) {
257 221 unset( $sub_form_cols[ $k ] );
258 222 continue;
259 223 }
260 -
261 224 $columns[ $form_id . '_' . $sub_form_col->field_key . '-_-' . $field->id ] = FrmAppHelper::truncate( $sub_form_col->name, 35 );
262 225 unset( $sub_form_col );
263 226 }
264 227 }
@@ -264,62 +227,24 @@
264 227 }
265 228
266 229 /**
267 230 * @since 3.01
268 - *
269 - * @param object $field The field object.
270 - * @param int|string $form_id The form ID.
271 - * @param array $columns The columns array.
272 - *
273 - * @return void
274 231 */
275 232 private static function add_field_cols( $field, $form_id, &$columns ) {
276 233 $col_id = $field->field_key;
277 -
278 - if ( (int) $field->form_id !== (int) $form_id ) {
234 + if ( $field->form_id != $form_id ) {
279 235 $col_id .= '-_-form' . $field->form_id;
280 236 }
281 237
282 - $has_separate_value = ! FrmField::is_option_empty( $field, 'separate_value' );
283 - $is_post_status = FrmField::is_option_true( $field, 'post_field' ) && $field->field_options['post_field'] === 'post_status';
284 - $include_column_for_sep_val = $has_separate_value && ! $is_post_status;
285 -
286 - if ( $include_column_for_sep_val ) {
287 - $columns[ $form_id . '_frmsep_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val );
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 + if ( $has_separate_value && ! $is_post_status ) {
241 + $columns[ $form_id . '_frmsep_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
288 242 }
289 243
290 - $columns[ $form_id . '_' . $col_id ] = self::maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, false );
244 + $columns[ $form_id . '_' . $col_id ] = FrmAppHelper::truncate( $field->name, 35 );
291 245 }
292 246
293 - /**
294 - * Appends "(Value)" or "(Label)" to the field name if it's an option field that has a separate value/label.
295 - *
296 - * @since 6.25.1
297 - *
298 - * @param object $field
299 - * @param bool $include_column_for_sep_val
300 - * @param bool $is_value
301 - *
302 - * @return string
303 - */
304 - private static function maybe_format_field_name_for_column_title( $field, $include_column_for_sep_val, $is_value = true ) {
305 - $field_name = FrmAppHelper::truncate( $field->name, 35 );
306 -
307 - if ( ! $include_column_for_sep_val || ! in_array( $field->type, array( 'select', 'radio', 'checkbox' ), true ) ) {
308 - return $field_name;
309 - }
310 -
311 - $append_text = $is_value ? esc_html__( 'value', 'formidable' ) : esc_html__( 'label', 'formidable' );
312 -
313 - return sprintf( '%s (%s)', $field_name, $append_text );
314 - }
315 -
316 - /**
317 - * @param int|string $form_id The form ID.
318 - * @param array $columns The columns array.
319 - *
320 - * @return void
321 - */
322 247 private static function maybe_add_ip_col( $form_id, &$columns ) {
323 248 if ( FrmAppHelper::ips_saved() ) {
324 249 $columns[ $form_id . '_ip' ] = 'IP';
325 250 }
@@ -324,26 +249,15 @@
324 249 $columns[ $form_id . '_ip' ] = 'IP';
325 250 }
326 251 }
327 252
328 - /**
329 - * @param bool $check The check value.
330 - * @param int $object_id The object ID.
331 - * @param string $meta_key The meta key.
332 - * @param mixed $meta_value The meta value.
333 - * @param mixed $prev_value The previous value.
334 - *
335 - * @return bool
336 - */
337 253 public static function check_hidden_cols( $check, $object_id, $meta_key, $meta_value, $prev_value ) {
338 254 $this_page_name = self::hidden_column_key();
339 -
340 - // phpcs:ignore Universal.Operators.StrictComparisons
341 255 if ( $meta_key != $this_page_name || $meta_value == $prev_value ) {
342 256 return $check;
343 257 }
344 258
345 - if ( ! $prev_value ) {
259 + if ( empty( $prev_value ) ) {
346 260 $prev_value = get_metadata( 'user', $object_id, $meta_key, true );
347 261 }
348 262
349 263 global $frm_vars;
@@ -354,27 +268,17 @@
354 268 }
355 269
356 270 /**
357 271 * 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 272 */
366 273 public static function update_hidden_cols( $meta_id, $object_id, $meta_key, $meta_value ) {
367 274 $this_page_name = self::hidden_column_key();
368 -
369 - // phpcs:ignore Universal.Operators.StrictComparisons
370 275 if ( $meta_key != $this_page_name ) {
371 276 return;
372 277 }
373 278
374 279 global $frm_vars;
375 -
376 - if ( empty( $frm_vars['prev_hidden_cols'] ) ) {
280 + if ( ! isset( $frm_vars['prev_hidden_cols'] ) || ! $frm_vars['prev_hidden_cols'] ) {
377 281 // Don't continue if there's no previous value.
378 282 return;
379 283 }
380 284
@@ -390,9 +294,8 @@
390 294 $cur_form_prefix = $cur_form_prefix[0];
391 295 $save = false;
392 296
393 297 foreach ( (array) $frm_vars['prev_hidden_cols'] as $prev_hidden ) {
394 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
395 298 if ( empty( $prev_hidden ) || in_array( $prev_hidden, $meta_value ) ) {
396 299 // Don't add blank cols or process included cols.
397 300 continue;
398 301 }
@@ -398,10 +301,9 @@
398 301 }
399 302
400 303 $form_prefix = explode( '_', $prev_hidden );
401 304 $form_prefix = $form_prefix[0];
402 -
403 - if ( $form_prefix === $cur_form_prefix ) {
305 + if ( $form_prefix == $cur_form_prefix ) {
404 306 // Don't add back columns that are meant to be hidden.
405 307 continue;
406 308 }
407 309
@@ -417,27 +319,20 @@
417 319 }
418 320
419 321 /**
420 322 * @since 2.05.07
421 - *
422 - * @param string $menu_name
423 - *
424 - * @return string
425 323 */
426 324 private static function hidden_column_key( $menu_name = '' ) {
427 325 $base = self::base_column_key( $menu_name );
326 +
428 327 return 'manage' . $base . 'columnshidden';
429 328 }
430 329
431 330 /**
432 331 * @since 2.05.07
433 - *
434 - * @param string $menu_name
435 - *
436 - * @return string
437 332 */
438 333 private static function base_column_key( $menu_name = '' ) {
439 - if ( ! $menu_name ) {
334 + if ( empty( $menu_name ) ) {
440 335 $menu_name = FrmAppHelper::get_menu_name();
441 336 }
442 337
443 338 $unread_count = FrmEntriesHelper::get_visible_unread_inbox_count();
@@ -444,15 +339,8 @@
444 339
445 340 return sanitize_title( $menu_name ) . ( $unread_count ? '-' . $unread_count : '' ) . '_page_formidable-entries';
446 341 }
447 342
448 - /**
449 - * @param int $save
450 - * @param string $option
451 - * @param string $value
452 - *
453 - * @return int
454 - */
455 343 public static function save_per_page( $save, $option, $value ) {
456 344 if ( $option === 'formidable_page_formidable_entries_per_page' ) {
457 345 $save = (int) $value;
458 346 }
@@ -459,11 +347,8 @@
459 347
460 348 return $save;
461 349 }
462 350
463 - /**
464 - * @return array
465 - */
466 351 public static function sortable_columns() {
467 352 $form_id = FrmForm::get_current_form_id();
468 353 $fields = FrmField::get_all_for_form( $form_id );
469 354
@@ -495,9 +380,8 @@
495 380 * Can't sort on checkboxes because they are sorted serialized.
496 381 * Some post content can be sorted but not everything.
497 382 *
498 383 * @param stdClass $field
499 - *
500 384 * @return bool
501 385 */
502 386 private static function field_supports_sorting( $field ) {
503 387 $is_sortable = 'checkbox' !== $field->type && empty( $field->field_options['post_field'] );
@@ -505,14 +389,11 @@
505 389 }
506 390
507 391 /**
508 392 * @param mixed $result Option value from database for hidden columns in entries table.
509 - *
510 393 * @return array
511 394 */
512 395 public static function hidden_columns( $result ) {
513 - global $frm_vars;
514 -
515 396 if ( ! is_array( $result ) ) {
516 397 // Force an unexpected value to be an array.
517 398 // Since $result is a filtered option and gets saved to the database, it's possible it could be a string.
518 399 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
@@ -518,16 +399,21 @@
518 399 // Since this code expects an array it would break with a "Uncaught Error: [] operator not supported for strings" error.
519 400 $result = array();
520 401 }
521 402
522 - $form_id = FrmForm::get_current_form_id();
523 - $hidden = self::user_hidden_columns_for_form( $form_id, $result );
524 - $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
525 - $max_columns = 11;
403 + $form_id = FrmForm::get_current_form_id();
526 404
527 - if ( $hidden ) {
528 - $result = $hidden;
529 - $i = $i - count( $result );
405 + $hidden = self::user_hidden_columns_for_form( $form_id, $result );
406 +
407 + global $frm_vars;
408 + $i = isset( $frm_vars['cols'] ) ? count( $frm_vars['cols'] ) : 0;
409 +
410 + if ( ! empty( $hidden ) ) {
411 + $result = $hidden;
412 + $i = $i - count( $result );
413 + $max_columns = 11;
414 + } else {
415 + $max_columns = 8;
530 416 }
531 417
532 418 if ( $i <= $max_columns ) {
533 419 return $result;
@@ -539,17 +425,11 @@
539 425 }
540 426
541 427 /**
542 428 * @since 2.05.07
543 - *
544 - * @param int|string $form_id
545 - * @param mixed $result
546 - *
547 - * @return array
548 429 */
549 430 private static function user_hidden_columns_for_form( $form_id, $result ) {
550 431 $hidden = array();
551 -
552 432 foreach ( (array) $result as $r ) {
553 433 if ( ! empty( $r ) ) {
554 434 list( $form_prefix, $field_key ) = explode( '_', $r );
555 435
@@ -567,13 +447,8 @@
567 447 /**
568 448 * Remove some columns by default when there are too many
569 449 *
570 450 * @since 2.05.07
571 - *
572 - * @param array $atts
573 - * @param array $result
574 - *
575 - * @return void
576 451 */
577 452 private static function remove_excess_cols( $atts, &$result ) {
578 453 global $frm_vars;
579 454
@@ -581,16 +456,17 @@
581 456 $atts['form_id'] . '_item_key' => '',
582 457 $atts['form_id'] . '_id' => '',
583 458 );
584 459 $cols = $remove_first + array_reverse( $frm_vars['cols'], true );
585 - $i = $atts['i'];
586 460
461 + $i = $atts['i'];
462 +
587 463 foreach ( $cols as $col_key => $col ) {
588 464 if ( $i <= $atts['max_columns'] ) {
589 465 break;
590 466 }
591 467
592 - if ( ! $result || ! in_array( $col_key, $result, true ) ) {
468 + if ( empty( $result ) || ! in_array( $col_key, $result, true ) ) {
593 469 $result[] = $col_key;
594 470 --$i;
595 471 }
596 472
@@ -597,14 +473,8 @@
597 473 unset( $col_key, $col );
598 474 }
599 475 }
600 476
601 - /**
602 - * @param string $message
603 - * @param array $errors
604 - *
605 - * @return void
606 - */
607 477 public static function display_list( $message = '', $errors = array() ) {
608 478 global $wpdb, $frm_vars;
609 479
610 480 $form = FrmForm::maybe_get_current_form();
@@ -616,19 +486,19 @@
616 486
617 487 self::get_delete_form_time( $form, $errors );
618 488 }
619 489
620 - $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
490 + $table_class = apply_filters( 'frm_entries_list_class', 'FrmEntriesListHelper' );
491 +
621 492 $wp_list_table = new $table_class( array( 'params' => $params ) );
622 - $pagenum = $wp_list_table->get_pagenum();
623 493
494 + $pagenum = $wp_list_table->get_pagenum();
495 +
624 496 $wp_list_table->prepare_items();
625 497
626 498 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
627 -
628 499 if ( $pagenum > $total_pages && $total_pages > 0 ) {
629 500 $url = add_query_arg( 'paged', $total_pages );
630 -
631 501 if ( headers_sent() ) {
632 502 FrmAppHelper::js_redirect( $url, true );
633 503 } else {
634 504 wp_redirect( esc_url_raw( $url ) );
@@ -635,9 +505,9 @@
635 505 }
636 506 die();
637 507 }
638 508
639 - if ( ! $message && isset( $_GET['import-message'] ) ) {
509 + if ( empty( $message ) && isset( $_GET['import-message'] ) ) {
640 510 $message = __( 'Your import is complete', 'formidable' );
641 511 }
642 512
643 513 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
@@ -642,18 +512,12 @@
642 512
643 513 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/list.php';
644 514 }
645 515
646 - /**
647 - * @param object $form
648 - * @param array $errors
649 - *
650 - * @return void
651 - */
652 516 private static function get_delete_form_time( $form, &$errors ) {
653 517 if ( 'trash' === $form->status ) {
654 518 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS );
655 - $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( $form->options['trash_time'] ?? time() ) );
519 + $time_to_delete = FrmAppHelper::human_time_diff( $delete_timestamp, ( isset( $form->options['trash_time'] ) ? $form->options['trash_time'] : time() ) );
656 520
657 521 /* translators: %1$s: Time string */
658 522 $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 );
659 523 }
@@ -660,12 +524,8 @@
660 524 }
661 525
662 526 /**
663 527 * Back End CRUD.
664 - *
665 - * @param int $id
666 - *
667 - * @return void
668 528 */
669 529 public static function show( $id = 0 ) {
670 530 FrmAppHelper::permission_check( 'frm_view_entries' );
671 531
@@ -677,9 +537,8 @@
677 537 }
678 538 }
679 539
680 540 $entry = FrmEntry::getOne( $id, true );
681 -
682 541 if ( ! $entry ) {
683 542 FrmAppController::show_error_modal(
684 543 array(
685 544 'title' => __( 'You can\'t view the entry', 'formidable' ),
@@ -690,9 +549,8 @@
690 549 return;
691 550 }
692 551
693 552 $data = $entry->description;
694 -
695 553 if ( ! is_array( $data ) || ! isset( $data['referrer'] ) ) {
696 554 $data = array( 'referrer' => $data );
697 555 }
698 556
@@ -709,9 +567,8 @@
709 567 * @return void
710 568 */
711 569 public static function destroy() {
712 570 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_entries', '_wpnonce', -1 );
713 -
714 571 if ( false !== $permission_error ) {
715 572 $error_args = array(
716 573 'title' => __( 'Verification failed', 'formidable' ),
717 574 'body' => $permission_error,
@@ -722,14 +579,13 @@
722 579 }
723 580
724 581 $params = FrmForm::get_admin_params();
725 582
726 - if ( ! empty( $params['keep_post'] ) ) {
583 + if ( isset( $params['keep_post'] ) && $params['keep_post'] ) {
727 584 self::unlink_post( $params['id'] );
728 585 }
729 586
730 587 $message = '';
731 -
732 588 if ( FrmEntry::destroy( $params['id'] ) ) {
733 589 $message = __( 'Entry was successfully deleted', 'formidable' );
734 590 }
735 591
@@ -735,18 +591,11 @@
735 591
736 592 self::display_list( $message );
737 593 }
738 594
739 - /**
740 - * @param array|string $errors
741 - * @param bool $ajax
742 - *
743 - * @return void
744 - */
745 595 public static function process_entry( $errors = '', $ajax = false ) {
746 596 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
747 -
748 - if ( FrmAppHelper::is_admin() || empty( $_POST ) || ! $form_id || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
597 + if ( FrmAppHelper::is_admin() || empty( $_POST ) || empty( $form_id ) || ! isset( $_POST['item_key'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
749 598 return;
750 599 }
751 600
752 601 global $frm_vars;
@@ -751,19 +600,12 @@
751 600
752 601 global $frm_vars;
753 602
754 603 $form = FrmForm::getOne( $form_id );
755 -
756 604 if ( ! $form ) {
757 605 return;
758 606 }
759 607
760 - $is_preview = 'frm_forms_preview' === FrmAppHelper::simple_get( 'action' );
761 -
762 - if ( $is_preview && FrmFormsHelper::should_block_preview( $form->form_key ) ) {
763 - return;
764 - }
765 -
766 608 $params = FrmForm::get_params( $form );
767 609
768 610 if ( ! isset( $frm_vars['form_params'] ) ) {
769 611 $frm_vars['form_params'] = array();
@@ -773,9 +615,8 @@
773 615 if ( isset( $frm_vars['created_entries'][ $form_id ] ) ) {
774 616 return;
775 617 }
776 618
777 - // phpcs:ignore Universal.Operators.StrictComparisons
778 619 if ( $errors == '' && ! $ajax ) {
779 620 $errors = FrmEntryValidate::validate( wp_unslash( $_POST ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
780 621 }
781 622
@@ -788,12 +629,11 @@
788 629 $errors = apply_filters( 'frm_entries_before_create', $errors, $form );
789 630
790 631 $frm_vars['created_entries'][ $form_id ] = array( 'errors' => $errors );
791 632
792 - if ( ! $errors ) {
633 + if ( empty( $errors ) ) {
793 634 $_POST['frm_skip_cookie'] = 1;
794 635 $do_success = false;
795 -
796 636 if ( $params['action'] === 'create' ) {
797 637 if ( apply_filters( 'frm_continue_to_create', true, $form_id ) && ! isset( $frm_vars['created_entries'][ $form_id ]['entry_id'] ) ) {
798 638 $frm_vars['created_entries'][ $form_id ]['entry_id'] = FrmEntry::create( $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
799 639
@@ -802,9 +642,8 @@
802 642 }
803 643 }
804 644
805 645 do_action( 'frm_process_entry', $params, $errors, $form, array( 'ajax' => $ajax ) );
806 -
807 646 if ( $do_success ) {
808 647 FrmFormsController::maybe_trigger_redirect( $form, $params, array( 'ajax' => $ajax ) );
809 648 }
810 649 unset( $_POST['frm_skip_cookie'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
@@ -823,19 +662,11 @@
823 662 public static function prepare_redirect_url( $url ) {
824 663 return str_replace( array( ' ', '[', ']', '|', '@' ), array( '%20', '%5B', '%5D', '%7C', '%40' ), $url );
825 664 }
826 665
827 - /**
828 - * Delete entry if redirected.
829 - *
830 - * @param string $url
831 - * @param object $form
832 - * @param array $atts
833 - *
834 - * @return string
835 - */
836 666 public static function delete_entry_before_redirect( $url, $form, $atts ) {
837 667 self::_delete_entry( $atts['id'], $form );
668 +
838 669 return $url;
839 670 }
840 671
841 672 /**
@@ -841,23 +672,13 @@
841 672 /**
842 673 * Delete entry if not redirected.
843 674 *
844 675 * @param array $atts
845 - *
846 - * @return void
847 676 */
848 677 public static function delete_entry_after_save( $atts ) {
849 678 self::_delete_entry( $atts['entry_id'], $atts['form'] );
850 679 }
851 680
852 - /**
853 - * Delete entry if not redirected.
854 - *
855 - * @param int $entry_id
856 - * @param object $form
857 - *
858 - * @return void
859 - */
860 681 private static function _delete_entry( $entry_id, $form ) {
861 682 if ( ! $form ) {
862 683 return;
863 684 }
@@ -862,10 +683,9 @@
862 683 return;
863 684 }
864 685
865 686 FrmAppHelper::unserialize_or_decode( $form->options );
866 -
867 - if ( ! empty( $form->options['no_save'] ) ) {
687 + if ( isset( $form->options['no_save'] ) && $form->options['no_save'] ) {
868 688 self::unlink_post( $entry_id );
869 689 FrmEntry::destroy( $entry_id );
870 690 }
871 691 }
@@ -871,12 +691,8 @@
871 691 }
872 692
873 693 /**
874 694 * Unlink entry from post
875 - *
876 - * @param int $entry_id
877 - *
878 - * @return void
879 695 */
880 696 private static function unlink_post( $entry_id ) {
881 697 global $wpdb;
882 698 $wpdb->update( $wpdb->prefix . 'frm_items', array( 'post_id' => '' ), array( 'id' => $entry_id ) );
@@ -912,9 +728,8 @@
912 728 'exclude_fields' => '',
913 729 'include_fields' => '',
914 730 'include_extras' => '',
915 731 'inline_style' => 1,
916 - 'table_style' => '',
917 732 // Return embedded fields as nested array.
918 733 'child_array' => false,
919 734 'line_breaks' => true,
920 735 'array_separator' => ', ',
@@ -919,32 +734,34 @@
919 734 'line_breaks' => true,
920 735 'array_separator' => ', ',
921 736 );
922 737 $defaults = apply_filters( 'frm_show_entry_defaults', $defaults );
923 - $atts = shortcode_atts( $defaults, $atts );
924 738
739 + $atts = shortcode_atts( $defaults, $atts );
740 +
925 741 if ( $atts['default_email'] ) {
926 - $shortcode_atts = array(
742 + $shortcode_atts = array(
927 743 'format' => $atts['format'],
928 744 'plain_text' => $atts['plain_text'],
929 745 );
746 +
930 747 $entry_formatter = FrmEntryFactory::entry_shortcode_formatter_instance( $atts['form_id'], $shortcode_atts );
931 - return $entry_formatter->content();
748 + $formatted_entry = $entry_formatter->content();
749 +
750 + } else {
751 +
752 + $entry_formatter = FrmEntryFactory::entry_formatter_instance( $atts );
753 + $formatted_entry = $entry_formatter->get_formatted_entry_values();
754 +
932 755 }
933 756
934 - $entry_formatter = FrmEntryFactory::entry_formatter_instance( $atts );
935 -
936 - return $entry_formatter->get_formatted_entry_values();
757 + return $formatted_entry;
937 758 }
938 759
939 - /**
940 - * @param false|object $entry
941 - *
942 - * @return void
943 - */
944 760 public static function entry_sidebar( $entry = false ) {
945 - $data = array();
946 - $id = 0;
761 + $data = array();
762 + $id = 0;
763 +
947 764 $date_format = get_option( 'date_format' );
948 765 $time_format = get_option( 'time_format' );
949 766
950 767 if ( $entry ) {
@@ -949,9 +766,8 @@
949 766
950 767 if ( $entry ) {
951 768 $id = $entry->id;
952 769 $data = $entry->description;
953 -
954 770 if ( isset( $data['browser'] ) ) {
955 771 $browser = FrmEntriesHelper::get_browser( $data['browser'] );
956 772 }
957 773 /**