PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22.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/FrmFormsController.php +22 -357 6.266.22.3 View file →
@@ -26,9 +26,8 @@
26 26 private static $formidable_tinymce_button;
27 27
28 28 public static function menu() {
29 29 $menu_label = __( 'Forms', 'formidable' );
30 -
31 30 if ( ! FrmAppHelper::pro_is_installed() ) {
32 31 $menu_label .= ' (Lite)';
33 32 }
34 33 add_submenu_page( 'formidable', 'Formidable | ' . $menu_label, $menu_label, 'frm_view_forms', 'formidable', 'FrmFormsController::route' );
@@ -68,9 +67,9 @@
68 67 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
69 68 $data_message .= ' <img src="' . esc_url( $images_url ) . '/survey-logic.png" srcset="' . esc_url( $images_url ) . 'survey-logic@2x.png 2x" alt="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '"/>';
70 69 echo '<a href="javascript:void(0)" class="frm_noallow frm_show_upgrade frm_add_logic_link frm-collapsed frm-flex-justify" data-upgrade="' . esc_attr__( 'Conditional Logic options', 'formidable' ) . '" data-message="' . esc_attr( $data_message ) . '" data-medium="builder" data-content="logic">';
71 70 esc_html_e( 'Conditional Logic', 'formidable' );
72 - FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown8_icon', array( 'aria-hidden' => 'true' ) );
71 + FrmAppHelper::icon_by_class( 'frmfont frm_arrowdown6_icon', array( 'aria-hidden' => 'true' ) );
73 72 echo '</a>';
74 73 }
75 74
76 75 /**
@@ -77,12 +76,8 @@
77 76 * By default, Divi processes form shortcodes on the edit post page.
78 77 * Now that won't do.
79 78 *
80 79 * @since 3.01
81 - *
82 - * @param array $shortcodes List of shortcodes to process.
83 - *
84 - * @return array
85 80 */
86 81 public static function prevent_divi_conflict( $shortcodes ) {
87 82 $shortcodes[] = 'formidable';
88 83
@@ -97,14 +92,12 @@
97 92
98 93 $message = '';
99 94 $params = FrmForm::list_page_params();
100 95 $errors = self::process_bulk_form_actions( array() );
101 -
102 96 if ( isset( $errors['message'] ) ) {
103 97 $message = $errors['message'];
104 98 unset( $errors['message'] );
105 99 }
106 -
107 100 $errors = apply_filters( 'frm_admin_list_form_action', $errors );
108 101
109 102 self::display_forms_list( $params, $message, $errors );
110 103 }
@@ -114,14 +107,12 @@
114 107 *
115 108 * @since 2.02.11
116 109 *
117 110 * @param int|object $form
118 - *
119 111 * @return void
120 112 */
121 113 private static function create_default_email_action( $form ) {
122 114 FrmForm::maybe_get_form( $form );
123 -
124 115 if ( ! is_object( $form ) ) {
125 116 return;
126 117 }
127 118
@@ -141,14 +132,12 @@
141 132 *
142 133 * @since 6.0.0
143 134 *
144 135 * @param int|object $form Form object or ID.
145 - *
146 136 * @return void
147 137 */
148 138 private static function create_default_on_submit_action( $form ) {
149 139 FrmForm::maybe_get_form( $form );
150 -
151 140 if ( ! is_object( $form ) ) {
152 141 return;
153 142 }
154 143
@@ -176,14 +165,12 @@
176 165 *
177 166 * @since 6.9
178 167 *
179 168 * @param int|object $form Form ID or object.
180 - *
181 169 * @return void
182 170 */
183 171 private static function create_submit_button_field( $form ) {
184 172 FrmForm::maybe_get_form( $form );
185 -
186 173 if ( ! is_object( $form ) ) {
187 174 return;
188 175 }
189 176
@@ -206,10 +193,8 @@
206 193 );
207 194 }
208 195
209 196 /**
210 - * @param array|false $values
211 - *
212 197 * @return void
213 198 */
214 199 public static function edit( $values = false ) {
215 200 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -221,9 +206,8 @@
221 206
222 207 /**
223 208 * @param mixed $id
224 209 * @param string $message
225 - *
226 210 * @return void
227 211 */
228 212 public static function settings( $id = false, $message = '' ) {
229 213 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -268,9 +252,8 @@
268 252
269 253 FrmForm::update( $id, $_POST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
270 254
271 255 $antispam_is_on = ! empty( $_POST['options']['antispam'] ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
272 -
273 256 if ( $antispam_is_on !== $antispam_was_on ) {
274 257 FrmAntiSpam::clear_caches();
275 258 }
276 259
@@ -280,9 +263,8 @@
280 263 }
281 264
282 265 /**
283 266 * @param int $form_id
284 - *
285 267 * @return bool
286 268 */
287 269 private static function antispam_was_on( $form_id ) {
288 270 $form = FrmForm::getOne( $form_id );
@@ -289,10 +271,8 @@
289 271 return ! empty( $form->options['antispam'] );
290 272 }
291 273
292 274 /**
293 - * @param array $values
294 - *
295 275 * @return void
296 276 */
297 277 public static function update( $values = array() ) {
298 278 if ( empty( $values ) ) {
@@ -305,9 +285,8 @@
305 285 }
306 286
307 287 $errors = FrmForm::validate( $values );
308 288 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce' );
309 -
310 289 if ( $permission_error !== false ) {
311 290 $errors['form'] = $permission_error;
312 291 }
313 292
@@ -326,9 +305,9 @@
326 305 if ( self::is_too_long( $values ) ) {
327 306 $message .= '<br/> ' . sprintf(
328 307 /* translators: %1$s: Start link HTML, %2$s: end link HTML */
329 308 __( 'However, your form is very long and may be %1$sreaching server limits%2$s.', 'formidable' ),
330 - '<a href="' . esc_url( self::get_form_too_long_docs_url() ) . '" target="_blank" rel="noopener">',
309 + '<a href="https://formidableforms.com/knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/?utm_source=WordPress&utm_medium=builder&utm_campaign=liteplugin" target="_blank" rel="noopener">',
331 310 '</a>'
332 311 );
333 312 }
334 313
@@ -339,32 +318,17 @@
339 318 self::get_edit_vars( $id, array(), $message );
340 319 }
341 320
342 321 /**
343 - * @since 6.25.1
344 - *
345 - * @return string
346 - */
347 - private static function get_form_too_long_docs_url() {
348 - $utm = array(
349 - 'campaign' => 'builder',
350 - 'content' => 'form-too-long',
351 - );
352 - return FrmAppHelper::admin_upgrade_link( $utm, 'knowledgebase/i-have-a-long-form-why-did-the-options-at-the-end-of-the-form-stop-saving/' );
353 - }
354 -
355 - /**
356 322 * Remove the draft flag from any new fields from this current session.
357 323 *
358 324 * @since 6.8
359 325 *
360 326 * @param int $form_id
361 - *
362 327 * @return void
363 328 */
364 329 private static function maybe_remove_draft_option_from_fields( $form_id ) {
365 330 $draft_field_ids_csv = FrmAppHelper::get_post_param( 'draft_fields', '', 'sanitize_text_field' );
366 -
367 331 if ( ! $draft_field_ids_csv ) {
368 332 // If the draft_fields input is empty there are no new fields in the session.
369 333 return;
370 334 }
@@ -369,9 +333,8 @@
369 333 return;
370 334 }
371 335
372 336 $draft_field_ids = array_filter( explode( ',', $draft_field_ids_csv ), 'is_numeric' );
373 -
374 337 if ( ! $draft_field_ids ) {
375 338 // Exit early if the draft fields input is invalid. It should be a CSV of integer values.
376 339 return;
377 340 }
@@ -376,9 +339,8 @@
376 339 return;
377 340 }
378 341
379 342 $draft_field_rows = FrmFieldsHelper::get_draft_field_results( $form_id, $draft_field_ids );
380 -
381 343 foreach ( $draft_field_rows as $row ) {
382 344 $row->field_options['draft'] = 0;
383 345 FrmField::update( $row->id, array( 'field_options' => $row->field_options ) );
384 346 }
@@ -390,10 +352,8 @@
390 352 * were likely not saved either.
391 353 *
392 354 * @since 3.06.01
393 355 *
394 - * @param array $values
395 - *
396 356 * @return bool
397 357 */
398 358 private static function is_too_long( $values ) {
399 359 return empty( $values['frm_end'] );
@@ -429,9 +389,8 @@
429 389 * @return string|null
430 390 */
431 391 public static function page_preview() {
432 392 $params = FrmForm::list_page_params();
433 -
434 393 if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
435 394 return null;
436 395 }
437 396
@@ -437,9 +396,8 @@
437 396
438 397 self::maybe_block_preview( $params['form'] );
439 398
440 399 $form = FrmForm::getOne( $params['form'] );
441 -
442 400 if ( ! $form ) {
443 401 return null;
444 402 }
445 403
@@ -452,9 +410,8 @@
452 410 * @return void
453 411 */
454 412 public static function show_page_preview() {
455 413 $preview = self::page_preview();
456 -
457 414 if ( is_null( $preview ) ) {
458 415 wp_die(
459 416 '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
460 417 '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
@@ -477,16 +434,9 @@
477 434
478 435 // print_emoji_styles is deprecated.
479 436 remove_action( 'wp_print_styles', 'print_emoji_styles' );
480 437
481 - if ( FrmTestModeController::should_add_test_mode_container() ) {
482 - do_action( 'frm_test_mode_init' );
483 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
484 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
485 - }
486 -
487 438 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
488 -
489 439 if ( $include_theme ) {
490 440 self::set_preview_query();
491 441 self::load_theme_preview();
492 442 } else {
@@ -509,9 +459,8 @@
509 459 'post_type' => 'page',
510 460 );
511 461
512 462 $page_for_posts = get_option( 'page_for_posts' );
513 -
514 463 if ( is_numeric( $page_for_posts ) ) {
515 464 // Avoid querying for the "Posts Page" or "Blog Page" so we don't display 10 forms.
516 465 $page_query['post__not_in'] = array( $page_for_posts );
517 466 }
@@ -516,15 +465,13 @@
516 465 $page_query['post__not_in'] = array( $page_for_posts );
517 466 }
518 467
519 468 $random_page = get_posts( $page_query );
520 -
521 469 if ( ! $random_page ) {
522 470 return;
523 471 }
524 472
525 473 $random_page = reset( $random_page );
526 -
527 474 if ( ! is_a( $random_page, 'WP_Post' ) ) {
528 475 // The return type can also be int.
529 476 return;
530 477 }
@@ -546,9 +493,8 @@
546 493 *
547 494 * @since 5.5.2
548 495 *
549 496 * @param WP_Post $page The page object.
550 - *
551 497 * @return void
552 498 */
553 499 private static function set_post_global( $page ) {
554 500 global $post;
@@ -581,9 +527,8 @@
581 527 *
582 528 * @since 6.5.2
583 529 *
584 530 * @param array $classes The body classes list.
585 - *
586 531 * @return array
587 532 */
588 533 public static function preview_block_theme_body_classnames( $classes ) {
589 534 $classes[] = 'has-global-padding';
@@ -620,11 +565,9 @@
620 565 * Calls core function to get a template part if it doesn't cause deprecation warnings. Otherwise skips the deprecation function call
621 566 * and renders required html fragments calling required functions.
622 567 *
623 568 * @since 6.7.1
624 - *
625 569 * @param string $template
626 - *
627 570 * @return void
628 571 */
629 572 private static function get_template( $template ) {
630 573 if ( self::should_try_getting_template( $template ) ) {
@@ -645,11 +588,9 @@
645 588 /**
646 589 * Returns true if calling a template function doesn't trigger deprecation warnings.
647 590 *
648 591 * @since 6.7.1
649 - *
650 592 * @param string $template
651 - *
652 593 * @return bool
653 594 */
654 595 private static function should_try_getting_template( $template ) {
655 596 $stylesheet_path = get_stylesheet_directory();
@@ -663,12 +604,8 @@
663 604 /**
664 605 * Set the page title for the theme preview page
665 606 *
666 607 * @since 3.0
667 - *
668 - * @param string $title
669 - *
670 - * @return string
671 608 */
672 609 public static function preview_page_title( $title ) {
673 610 if ( in_the_loop() ) {
674 611 $title = self::preview_title( $title );
@@ -682,9 +619,8 @@
682 619 *
683 620 * @since 3.0
684 621 *
685 622 * @param string $title
686 - *
687 623 * @return string
688 624 */
689 625 public static function preview_title( $title ) {
690 626 return __( 'Form Preview', 'formidable' );
@@ -695,9 +631,8 @@
695 631 *
696 632 * @since 3.0
697 633 *
698 634 * @param string $content
699 - *
700 635 * @return string
701 636 */
702 637 public static function preview_content( $content ) {
703 638 if ( in_the_loop() ) {
@@ -713,9 +648,8 @@
713 648 * @since 3.0
714 649 */
715 650 private static function load_direct_preview() {
716 651 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
717 -
718 652 if ( $key == '' ) {
719 653 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
720 654 }
721 655
@@ -730,9 +664,8 @@
730 664
731 665 self::maybe_block_preview( $key );
732 666
733 667 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
734 -
735 668 if ( ! $form ) {
736 669 $error = __( 'Form does not exist', 'formidable' );
737 670 wp_die(
738 671 '<h1>' . esc_html( $error ) . '</h1>',
@@ -756,9 +689,8 @@
756 689 *
757 690 * @since 6.20
758 691 *
759 692 * @param string $form_key Form key.
760 - *
761 693 * @return void
762 694 */
763 695 public static function maybe_block_preview( $form_key ) {
764 696 if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
@@ -784,9 +716,8 @@
784 716 add_filter(
785 717 'script_loader_src',
786 718 /**
787 719 * @param string|null $src
788 - *
789 720 * @return string
790 721 */
791 722 function ( $src ) {
792 723 if ( is_null( $src ) ) {
@@ -802,9 +733,8 @@
802 733 }
803 734
804 735 /**
805 736 * @param array $ids
806 - *
807 737 * @return string
808 738 */
809 739 public static function bulk_untrash( $ids ) {
810 740 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -865,9 +795,8 @@
865 795 // Check nonce url.
866 796 check_admin_referer( $status . '_form_' . $params['id'] );
867 797
868 798 $count = 0;
869 -
870 799 if ( FrmForm::set_status( $params['id'], $available_status[ $status ]['new_status'] ) ) {
871 800 ++$count;
872 801 }
873 802
@@ -890,9 +819,8 @@
890 819 }
891 820
892 821 /**
893 822 * @param array $ids
894 - *
895 823 * @return string
896 824 */
897 825 public static function bulk_trash( $ids ) {
898 826 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -897,9 +825,8 @@
897 825 public static function bulk_trash( $ids ) {
898 826 FrmAppHelper::permission_check( 'frm_delete_forms' );
899 827
900 828 $count = 0;
901 -
902 829 foreach ( $ids as $id ) {
903 830 if ( FrmForm::trash( $id ) ) {
904 831 ++$count;
905 832 }
@@ -934,9 +861,8 @@
934 861 // Check nonce url.
935 862 check_admin_referer( 'destroy_form_' . $params['id'] );
936 863
937 864 $count = 0;
938 -
939 865 if ( FrmForm::destroy( $params['id'] ) ) {
940 866 ++$count;
941 867 }
942 868
@@ -947,9 +873,8 @@
947 873 }
948 874
949 875 /**
950 876 * @param array $ids
951 - *
952 877 * @return string
953 878 */
954 879 public static function bulk_destroy( $ids ) {
955 880 FrmAppHelper::permission_check( 'frm_delete_forms' );
@@ -954,12 +879,10 @@
954 879 public static function bulk_destroy( $ids ) {
955 880 FrmAppHelper::permission_check( 'frm_delete_forms' );
956 881
957 882 $count = 0;
958 -
959 883 foreach ( $ids as $id ) {
960 884 $d = FrmForm::destroy( $id );
961 -
962 885 if ( $d ) {
963 886 ++$count;
964 887 }
965 888 }
@@ -977,9 +900,8 @@
977 900 */
978 901 public static function delete_all() {
979 902 // Check nonce url.
980 903 $permission_error = FrmAppHelper::permission_nonce_error( 'frm_delete_forms', '_wpnonce', 'bulk-toplevel_page_formidable' );
981 -
982 904 if ( $permission_error !== false ) {
983 905 self::display_forms_list( array(), '', array( $permission_error ) );
984 906
985 907 return;
@@ -1121,9 +1043,8 @@
1121 1043 private static function should_insert_form_popup() {
1122 1044 if ( FrmAppHelper::is_form_builder_page() ) {
1123 1045 return true;
1124 1046 }
1125 -
1126 1047 $page = basename( FrmAppHelper::get_server_value( 'PHP_SELF' ) );
1127 1048 return in_array( $page, array( 'post.php', 'page.php', 'page-new.php', 'post-new.php' ), true );
1128 1049 }
1129 1050
@@ -1131,9 +1052,8 @@
1131 1052 FrmAppHelper::permission_check( 'frm_view_forms' );
1132 1053 check_ajax_referer( 'frm_ajax', 'nonce' );
1133 1054
1134 1055 $shortcode = FrmAppHelper::get_post_param( 'shortcode', '', 'sanitize_text_field' );
1135 -
1136 1056 if ( empty( $shortcode ) ) {
1137 1057 wp_die();
1138 1058 }
1139 1059
@@ -1159,9 +1079,8 @@
1159 1079 'label' => __( 'Minimize form HTML', 'formidable' ),
1160 1080 ),
1161 1081 );
1162 1082 }
1163 -
1164 1083 $opts = apply_filters( 'frm_sc_popup_opts', $opts, $shortcode );
1165 1084
1166 1085 if ( isset( $opts['form_id'] ) && is_string( $opts['form_id'] ) ) {
1167 1086 // allow other shortcodes to use the required form id option
@@ -1181,9 +1100,8 @@
1181 1100 *
1182 1101 * @param array $params
1183 1102 * @param string $message
1184 1103 * @param array $errors
1185 - *
1186 1104 * @return void
1187 1105 */
1188 1106 public static function display_forms_list( $params = array(), $message = '', $errors = array() ) {
1189 1107 FrmAppHelper::permission_check( 'frm_view_forms' );
@@ -1206,9 +1124,8 @@
1206 1124
1207 1125 $wp_list_table->prepare_items();
1208 1126
1209 1127 $total_pages = $wp_list_table->get_pagination_arg( 'total_pages' );
1210 -
1211 1128 if ( $pagenum > $total_pages && $total_pages > 0 ) {
1212 1129 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1213 1130 die();
1214 1131 }
@@ -1214,9 +1131,8 @@
1214 1131 }
1215 1132
1216 1133 $inbox = new FrmInbox();
1217 1134 $error = $inbox->check_for_error();
1218 -
1219 1135 if ( $error ) {
1220 1136 $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1221 1137 }
1222 1138
@@ -1224,9 +1140,8 @@
1224 1140 }
1225 1141
1226 1142 /**
1227 1143 * @param array<string,string> $columns
1228 - *
1229 1144 * @return array<string,string>
1230 1145 */
1231 1146 public static function get_columns( $columns ) {
1232 1147 $columns['cb'] = '<input type="checkbox" />';
@@ -1233,9 +1148,8 @@
1233 1148 $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1234 1149 $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1235 1150 $columns['id'] = 'ID';
1236 1151 $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1237 -
1238 1152 if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1239 1153 $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1240 1154 }
1241 1155 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
@@ -1266,9 +1180,8 @@
1266 1180 }
1267 1181
1268 1182 /**
1269 1183 * @param mixed $hidden_columns
1270 - *
1271 1184 * @return array
1272 1185 */
1273 1186 public static function hidden_columns( $hidden_columns ) {
1274 1187 if ( ! is_array( $hidden_columns ) ) {
@@ -1289,15 +1202,8 @@
1289 1202
1290 1203 return $hidden_columns;
1291 1204 }
1292 1205
1293 - /**
1294 - * @param mixed $save
1295 - * @param string $option
1296 - * @param int|string $value
1297 - *
1298 - * @return mixed
1299 - */
1300 1206 public static function save_per_page( $save, $option, $value ) {
1301 1207 if ( $option === 'formidable_page_formidable_per_page' ) {
1302 1208 $save = (int) $value;
1303 1209 }
@@ -1309,9 +1215,8 @@
1309 1215 * @param int|string $id
1310 1216 * @param array $errors
1311 1217 * @param string $message
1312 1218 * @param bool $create_link
1313 - *
1314 1219 * @return void
1315 1220 */
1316 1221 private static function get_edit_vars( $id, $errors = array(), $message = '', $create_link = false ) {
1317 1222 global $frm_vars;
@@ -1326,9 +1231,8 @@
1326 1231 'page' => 'formidable',
1327 1232 )
1328 1233 ),
1329 1234 );
1330 -
1331 1235 if ( ! $form ) {
1332 1236 FrmAppController::show_error_modal( $error_args );
1333 1237 return;
1334 1238 }
@@ -1382,9 +1286,8 @@
1382 1286 */
1383 1287 $values['fields'] = apply_filters( 'frm_fields_in_form_builder', $fields, compact( 'form' ) );
1384 1288
1385 1289 $edit_message = __( 'Form was successfully updated.', 'formidable' );
1386 -
1387 1290 if ( $form->is_template && $message == $edit_message ) {
1388 1291 $message = __( 'Template was successfully updated.', 'formidable' );
1389 1292 }
1390 1293
@@ -1400,12 +1303,11 @@
1400 1303 }
1401 1304
1402 1305 /**
1403 1306 * @param array $fields
1404 - *
1405 1307 * @return array
1406 1308 */
1407 - public static function update_form_builder_fields( $fields ) {
1309 + public static function update_form_builder_fields( $fields, $form ) {
1408 1310 foreach ( $fields as $field ) {
1409 1311 $field->do_not_include_icons = true;
1410 1312 }
1411 1313 return $fields;
@@ -1410,13 +1312,8 @@
1410 1312 }
1411 1313 return $fields;
1412 1314 }
1413 1315
1414 - /**
1415 - * @param string $message
1416 - *
1417 - * @return void
1418 - */
1419 1316 public static function maybe_update_form_builder_message( &$message ) {
1420 1317 if ( 'form_duplicated' === FrmAppHelper::simple_get( 'message' ) ) {
1421 1318 $message = __( 'Form was Successfully Copied', 'formidable' );
1422 1319 }
@@ -1425,9 +1322,8 @@
1425 1322 /**
1426 1323 * @param int|string $id
1427 1324 * @param array $errors
1428 1325 * @param array|string $args
1429 - *
1430 1326 * @return void
1431 1327 */
1432 1328 public static function get_settings_vars( $id, $errors = array(), $args = array() ) {
1433 1329 FrmAppHelper::permission_check( 'frm_edit_forms' );
@@ -1495,12 +1391,8 @@
1495 1391 }
1496 1392
1497 1393 /**
1498 1394 * @since 4.0
1499 - *
1500 - * @param array $atts
1501 - *
1502 - * @return void
1503 1395 */
1504 1396 public static function form_publish_button( $atts ) {
1505 1397 $values = $atts['values'];
1506 1398 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/_publish_box.php';
@@ -1511,9 +1403,8 @@
1511 1403 *
1512 1404 * @since 4.0
1513 1405 *
1514 1406 * @param array $values
1515 - *
1516 1407 * @return array
1517 1408 */
1518 1409 private static function get_settings_tabs( $values ) {
1519 1410 $sections = array(
@@ -1519,9 +1410,9 @@
1519 1410 $sections = array(
1520 1411 'advanced' => array(
1521 1412 'name' => __( 'General', 'formidable' ),
1522 1413 'title' => __( 'General Form Settings', 'formidable' ),
1523 - 'function' => array( self::class, 'advanced_settings' ),
1414 + 'function' => array( __CLASS__, 'advanced_settings' ),
1524 1415 'icon' => 'frm_icon_font frm_settings_icon',
1525 1416 ),
1526 1417 'email' => array(
1527 1418 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1537,9 +1428,8 @@
1537 1428 'medium' => 'permissions',
1538 1429 'upgrade' => __( 'Form Permissions', 'formidable' ),
1539 1430 'message' => __( 'Allow editing, protect forms and files, limit entries, and save drafts. Upgrade to get form and entry permissions.', 'formidable' ),
1540 1431 'screenshot' => 'permissions.png',
1541 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-permissions', 'form-permissions-settings' ),
1542 1432 ),
1543 1433 ),
1544 1434 'scheduling' => array(
1545 1435 'name' => __( 'Form Scheduling', 'formidable' ),
@@ -1548,14 +1438,13 @@
1548 1438 'data' => array(
1549 1439 'medium' => 'scheduling',
1550 1440 'upgrade' => __( 'Form scheduling settings', 'formidable' ),
1551 1441 'screenshot' => 'scheduling.png',
1552 - 'learn-more' => FrmAppHelper::get_doc_url( 'general-form-settings/#kb-form-scheduling', 'form-scheduling-settings' ),
1553 1442 ),
1554 1443 ),
1555 1444 'buttons' => array(
1556 1445 'name' => __( 'Buttons', 'formidable' ),
1557 - 'class' => self::class,
1446 + 'class' => __CLASS__,
1558 1447 'function' => 'buttons_settings',
1559 1448 'icon' => 'frm_icon_font frm_button_icon',
1560 1449 ),
1561 1450 'landing' => array(
@@ -1573,9 +1462,8 @@
1573 1462 array(
1574 1463 'upgrade' => __( 'Conversational Forms', 'formidable' ),
1575 1464 'message' => __( 'Ask one question at a time for automated conversations.', 'formidable' ),
1576 1465 'screenshot' => 'chat.png',
1577 - 'learn-more' => FrmAppHelper::get_doc_url( 'conversational-forms', 'conversational-forms-settings', false ),
1578 1466 )
1579 1467 ),
1580 1468 ),
1581 1469 'abandonment' => array(
@@ -1587,15 +1475,14 @@
1587 1475 array(
1588 1476 'upgrade' => __( 'Form abandonment settings', 'formidable' ),
1589 1477 'message' => __( 'Unlock the power of data capture to boost lead generation and master the art of form optimization.', 'formidable' ),
1590 1478 'screenshot' => 'abandonment.png',
1591 - 'learn-more' => FrmAppHelper::get_doc_url( 'features/form-abandonment-wordpress-plugin', 'form-abandonment-settings', false ),
1592 1479 )
1593 1480 ),
1594 1481 ),
1595 1482 'html' => array(
1596 1483 'name' => __( 'Customize HTML', 'formidable' ),
1597 - 'class' => self::class,
1484 + 'class' => __CLASS__,
1598 1485 'function' => 'html_settings',
1599 1486 'icon' => 'frm_icon_font frm_code_icon',
1600 1487 ),
1601 1488 );
@@ -1603,8 +1490,14 @@
1603 1490 if ( ! has_action( 'frm_add_form_style_tab_options' ) && ! has_action( 'frm_add_form_button_options' ) ) {
1604 1491 unset( $sections['buttons'] );
1605 1492 }
1606 1493
1494 + foreach ( array( 'landing', 'chat', 'abandonment' ) as $feature ) {
1495 + if ( ! FrmAppHelper::show_new_feature( $feature ) ) {
1496 + unset( $sections[ $feature ] );
1497 + }
1498 + }
1499 +
1607 1500 $sections = apply_filters( 'frm_add_form_settings_section', $sections, $values );
1608 1501
1609 1502 foreach ( $sections as $key => $section ) {
1610 1503 $defaults = array(
@@ -1637,9 +1530,8 @@
1637 1530 /**
1638 1531 * @since 4.0
1639 1532 *
1640 1533 * @param array $values
1641 - *
1642 1534 * @return void
1643 1535 */
1644 1536 public static function advanced_settings( $values ) {
1645 1537 $first_h3 = 'frm_first_h3';
@@ -1648,9 +1540,8 @@
1648 1540 }
1649 1541
1650 1542 /**
1651 1543 * @param array $values
1652 - *
1653 1544 * @return void
1654 1545 */
1655 1546 public static function render_spam_settings( $values ) {
1656 1547 if ( function_exists( 'akismet_http_post' ) ) {
@@ -1663,9 +1554,8 @@
1663 1554 /**
1664 1555 * @since 4.0
1665 1556 *
1666 1557 * @param array $values
1667 - *
1668 1558 * @return void
1669 1559 */
1670 1560 public static function buttons_settings( $values ) {
1671 1561 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-buttons.php';
@@ -1674,9 +1564,8 @@
1674 1564 /**
1675 1565 * @since 4.0
1676 1566 *
1677 1567 * @param array $values
1678 - *
1679 1568 * @return void
1680 1569 */
1681 1570 public static function html_settings( $values ) {
1682 1571 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/settings-html.php';
@@ -1687,9 +1576,8 @@
1687 1576 *
1688 1577 * @since 2.03.08
1689 1578 *
1690 1579 * @param array|bool $values
1691 - *
1692 1580 * @return void
1693 1581 */
1694 1582 private static function clean_submit_html( &$values ) {
1695 1583 if ( is_array( $values ) && isset( $values['submit_html'] ) ) {
@@ -1714,9 +1602,8 @@
1714 1602
1715 1603 /**
1716 1604 * @param int|string $form_id
1717 1605 * @param string $class
1718 - *
1719 1606 * @return void
1720 1607 */
1721 1608 public static function mb_tags_box( $form_id, $class = '' ) {
1722 1609 $fields = FrmField::get_all_for_form( $form_id, '', 'include' );
@@ -1743,12 +1630,8 @@
1743 1630 }
1744 1631
1745 1632 /**
1746 1633 * @since 3.04.01
1747 - *
1748 - * @param array $atts
1749 - *
1750 - * @return array
1751 1634 */
1752 1635 private static function advanced_helpers( $atts ) {
1753 1636 $advanced_helpers = array(
1754 1637 'default' => array(
@@ -1757,12 +1640,10 @@
1757 1640 ),
1758 1641 );
1759 1642
1760 1643 $user_fields = self::user_shortcodes();
1761 -
1762 1644 if ( $user_fields ) {
1763 1645 $user_helpers = array();
1764 -
1765 1646 foreach ( $user_fields as $uk => $uf ) {
1766 1647 $user_helpers[ '|user_id| show="' . $uk . '"' ] = $uf;
1767 1648 unset( $uk, $uf );
1768 1649 }
@@ -1787,10 +1668,8 @@
1787 1668 * Get an array of the options to display in the advanced tab
1788 1669 * of the customization panel
1789 1670 *
1790 1671 * @since 2.0.6
1791 - *
1792 - * @return array
1793 1672 */
1794 1673 private static function get_advanced_shortcodes() {
1795 1674 $adv_shortcodes = array(
1796 1675 'x sep=", "' => array(
@@ -1816,10 +1695,8 @@
1816 1695 }
1817 1696
1818 1697 /**
1819 1698 * @since 3.04.01
1820 - *
1821 - * @return array
1822 1699 */
1823 1700 private static function user_shortcodes() {
1824 1701 $options = array(
1825 1702 'ID' => __( 'User ID', 'formidable' ),
@@ -1838,12 +1715,8 @@
1838 1715 /**
1839 1716 * Get an array of the helper shortcodes to display in the customization panel
1840 1717 *
1841 1718 * @since 2.0.6
1842 - *
1843 - * @param bool $settings_tab
1844 - *
1845 - * @return array
1846 1719 */
1847 1720 private static function get_shortcode_helpers( $settings_tab ) {
1848 1721 $entry_shortcodes = array(
1849 1722 'id' => __( 'Entry ID', 'formidable' ),
@@ -1858,9 +1731,8 @@
1858 1731 'form_name' => __( 'Form Name', 'formidable' ),
1859 1732 );
1860 1733
1861 1734 $entry_shortcodes = array_merge( FrmShortcodeHelper::get_contextual_shortcode_values(), $entry_shortcodes );
1862 -
1863 1735 if ( ! FrmAppHelper::pro_is_installed() ) {
1864 1736 unset( $entry_shortcodes['post_id'] );
1865 1737 }
1866 1738
@@ -1868,11 +1740,8 @@
1868 1740 * Use this hook to add or remove buttons in the helpers section
1869 1741 * in the customization panel
1870 1742 *
1871 1743 * @since 2.0.6
1872 - *
1873 - * @param array $entry_shortcodes
1874 - * @param bool $settings_tab
1875 1744 */
1876 1745 $entry_shortcodes = apply_filters( 'frm_helper_shortcodes', $entry_shortcodes, $settings_tab );
1877 1746
1878 1747 return $entry_shortcodes;
@@ -1881,9 +1750,8 @@
1881 1750 /**
1882 1751 * Insert the form class setting into the form.
1883 1752 *
1884 1753 * @param stdClass $form
1885 - *
1886 1754 * @return void
1887 1755 */
1888 1756 public static function form_classes( $form ) {
1889 1757 if ( isset( $form->options['form_class'] ) ) {
@@ -1906,9 +1774,8 @@
1906 1774 * @param stdClass $form
1907 1775 */
1908 1776 public static function add_js_validate_form_to_global_vars( $form ) {
1909 1777 global $frm_vars;
1910 -
1911 1778 if ( ! isset( $frm_vars['js_validate_forms'] ) ) {
1912 1779 $frm_vars['js_validate_forms'] = array();
1913 1780 }
1914 1781 $frm_vars['js_validate_forms'][ $form->id ] = $form;
@@ -1931,9 +1798,8 @@
1931 1798 /**
1932 1799 * @param string $content
1933 1800 * @param int|stdClass|string $form
1934 1801 * @param false|int|stdClass|string $entry
1935 - *
1936 1802 * @return string
1937 1803 */
1938 1804 public static function filter_content( $content, $form, $entry = false ) {
1939 1805 $content = self::replace_form_name_shortcodes( $content, $form );
@@ -1938,9 +1804,8 @@
1938 1804 public static function filter_content( $content, $form, $entry = false ) {
1939 1805 $content = self::replace_form_name_shortcodes( $content, $form );
1940 1806
1941 1807 self::get_entry_by_param( $entry );
1942 -
1943 1808 if ( ! $entry ) {
1944 1809 return $content;
1945 1810 }
1946 1811
@@ -1968,9 +1833,8 @@
1968 1833 * @since 5.5
1969 1834 *
1970 1835 * @param array|string $string
1971 1836 * @param int|stdClass|string $form
1972 - *
1973 1837 * @return array|string
1974 1838 */
1975 1839 public static function replace_form_name_shortcodes( $string, $form ) {
1976 1840 if ( ! is_string( $string ) ) {
@@ -1990,9 +1854,8 @@
1990 1854 }
1991 1855
1992 1856 /**
1993 1857 * @param false|int|stdClass|string $entry
1994 - *
1995 1858 * @return void
1996 1859 */
1997 1860 private static function get_entry_by_param( &$entry ) {
1998 1861 if ( ! $entry || ! is_object( $entry ) ) {
@@ -2003,15 +1866,8 @@
2003 1866 FrmEntry::maybe_get_entry( $entry );
2004 1867 }
2005 1868 }
2006 1869
2007 - /**
2008 - * @param string $content
2009 - * @param false|object $entry
2010 - * @param array $shortcodes
2011 - *
2012 - * @return string
2013 - */
2014 1870 public static function replace_content_shortcodes( $content, $entry, $shortcodes ) {
2015 1871 return FrmFieldsHelper::replace_content_shortcodes( $content, $entry, $shortcodes );
2016 1872 }
2017 1873
@@ -2016,9 +1872,8 @@
2016 1872 }
2017 1873
2018 1874 /**
2019 1875 * @param array $errors
2020 - *
2021 1876 * @return array
2022 1877 */
2023 1878 public static function process_bulk_form_actions( $errors ) {
2024 1879 if ( ! $_REQUEST ) {
@@ -2025,9 +1880,8 @@
2025 1880 return $errors;
2026 1881 }
2027 1882
2028 1883 $bulkaction = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2029 -
2030 1884 if ( $bulkaction == - 1 ) {
2031 1885 $bulkaction = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2032 1886 }
2033 1887
@@ -2037,9 +1891,8 @@
2037 1891 $bulkaction = str_replace( 'bulk_', '', $bulkaction );
2038 1892 }
2039 1893
2040 1894 $ids = FrmAppHelper::get_param( 'item-action', '', 'get', 'sanitize_text_field' );
2041 -
2042 1895 if ( empty( $ids ) ) {
2043 1896 $errors[] = __( 'No forms were specified', 'formidable' );
2044 1897
2045 1898 return $errors;
@@ -2045,9 +1898,8 @@
2045 1898 return $errors;
2046 1899 }
2047 1900
2048 1901 $permission_error = FrmAppHelper::permission_nonce_error( '', '_wpnonce', 'bulk-toplevel_page_formidable' );
2049 -
2050 1902 if ( $permission_error !== false ) {
2051 1903 $errors[] = $permission_error;
2052 1904
2053 1905 return $errors;
@@ -2078,9 +1930,8 @@
2078 1930 /**
2079 1931 * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
2080 1932 *
2081 1933 * @since 6.20
2082 - *
2083 1934 * @return void
2084 1935 */
2085 1936 public static function include_device_too_small_message() {
2086 1937 if ( ! FrmAppHelper::is_formidable_admin() ) {
@@ -2093,9 +1944,8 @@
2093 1944 public static function route() {
2094 1945 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
2095 1946 $vars = array();
2096 1947 FrmAppHelper::include_svg();
2097 -
2098 1948 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
2099 1949 FrmAppHelper::permission_check( 'frm_edit_forms' );
2100 1950
2101 1951 // Javascript needs to be allowed in some field settings.
@@ -2101,13 +1951,11 @@
2101 1951 // Javascript needs to be allowed in some field settings.
2102 1952 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
2103 1953 $json_vars = htmlspecialchars_decode( nl2br( str_replace( '&quot;', '"', wp_unslash( $_POST['frm_compact_fields'] ) ) ) );
2104 1954 $json_vars = json_decode( $json_vars, true );
2105 -
2106 1955 if ( empty( $json_vars ) ) {
2107 1956 // json decoding failed so we should return an error message.
2108 1957 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2109 -
2110 1958 if ( 'edit' === $action ) {
2111 1959 $action = 'update';
2112 1960 }
2113 1961
@@ -2120,9 +1968,8 @@
2120 1968 $_POST = array_merge( $_POST, $_REQUEST ); // phpcs:ignore WordPress.Security.NonceVerification.Missing
2121 1969 }
2122 1970 } else {
2123 1971 $action = FrmAppHelper::get_param( $action, '', 'get', 'sanitize_title' );
2124 -
2125 1972 if ( isset( $_REQUEST['delete_all'] ) ) {
2126 1973 // Override the action for this page.
2127 1974 $action = 'delete_all';
2128 1975 }
@@ -2148,15 +1995,13 @@
2148 1995 self::no_views( $vars );
2149 1996 return;
2150 1997 default:
2151 1998 do_action( 'frm_form_action_' . $action );
2152 -
2153 1999 if ( apply_filters( 'frm_form_stop_action_' . $action, false ) ) {
2154 2000 return;
2155 2001 }
2156 2002
2157 2003 $action = FrmAppHelper::get_param( 'action', '', 'get', 'sanitize_text_field' );
2158 -
2159 2004 if ( $action == - 1 ) {
2160 2005 $action = FrmAppHelper::get_param( 'action2', '', 'get', 'sanitize_title' );
2161 2006 }
2162 2007
@@ -2167,9 +2012,8 @@
2167 2012 return;
2168 2013 }
2169 2014
2170 2015 $message = FrmAppHelper::get_param( 'message' );
2171 -
2172 2016 if ( 'form_duplicate_error' === $message ) {
2173 2017 self::display_forms_list( array(), '', array( __( 'There was a problem duplicating the form', 'formidable' ) ) );
2174 2018 return;
2175 2019 }
@@ -2205,41 +2049,15 @@
2205 2049 // Get posted data
2206 2050 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2207 2051 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2208 2052
2209 - $form = FrmForm::getOne( $form_id );
2053 + // Update the form name and form key.
2054 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2055 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2210 2056
2211 - if ( ! $form ) {
2212 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2213 - }
2214 -
2215 - if ( $name === $form->name ) {
2216 - // Nothing to change so exit early.
2217 - wp_send_json_success();
2218 - }
2219 -
2220 - $to_update = array(
2221 - 'name' => $name,
2222 - );
2223 -
2224 - if ( '' !== $name ) {
2225 - // Only update form_key if name is not empty.
2226 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2227 - $to_update['form_key'] = $form_key;
2228 - } else {
2229 - $form_key = $form->form_key;
2230 - }
2231 -
2232 - FrmForm::update( $form_id, $to_update );
2233 -
2234 2057 wp_send_json_success( compact( 'form_key' ) );
2235 2058 }
2236 2059
2237 - /**
2238 - * @param array $errors
2239 - *
2240 - * @return array
2241 - */
2242 2060 public static function json_error( $errors ) {
2243 2061 $errors['json'] = __( 'Abnormal HTML characters prevented your form from saving correctly', 'formidable' );
2244 2062
2245 2063 return $errors;
@@ -2249,10 +2067,8 @@
2249 2067 * Add education about views.
2250 2068 *
2251 2069 * @since 4.07
2252 2070 *
2253 - * @param array $values
2254 - *
2255 2071 * @return void
2256 2072 */
2257 2073 public static function no_views( $values = array() ) {
2258 2074 FrmAppHelper::include_svg();
@@ -2266,10 +2082,8 @@
2266 2082 * Add education about reports.
2267 2083 *
2268 2084 * @since 4.07
2269 2085 *
2270 - * @param array $values
2271 - *
2272 2086 * @return void
2273 2087 */
2274 2088 public static function no_reports( $values = array() ) {
2275 2089 $id = FrmAppHelper::get_param( 'form', '', 'get', 'absint' );
@@ -2296,9 +2110,8 @@
2296 2110 * @since 4.05.02
2297 2111 */
2298 2112 private static function move_menu_to_footer() {
2299 2113 $settings = FrmAppHelper::get_settings();
2300 -
2301 2114 if ( empty( $settings->admin_bar ) ) {
2302 2115 remove_action( 'wp_body_open', 'wp_admin_bar_render', 0 );
2303 2116 }
2304 2117 }
@@ -2304,15 +2117,13 @@
2304 2117 }
2305 2118
2306 2119 public static function admin_bar_configure() {
2307 2120 global $frm_vars;
2308 -
2309 2121 if ( empty( $frm_vars['forms_loaded'] ) ) {
2310 2122 return;
2311 2123 }
2312 2124
2313 2125 $actions = array();
2314 -
2315 2126 foreach ( $frm_vars['forms_loaded'] as $form ) {
2316 2127 if ( is_object( $form ) ) {
2317 2128 $actions[ $form->id ] = $form->name;
2318 2129 }
@@ -2346,12 +2157,8 @@
2346 2157 }
2347 2158
2348 2159 /**
2349 2160 * @since 2.05.07
2350 - *
2351 - * @param array $actions
2352 - *
2353 - * @return void
2354 2161 */
2355 2162 private static function add_forms_to_admin_bar( $actions ) {
2356 2163 global $wp_admin_bar;
2357 2164
@@ -2373,14 +2180,12 @@
2373 2180 /**
2374 2181 * The formidable shortcode
2375 2182 *
2376 2183 * @param array $atts The params from the shortcode.
2377 - *
2378 2184 * @return string
2379 2185 */
2380 2186 public static function get_form_shortcode( $atts ) {
2381 2187 global $frm_vars;
2382 -
2383 2188 if ( ! empty( $frm_vars['skip_shortcode'] ) ) {
2384 2189 $sc = '[formidable';
2385 2190 $sc .= FrmAppHelper::array_to_html_params( $atts );
2386 2191 return $sc . ']';
@@ -2409,9 +2214,8 @@
2409 2214 * @since 5.2.01
2410 2215 *
2411 2216 * @param false|int|string $id
2412 2217 * @param false|string $key
2413 - *
2414 2218 * @return false|stdClass
2415 2219 */
2416 2220 private static function maybe_get_form_by_id_or_key( $id, $key ) {
2417 2221 if ( ! $id ) {
@@ -2425,9 +2229,8 @@
2425 2229 * @param false|string $key
2426 2230 * @param bool|int|string $title may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2427 2231 * @param bool|int|string $description may be 'auto', true, false, 'true', 'false', 'yes', '1', 1, '0', 0.
2428 2232 * @param array $atts
2429 - *
2430 2233 * @return string
2431 2234 */
2432 2235 public static function show_form( $id = '', $key = '', $title = false, $description = false, $atts = array() ) {
2433 2236 $form = self::maybe_get_form_by_id_or_key( $id, $key );
@@ -2475,9 +2278,8 @@
2475 2278 }
2476 2279
2477 2280 /**
2478 2281 * @param false|int|string $id
2479 - *
2480 2282 * @return false|stdClass
2481 2283 */
2482 2284 private static function maybe_get_form_to_show( $id ) {
2483 2285 $form = false;
@@ -2484,9 +2286,8 @@
2484 2286
2485 2287 if ( ! empty( $id ) ) {
2486 2288 // Form id or key is set.
2487 2289 $form = FrmForm::getOne( $id );
2488 -
2489 2290 if ( ! $form || $form->parent_form_id || $form->status === 'trash' ) {
2490 2291 $form = false;
2491 2292 }
2492 2293 }
@@ -2493,25 +2294,12 @@
2493 2294
2494 2295 return $form;
2495 2296 }
2496 2297
2497 - /**
2498 - * @param object $form
2499 - *
2500 - * @return bool
2501 - */
2502 2298 private static function is_viewable_draft_form( $form ) {
2503 2299 return $form->status === 'draft' && current_user_can( 'frm_edit_forms' ) && ! FrmAppHelper::is_preview_page();
2504 2300 }
2505 2301
2506 - /**
2507 - * @param object $form
2508 - * @param bool $title
2509 - * @param bool $description
2510 - * @param array $atts
2511 - *
2512 - * @return string
2513 - */
2514 2302 public static function get_form( $form, $title, $description, $atts = array() ) {
2515 2303 ob_start();
2516 2304
2517 2305 do_action( 'frm_before_get_form', $atts );
@@ -2526,25 +2314,12 @@
2526 2314
2527 2315 return $contents;
2528 2316 }
2529 2317
2530 - /**
2531 - * @param array $params
2532 - *
2533 - * @return void
2534 - */
2535 2318 public static function enqueue_scripts( $params ) {
2536 2319 do_action( 'frm_enqueue_form_scripts', $params );
2537 2320 }
2538 2321
2539 - /**
2540 - * @param object $form
2541 - * @param bool $title
2542 - * @param bool $description
2543 - * @param array $atts
2544 - *
2545 - * @return void
2546 - */
2547 2322 public static function get_form_contents( $form, $title, $description, $atts ) {
2548 2323 $params = FrmForm::get_params( $form );
2549 2324 $errors = self::get_saved_errors( $form, $params );
2550 2325 $fields = FrmFieldsHelper::get_form_fields( $form->id, $errors );
@@ -2558,9 +2333,8 @@
2558 2333 FrmFormState::set_initial_value( 'title', $title );
2559 2334 FrmFormState::set_initial_value( 'description', $description );
2560 2335
2561 2336 do_action( 'frm_display_form_action', $params, $fields, $form, $title, $description );
2562 -
2563 2337 if ( apply_filters( 'frm_continue_to_new', true, $form->id, $params['action'] ) ) {
2564 2338 self::show_form_after_submit( $pass_args );
2565 2339 }
2566 2340 } elseif ( ! empty( $errors ) ) {
@@ -2591,13 +2365,8 @@
2591 2365 /**
2592 2366 * If the form was processed earlier (init), get the generated errors
2593 2367 *
2594 2368 * @since 2.05
2595 - *
2596 - * @param object $form
2597 - * @param array $params
2598 - *
2599 - * @return array
2600 2369 */
2601 2370 private static function get_saved_errors( $form, $params ) {
2602 2371 global $frm_vars;
2603 2372
@@ -2619,12 +2388,8 @@
2619 2388 }
2620 2389
2621 2390 /**
2622 2391 * @since 2.2.7
2623 - *
2624 - * @param int|string $form_id
2625 - *
2626 - * @return int
2627 2392 */
2628 2393 public static function just_created_entry( $form_id ) {
2629 2394 global $frm_vars;
2630 2395
@@ -2642,9 +2407,8 @@
2642 2407 *
2643 2408 * @type object $form Form object.
2644 2409 * @type int $entry_id Entry ID.
2645 2410 * }
2646 - *
2647 2411 * @return array|string
2648 2412 */
2649 2413 private static function get_confirmation_method( $atts ) {
2650 2414 $action = FrmOnSubmitHelper::current_event( $atts );
@@ -2652,9 +2416,8 @@
2652 2416 $method = ! empty( $atts['form']->options[ $opt ] ) ? $atts['form']->options[ $opt ] : 'message';
2653 2417
2654 2418 if ( ! empty( $atts['entry_id'] ) ) {
2655 2419 $met_actions = self::get_met_on_submit_actions( $atts, $action );
2656 -
2657 2420 if ( $met_actions ) {
2658 2421 $method = $met_actions;
2659 2422 }
2660 2423 }
@@ -2667,15 +2430,8 @@
2667 2430
2668 2431 return $method;
2669 2432 }
2670 2433
2671 - /**
2672 - * @param object $form
2673 - * @param array $params
2674 - * @param array $args
2675 - *
2676 - * @return void
2677 - */
2678 2434 public static function maybe_trigger_redirect( $form, $params, $args ) {
2679 2435 if ( ! isset( $params['id'] ) ) {
2680 2436 global $frm_vars;
2681 2437 $params['id'] = $frm_vars['created_entries'][ $form->id ]['entry_id'];
@@ -2715,15 +2471,8 @@
2715 2471 self::trigger_redirect( $form, $params, $args );
2716 2472 }
2717 2473 }
2718 2474
2719 - /**
2720 - * @param object $form
2721 - * @param array $params
2722 - * @param array $args
2723 - *
2724 - * @return void
2725 - */
2726 2475 public static function trigger_redirect( $form, $params, $args ) {
2727 2476 $success_args = array(
2728 2477 'action' => $params['action'],
2729 2478 'conf_method' => 'redirect',
@@ -2782,9 +2531,8 @@
2782 2531 * @since 6.0
2783 2532 *
2784 2533 * @param array $args See {@see FrmFormsController::run_success_action()}.
2785 2534 * @param string $event Form event. Default is `create`.
2786 - *
2787 2535 * @return array Array of actions that meet the conditional logics.
2788 2536 */
2789 2537 public static function get_met_on_submit_actions( $args, $event = 'create' ) {
2790 2538 if ( ! FrmOnSubmitHelper::form_has_migrated( $args['form'] ) ) {
@@ -2857,9 +2605,8 @@
2857 2605 *
2858 2606 * @param object $action Form action object.
2859 2607 * @param array $args See {@see FrmFormsController::run_success_action()}.
2860 2608 * @param string $event Form event. Default is `create`.
2861 - *
2862 2609 * @return bool
2863 2610 */
2864 2611 private static function is_valid_on_submit_action( $action, $args, $event = 'create' ) {
2865 2612 $action_type = FrmOnSubmitHelper::get_action_type( $action );
@@ -2881,9 +2628,8 @@
2881 2628 return false;
2882 2629 }
2883 2630
2884 2631 $page = get_post( $action->post_content['success_page_id'] );
2885 -
2886 2632 if ( ! $page || 'trash' === $page->post_status ) {
2887 2633 return false;
2888 2634 }
2889 2635 }
@@ -2905,9 +2651,8 @@
2905 2651 'entry_id' => $args['entry_id'],
2906 2652 'action' => FrmOnSubmitHelper::current_event( $args ),
2907 2653 )
2908 2654 );
2909 -
2910 2655 if ( ! is_array( $args['conf_method'] ) ) {
2911 2656 self::run_success_action( $args );
2912 2657 return;
2913 2658 }
@@ -2934,9 +2679,8 @@
2934 2679 * @param array $args See {@see FrmFormsController::run_success_action()}.
2935 2680 */
2936 2681 public static function run_multi_on_submit_actions( $args ) {
2937 2682 $redirect_action = null;
2938 -
2939 2683 foreach ( $args['conf_method'] as $action ) {
2940 2684 if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $action ) ) {
2941 2685 // We catch the redirect action to run it last.
2942 2686 $redirect_action = $action;
@@ -2974,9 +2718,8 @@
2974 2718 * @since 6.0
2975 2719 *
2976 2720 * @param array $args See {@see FrmFormsController::run_success_action()}.
2977 2721 * @param object $action On Submit action object.
2978 - *
2979 2722 * @return array
2980 2723 */
2981 2724 private static function get_run_success_action_args( $args, $action ) {
2982 2725 $new_args = $args;
@@ -3000,17 +2743,12 @@
3000 2743 }
3001 2744
3002 2745 /**
3003 2746 * @since 3.0
3004 - *
3005 - * @param array $args
3006 - *
3007 - * @return void
3008 2747 */
3009 2748 private static function load_page_after_submit( $args ) {
3010 2749 global $post;
3011 2750 $opt = $args['success_opt'];
3012 -
3013 2751 if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) {
3014 2752 $page = get_post( $args['form']->options[ $opt . '_page_id' ] );
3015 2753 $old_post = $post;
3016 2754 $post = $page;
@@ -3034,9 +2772,8 @@
3034 2772 }
3035 2773
3036 2774 /**
3037 2775 * @since 3.0
3038 - *
3039 2776 * @param array $args See {@see FrmFormsController::run_success_action()}.
3040 2777 */
3041 2778 private static function redirect_after_submit( $args ) {
3042 2779 add_filter( 'frm_use_wpautop', '__return_false' );
@@ -3103,9 +2840,8 @@
3103 2840 *
3104 2841 * @since 6.3.1
3105 2842 *
3106 2843 * @param array $args See {@see FrmFormsController::run_success_action()}.
3107 - *
3108 2844 * @return array
3109 2845 */
3110 2846 private static function get_ajax_redirect_response_data( $args ) {
3111 2847 $response_data = array(
@@ -3128,9 +2864,8 @@
3128 2864 $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
3129 2865
3130 2866 $args['form']->options['success_msg'] = $args['message'];
3131 2867 $args['form']->options['edit_msg'] = $args['message'];
3132 -
3133 2868 if ( ! isset( $args['fields'] ) ) {
3134 2869 $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
3135 2870 }
3136 2871
@@ -3182,15 +2917,13 @@
3182 2917 add_filter( 'frm_use_wpautop', '__return_true' );
3183 2918
3184 2919 echo FrmAppHelper::maybe_kses( $redirect_msg ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3185 2920 echo '<script>';
3186 -
3187 2921 if ( empty( $args['doing_ajax'] ) ) {
3188 2922 // Not AJAX submit, delay JS until window.load.
3189 2923 echo 'window.onload=function(){';
3190 2924 }
3191 2925 echo 'setTimeout(function(){' . $redirect_js . '}, ' . intval( $delay_time ) . ');'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
3192 -
3193 2926 if ( empty( $args['doing_ajax'] ) ) {
3194 2927 echo '};';
3195 2928 }
3196 2929 echo '</script>';
@@ -3225,14 +2958,12 @@
3225 2958 * @since 6.3.1
3226 2959 *
3227 2960 * @param string $success_url Redirect URL.
3228 2961 * @param array $args Contains `form` object.
3229 - *
3230 2962 * @return string
3231 2963 */
3232 2964 private static function get_redirect_fallback_message( $success_url, $args ) {
3233 2965 $target = '';
3234 -
3235 2966 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
3236 2967 $target = ' target="_blank"';
3237 2968 }
3238 2969
@@ -3247,12 +2978,8 @@
3247 2978 /**
3248 2979 * Prepare to show the success message and empty form after submit
3249 2980 *
3250 2981 * @since 2.05
3251 - *
3252 - * @param array $atts
3253 - *
3254 - * @return void
3255 2982 */
3256 2983 public static function show_message_after_save( $atts ) {
3257 2984 $atts['message'] = self::prepare_submit_message( $atts['form'], $atts['entry_id'], $atts );
3258 2985
@@ -3258,9 +2985,8 @@
3258 2985
3259 2986 if ( ! isset( $atts['form']->options['show_form'] ) || $atts['form']->options['show_form'] ) {
3260 2987 if ( isset( $atts['action'] ) && 'update' === $atts['action'] && is_callable( array( 'FrmProEntriesController', 'show_front_end_form_with_entry' ) ) ) {
3261 2988 $entry = FrmEntry::getOne( $atts['entry_id'] );
3262 -
3263 2989 if ( $entry ) {
3264 2990 // This is copied from the Pro plugin.
3265 2991 $atts['conf_message'] = FrmProEntriesController::confirmation( 'message', $atts['form'], $atts['form']->options, $entry->id, $atts );
3266 2992 $atts['show_form'] = FrmProEntriesController::is_form_displayed_after_edit( $atts['form'] );
@@ -3277,12 +3003,8 @@
3277 3003 /**
3278 3004 * Show an empty form
3279 3005 *
3280 3006 * @since 2.05
3281 - *
3282 - * @param array $args
3283 - *
3284 - * @return void
3285 3007 */
3286 3008 private static function show_form_after_submit( $args ) {
3287 3009 self::fill_atts_for_form_display( $args );
3288 3010
@@ -3303,9 +3025,9 @@
3303 3025
3304 3026 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3305 3027
3306 3028 $frm_settings = FrmAppHelper::get_settings();
3307 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
3029 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3308 3030
3309 3031 global $frm_vars;
3310 3032 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3311 3033
@@ -3314,19 +3036,12 @@
3314 3036 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/new.php';
3315 3037 }
3316 3038
3317 3039 /**
3318 - * Gets message placement.
3319 - *
3320 3040 * @since 4.05.02
3321 - * @since 6.26 This method changed from `private` to `public`.
3322 - *
3323 - * @param object $form Form object.
3324 - * @param string $message The message.
3325 - *
3326 - * @return string Accepts 'before', 'after', or 'submit'.
3041 + * @return string - 'before', 'after', or 'submit'
3327 3042 */
3328 - public static function message_placement( $form, $message ) {
3043 + private static function message_placement( $form, $message ) {
3329 3044 $place = 'before';
3330 3045
3331 3046 if ( $message && isset( $form->options['form_class'] ) ) {
3332 3047 if ( strpos( $form->options['form_class'], 'frm_below_success' ) !== false ) {
@@ -3336,14 +3051,10 @@
3336 3051 }
3337 3052 }
3338 3053
3339 3054 /**
3340 - * Filter the message placement.
3341 - *
3342 3055 * @since 4.05.02
3343 - *
3344 - * @param string $place Accepts 'before', 'after', or 'submit'.
3345 - * @param array $args Args.
3056 + * @return string - 'before' or 'after'
3346 3057 */
3347 3058 return apply_filters( 'frm_message_placement', $place, compact( 'form', 'message' ) );
3348 3059 }
3349 3060
@@ -3350,12 +3061,8 @@
3350 3061 /**
3351 3062 * Get all the values needed on the new.php entry page
3352 3063 *
3353 3064 * @since 2.05
3354 - *
3355 - * @param array $args
3356 - *
3357 - * @return void
3358 3065 */
3359 3066 private static function fill_atts_for_form_display( &$args ) {
3360 3067 if ( ! isset( $args['title'] ) && isset( $args['show_title'] ) ) {
3361 3068 $args['title'] = $args['show_title'];
@@ -3380,12 +3087,8 @@
3380 3087 /**
3381 3088 * Show the success message without the form
3382 3089 *
3383 3090 * @since 2.05
3384 - *
3385 - * @param array $atts
3386 - *
3387 - * @return void
3388 3091 */
3389 3092 private static function show_lone_success_message( $atts ) {
3390 3093 global $frm_vars;
3391 3094 $values = FrmEntriesHelper::setup_new_vars( $atts['fields'], $atts['form'], true );
@@ -3408,17 +3111,16 @@
3408 3111 *
3409 3112 * @param object $form Form object.
3410 3113 * @param int $entry_id Entry ID.
3411 3114 * @param array $args See {@see FrmFormsController::run_success_action()}.
3412 - *
3413 3115 * @return string
3414 3116 */
3415 3117 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3416 3118 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3417 - $opt = $args['success_opt'] ?? 'success';
3119 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3418 3120
3419 3121 if ( $entry_id && is_numeric( $entry_id ) ) {
3420 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
3122 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3421 3123 $class = 'frm_message';
3422 3124 } else {
3423 3125 $message = $frm_settings->failed_msg;
3424 3126 $class = FrmFormsHelper::form_error_class();
@@ -3459,15 +3161,8 @@
3459 3161 public static function has_combo_js_file() {
3460 3162 return is_readable( FrmAppHelper::plugin_path() . '/js/frm.min.js' );
3461 3163 }
3462 3164
3463 - /**
3464 - * @param object $form
3465 - * @param int|string $this_load
3466 - * @param bool $global_load
3467 - *
3468 - * @return void
3469 - */
3470 3165 public static function maybe_load_css( $form, $this_load, $global_load ) {
3471 3166 $load_css = FrmForm::is_form_loaded( $form, $this_load, $global_load );
3472 3167
3473 3168 if ( ! $load_css ) {
@@ -3497,9 +3192,8 @@
3497 3192 return;
3498 3193 }
3499 3194
3500 3195 global $wp_styles;
3501 -
3502 3196 if ( is_array( $wp_styles->queue ) && in_array( 'formidable', $wp_styles->queue, true ) ) {
3503 3197 wp_print_styles( 'formidable' );
3504 3198 }
3505 3199 }
@@ -3514,16 +3208,10 @@
3514 3208 private static function should_load_late() {
3515 3209 return ! function_exists( 'aioseo' );
3516 3210 }
3517 3211
3518 - /**
3519 - * @param string $tag
3520 - * @param string $handle
3521 - *
3522 - * @return string
3523 - */
3524 3212 public static function defer_script_loading( $tag, $handle ) {
3525 - if ( 'captcha-api' === $handle && ! strpos( $tag, 'defer' ) ) {
3213 + if ( 'captcha-api' == $handle && ! strpos( $tag, 'defer' ) ) {
3526 3214 $tag = str_replace( ' src', ' defer="defer" async="async" src', $tag );
3527 3215 }
3528 3216
3529 3217 return $tag;
@@ -3528,13 +3216,8 @@
3528 3216
3529 3217 return $tag;
3530 3218 }
3531 3219
3532 - /**
3533 - * @param string $location
3534 - *
3535 - * @return void
3536 - */
3537 3220 public static function footer_js( $location = 'footer' ) {
3538 3221 global $frm_vars;
3539 3222
3540 3223 FrmStylesController::enqueue_css();
@@ -3548,13 +3231,8 @@
3548 3231 }
3549 3232
3550 3233 /**
3551 3234 * @since 2.0.8
3552 - *
3553 - * @param array $atts
3554 - * @param string $content
3555 - *
3556 - * @return void
3557 3235 */
3558 3236 private static function maybe_minimize_form( $atts, &$content ) {
3559 3237 // check if minimizing is turned on
3560 3238 if ( self::is_minification_on( $atts ) ) {
@@ -3563,11 +3241,8 @@
3563 3241 }
3564 3242
3565 3243 /**
3566 3244 * @since 2.0.8
3567 - *
3568 - * @param array $atts
3569 - *
3570 3245 * @return bool
3571 3246 */
3572 3247 private static function is_minification_on( $atts ) {
3573 3248 return ! empty( $atts['minimize'] );
@@ -3579,9 +3254,8 @@
3579 3254 * @return void
3580 3255 */
3581 3256 public static function landing_page_preview_option() {
3582 3257 $dir = apply_filters( 'frm_landing_page_preview_option', false );
3583 -
3584 3258 if ( false === $dir || ! file_exists( $dir . 'landing-page-preview-option.php' ) ) {
3585 3259 $dir = self::get_form_views_path();
3586 3260 }
3587 3261 include $dir . 'landing-page-preview-option.php';
@@ -3610,15 +3284,13 @@
3610 3284
3611 3285 check_ajax_referer( 'frm_ajax', 'nonce' );
3612 3286
3613 3287 $type = FrmAppHelper::get_post_param( 'type', '', 'sanitize_text_field' );
3614 -
3615 3288 if ( ! $type || ! in_array( $type, array( 'form', 'view' ), true ) ) {
3616 3289 die( 0 );
3617 3290 }
3618 3291
3619 3292 $object_id = FrmAppHelper::get_post_param( 'object_id', '', 'absint' );
3620 -
3621 3293 if ( ! $object_id ) {
3622 3294 die( 0 );
3623 3295 }
3624 3296
@@ -3630,15 +3302,13 @@
3630 3302 $postarr['post_content'] = apply_filters( 'frm_create_page_with_' . $type . '_shortcode_content', '', $object_id );
3631 3303 }
3632 3304
3633 3305 $name = FrmAppHelper::get_post_param( 'name', '', 'sanitize_text_field' );
3634 -
3635 3306 if ( $name ) {
3636 3307 $postarr['post_title'] = $name;
3637 3308 }
3638 3309
3639 3310 $success = wp_insert_post( $postarr );
3640 -
3641 3311 if ( ! is_numeric( $success ) || ! $success ) {
3642 3312 die( 0 );
3643 3313 }
3644 3314
@@ -3652,9 +3322,8 @@
3652 3322 /**
3653 3323 * @since 5.3
3654 3324 *
3655 3325 * @param int $form_id
3656 - *
3657 3326 * @return string
3658 3327 */
3659 3328 private static function get_page_shortcode_content_for_form( $form_id ) {
3660 3329 $shortcode = '[formidable id="' . $form_id . '"]';
@@ -3696,12 +3365,8 @@
3696 3365 }
3697 3366
3698 3367 /**
3699 3368 * @deprecated 4.0
3700 - *
3701 - * @param array $values
3702 - *
3703 - * @return void
3704 3369 */
3705 3370 public static function create( $values = array() ) {
3706 3371 _deprecated_function( __METHOD__, '4.0', 'FrmFormsController::update' );
3707 3372 self::update( $values );