PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.16.3
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.16.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 +43 -178 6.256.16.3 View file →
@@ -67,9 +67,9 @@
67 67 $data_message = __( 'Only show the fields you need and create branching forms. Upgrade to get conditional logic and question branching.', 'formidable' );
68 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' ) . '"/>';
69 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">';
70 70 esc_html_e( 'Conditional Logic', 'formidable' );
71 - 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' ) );
72 72 echo '</a>';
73 73 }
74 74
75 75 /**
@@ -107,16 +107,11 @@
107 107 *
108 108 * @since 2.02.11
109 109 *
110 110 * @param int|object $form
111 - * @return void
112 111 */
113 112 private static function create_default_email_action( $form ) {
114 113 FrmForm::maybe_get_form( $form );
115 - if ( ! is_object( $form ) ) {
116 - return;
117 - }
118 -
119 114 $create_email = apply_filters( 'frm_create_default_email_action', true, $form );
120 115
121 116 if ( $create_email ) {
122 117 /**
@@ -132,15 +127,11 @@
132 127 *
133 128 * @since 6.0.0
134 129 *
135 130 * @param int|object $form Form object or ID.
136 - * @return void
137 131 */
138 132 private static function create_default_on_submit_action( $form ) {
139 133 FrmForm::maybe_get_form( $form );
140 - if ( ! is_object( $form ) ) {
141 - return;
142 - }
143 134
144 135 /**
145 136 * Enable or disable the default On Submit action.
146 137 *
@@ -165,15 +156,11 @@
165 156 *
166 157 * @since 6.9
167 158 *
168 159 * @param int|object $form Form ID or object.
169 - * @return void
170 160 */
171 161 private static function create_submit_button_field( $form ) {
172 162 FrmForm::maybe_get_form( $form );
173 - if ( ! is_object( $form ) ) {
174 - return;
175 - }
176 163
177 164 if ( FrmSubmitHelper::get_submit_field( $form->id ) ) {
178 165 // Do not create submit button field if it exists.
179 166 return;
@@ -389,14 +376,12 @@
389 376 * @return string|null
390 377 */
391 378 public static function page_preview() {
392 379 $params = FrmForm::list_page_params();
393 - if ( ! $params['form'] || is_numeric( $params['form'] ) ) {
380 + if ( ! $params['form'] ) {
394 381 return null;
395 382 }
396 383
397 - self::maybe_block_preview( $params['form'] );
398 -
399 384 $form = FrmForm::getOne( $params['form'] );
400 385 if ( ! $form ) {
401 386 return null;
402 387 }
@@ -409,18 +394,9 @@
409 394 *
410 395 * @return void
411 396 */
412 397 public static function show_page_preview() {
413 - $preview = self::page_preview();
414 - if ( is_null( $preview ) ) {
415 - wp_die(
416 - '<h1>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</h1>',
417 - '<p>' . esc_html__( 'Form key is invalid', 'formidable' ) . '</p>',
418 - 404
419 - );
420 - }
421 -
422 - echo $preview; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
398 + echo self::page_preview(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
423 399 }
424 400
425 401 /**
426 402 * @return void
@@ -431,17 +407,8 @@
431 407
432 408 global $frm_vars;
433 409 $frm_vars['preview'] = true;
434 410
435 - // print_emoji_styles is deprecated.
436 - remove_action( 'wp_print_styles', 'print_emoji_styles' );
437 -
438 - if ( FrmTestModeController::should_add_test_mode_container() ) {
439 - do_action( 'frm_test_mode_init' );
440 - add_action( 'wp_enqueue_scripts', 'FrmTestModeController::register_and_enqueue_required_scripts' );
441 - add_filter( 'frm_filter_final_form', 'FrmTestModeController::maybe_add_test_mode_container', 99 );
442 - }
443 -
444 411 $include_theme = FrmAppHelper::get_param( 'theme', '', 'get', 'absint' );
445 412 if ( $include_theme ) {
446 413 self::set_preview_query();
447 414 self::load_theme_preview();
@@ -558,12 +525,8 @@
558 525 echo '<div class="container entry-content">';
559 526 the_content();
560 527 echo '</div>';
561 528
562 - // Prevent extra unexpected forms in the footer.
563 - // For some reason this happens in the Twenty Twenty Five theme.
564 - add_filter( 'frm_filter_final_form', '__return_empty_string' );
565 -
566 529 self::get_template( 'footer' );
567 530 }
568 531 }
569 532
@@ -653,36 +616,23 @@
653 616 /**
654 617 * @since 3.0
655 618 */
656 619 private static function load_direct_preview() {
620 + header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
621 +
622 + // print_emoji_styles is deprecated.
623 + remove_action( 'wp_print_styles', 'print_emoji_styles' );
624 +
657 625 $key = FrmAppHelper::simple_get( 'form', 'sanitize_title' );
658 626 if ( $key == '' ) {
659 627 $key = FrmAppHelper::get_post_param( 'form', '', 'sanitize_title' );
660 628 }
661 629
662 - if ( ! $key ) {
663 - $error = __( 'Form key is missing', 'formidable' );
664 - wp_die(
665 - '<h1>' . esc_html( $error ) . '</h1>',
666 - '<p>' . esc_html( $error ) . '</p>',
667 - 404
668 - );
669 - }
670 -
671 - self::maybe_block_preview( $key );
672 -
673 630 $form = FrmForm::getAll( array( 'form_key' => $key ), '', 1 );
674 - if ( ! $form ) {
675 - $error = __( 'Form does not exist', 'formidable' );
676 - wp_die(
677 - '<h1>' . esc_html( $error ) . '</h1>',
678 - '<p>' . esc_html( $error ) . '</p>',
679 - 404
680 - );
631 + if ( empty( $form ) ) {
632 + $form = FrmForm::getAll( array(), '', 1 );
681 633 }
682 634
683 - header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
684 -
685 635 self::fix_deprecated_null_param_warning();
686 636
687 637 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
688 638 }
@@ -687,30 +637,8 @@
687 637 require FrmAppHelper::plugin_path() . '/classes/views/frm-entries/direct.php';
688 638 }
689 639
690 640 /**
691 - * Block the form preview for the contact form by default if the user cannot view forms.
692 - * This is to prevent the contact form being exploited.
693 - * Since this form is added by default and every site uses the same key, it is too easy
694 - * to guess this form.
695 - *
696 - * @since 6.20
697 - *
698 - * @param string $form_key Form key.
699 - * @return void
700 - */
701 - public static function maybe_block_preview( $form_key ) {
702 - if ( FrmFormsHelper::should_block_preview( $form_key ) ) {
703 - $error = __( 'You do not have permission to view this form', 'formidable' );
704 - wp_die(
705 - '<h1>' . esc_html( $error ) . '</h1>',
706 - '<p>' . esc_html( $error ) . '</p>',
707 - 403
708 - );
709 - }
710 - }
711 -
712 - /**
713 641 * Some themes have a null $src value.
714 642 * This function adds a filter to ensure that $src is not null.
715 643 * WP will call str_starts_with with the null value triggering a deprecated message otherwise.
716 644 *
@@ -1135,14 +1063,8 @@
1135 1063 wp_redirect( esc_url_raw( add_query_arg( 'paged', $total_pages ) ) );
1136 1064 die();
1137 1065 }
1138 1066
1139 - $inbox = new FrmInbox();
1140 - $error = $inbox->check_for_error();
1141 - if ( $error ) {
1142 - $show_messages = array( $error['subject'] . '. ' . $error['message'] );
1143 - }
1144 -
1145 1067 require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/list.php';
1146 1068 }
1147 1069
1148 1070 /**
@@ -1149,16 +1071,14 @@
1149 1071 * @param array<string,string> $columns
1150 1072 * @return array<string,string>
1151 1073 */
1152 1074 public static function get_columns( $columns ) {
1153 - $columns['cb'] = '<input type="checkbox" />';
1154 - $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1155 - $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1156 - $columns['id'] = 'ID';
1157 - $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1158 - if ( 'trash' !== FrmAppHelper::simple_get( 'form_type' ) ) {
1159 - $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1160 - }
1075 + $columns['cb'] = '<input type="checkbox" />';
1076 + $columns['name'] = esc_html__( 'Form Title', 'formidable' );
1077 + $columns['entries'] = esc_html__( 'Entries', 'formidable' );
1078 + $columns['id'] = 'ID';
1079 + $columns['form_key'] = esc_html__( 'Key', 'formidable' );
1080 + $columns['shortcode'] = esc_html__( 'Actions', 'formidable' );
1161 1081 $columns['created_at'] = esc_html__( 'Date', 'formidable' );
1162 1082
1163 1083 add_screen_option(
1164 1084 'per_page',
@@ -1416,9 +1336,9 @@
1416 1336 $sections = array(
1417 1337 'advanced' => array(
1418 1338 'name' => __( 'General', 'formidable' ),
1419 1339 'title' => __( 'General Form Settings', 'formidable' ),
1420 - 'function' => array( self::class, 'advanced_settings' ),
1340 + 'function' => array( __CLASS__, 'advanced_settings' ),
1421 1341 'icon' => 'frm_icon_font frm_settings_icon',
1422 1342 ),
1423 1343 'email' => array(
1424 1344 'name' => __( 'Actions & Notifications', 'formidable' ),
@@ -1448,9 +1368,9 @@
1448 1368 ),
1449 1369 ),
1450 1370 'buttons' => array(
1451 1371 'name' => __( 'Buttons', 'formidable' ),
1452 - 'class' => self::class,
1372 + 'class' => __CLASS__,
1453 1373 'function' => 'buttons_settings',
1454 1374 'icon' => 'frm_icon_font frm_button_icon',
1455 1375 ),
1456 1376 'landing' => array(
@@ -1486,9 +1406,9 @@
1486 1406 ),
1487 1407 ),
1488 1408 'html' => array(
1489 1409 'name' => __( 'Customize HTML', 'formidable' ),
1490 - 'class' => self::class,
1410 + 'class' => __CLASS__,
1491 1411 'function' => 'html_settings',
1492 1412 'icon' => 'frm_icon_font frm_code_icon',
1493 1413 ),
1494 1414 );
@@ -1552,9 +1472,9 @@
1552 1472 public static function render_spam_settings( $values ) {
1553 1473 if ( function_exists( 'akismet_http_post' ) ) {
1554 1474 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/akismet.php';
1555 1475 }
1556 - include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/stopforumspam.php';
1476 + include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/honeypot.php';
1557 1477 include FrmAppHelper::plugin_path() . '/classes/views/frm-forms/spam-settings/antispam.php';
1558 1478 }
1559 1479
1560 1480 /**
@@ -1768,9 +1688,9 @@
1768 1688 echo ' frm_js_validate ';
1769 1689 self::add_js_validate_form_to_global_vars( $form );
1770 1690 }
1771 1691
1772 - if ( FrmForm::is_ajax_on( $form ) ) {
1692 + if ( ! FrmFormsHelper::should_use_pro_for_ajax_submit() && FrmForm::is_ajax_on( $form ) ) {
1773 1693 echo ' frm_ajax_submit ';
1774 1694 }
1775 1695 }
1776 1696
@@ -1932,26 +1852,13 @@
1932 1852
1933 1853 return $errors;
1934 1854 }
1935 1855
1936 - /**
1937 - * Includes html that shows a message when the device is too small to use Formidable Forms admin pages.
1938 - *
1939 - * @since 6.20
1940 - * @return void
1941 - */
1942 - public static function include_device_too_small_message() {
1943 - if ( ! FrmAppHelper::is_formidable_admin() ) {
1944 - return;
1945 - }
1946 -
1947 - include FrmAppHelper::plugin_path() . '/classes/views/shared/small-device-message.php';
1948 - }
1949 -
1950 1856 public static function route() {
1951 1857 $action = isset( $_REQUEST['frm_action'] ) ? 'frm_action' : 'action';
1952 1858 $vars = array();
1953 1859 FrmAppHelper::include_svg();
1860 +
1954 1861 if ( isset( $_POST['frm_compact_fields'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1955 1862 FrmAppHelper::permission_check( 'frm_edit_forms' );
1956 1863
1957 1864 // Javascript needs to be allowed in some field settings.
@@ -2055,32 +1962,12 @@
2055 1962 // Get posted data
2056 1963 $form_id = FrmAppHelper::get_post_param( 'form_id', '', 'absint' );
2057 1964 $name = FrmAppHelper::get_post_param( 'form_name', '', 'sanitize_text_field' );
2058 1965
2059 - $form = FrmForm::getOne( $form_id );
2060 - if ( ! $form ) {
2061 - wp_send_json_error( __( 'Form not found', 'formidable' ) );
2062 - }
1966 + // Update the form name and form key.
1967 + $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
1968 + FrmForm::update( $form_id, compact( 'name', 'form_key' ) );
2063 1969
2064 - if ( $name === $form->name ) {
2065 - // Nothing to change so exit early.
2066 - wp_send_json_success();
2067 - }
2068 -
2069 - $to_update = array(
2070 - 'name' => $name,
2071 - );
2072 -
2073 - if ( '' !== $name ) {
2074 - // Only update form_key if name is not empty.
2075 - $form_key = FrmAppHelper::get_unique_key( sanitize_title( $name ), 'frm_forms', 'form_key' );
2076 - $to_update['form_key'] = $form_key;
2077 - } else {
2078 - $form_key = $form->form_key;
2079 - }
2080 -
2081 - FrmForm::update( $form_id, $to_update );
2082 -
2083 1970 wp_send_json_success( compact( 'form_key' ) );
2084 1971 }
2085 1972
2086 1973 public static function json_error( $errors ) {
@@ -2485,9 +2372,9 @@
2485 2372 * @param array $args See {@see FrmFormsController::maybe_trigger_redirect()}.
2486 2373 */
2487 2374 public static function maybe_trigger_redirect_with_action( $conf_method, $form, $params, $args ) {
2488 2375 if ( is_array( $conf_method ) && 1 === count( $conf_method ) ) {
2489 - if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) && empty( $conf_method[0]->post_content['redirect_delay'] ) ) {
2376 + if ( 'redirect' === FrmOnSubmitHelper::get_action_type( $conf_method[0] ) ) {
2490 2377 $event = FrmOnSubmitHelper::current_event( $params );
2491 2378 FrmOnSubmitHelper::populate_on_submit_data( $form->options, $conf_method[0], $event );
2492 2379 $conf_method = 'redirect';
2493 2380 }
@@ -2822,9 +2709,9 @@
2822 2709 echo json_encode( self::get_ajax_redirect_response_data( $args + compact( 'success_url' ) ) );
2823 2710 wp_die();
2824 2711 }
2825 2712
2826 - if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) && empty( $args['form']->options['redirect_delay'] ) ) {
2713 + if ( ! headers_sent() && empty( $args['force_delay_redirect'] ) ) {
2827 2714 // Not AJAX submit, no headers sent, and there is just one Redirect action runs.
2828 2715 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2829 2716 self::print_open_in_new_tab_js_with_fallback_handler( $success_url, $args );
2830 2717 self::$redirected_in_new_tab[ $args['form']->id ] = 1;
@@ -2869,46 +2756,28 @@
2869 2756 * @param array $args See {@see FrmFormsController::run_success_action()}.
2870 2757 * @return array
2871 2758 */
2872 2759 private static function get_ajax_redirect_response_data( $args ) {
2873 - $response_data = array(
2874 - 'redirect' => $args['success_url'],
2875 - 'content' => '',
2876 - );
2877 - $unset_content = true;
2760 + $response_data = array( 'redirect' => $args['success_url'] );
2878 2761
2879 - if ( ! empty( $args['form']->options['redirect_delay'] ) ) {
2880 - $response_data['delay'] = $args['form']->options['redirect_delay_time'];
2881 - $response_data['content'] .= self::get_redirect_message( $args['success_url'], $args['form']->options['redirect_delay_msg'], $args );
2882 - $unset_content = false;
2883 - }
2884 -
2885 2762 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2886 2763 $response_data['openInNewTab'] = 1;
2887 2764
2888 - // Only show open in new tab text if there is no delay.
2889 - if ( empty( $response_data['content'] ) ) {
2890 - $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2765 + $args['message'] = FrmOnSubmitHelper::get_default_new_tab_msg();
2891 2766
2892 - $args['form']->options['success_msg'] = $args['message'];
2893 - $args['form']->options['edit_msg'] = $args['message'];
2894 - if ( ! isset( $args['fields'] ) ) {
2895 - $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2896 - }
2767 + $args['form']->options['success_msg'] = $args['message'];
2768 + $args['form']->options['edit_msg'] = $args['message'];
2769 + if ( ! isset( $args['fields'] ) ) {
2770 + $args['fields'] = FrmField::get_all_for_form( $args['form']->id );
2771 + }
2897 2772
2898 - $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2773 + $args['message'] = self::prepare_submit_message( $args['form'], $args['entry_id'], $args );
2899 2774
2900 - ob_start();
2901 - self::show_lone_success_message( $args );
2902 - $response_data['content'] .= ob_get_clean();
2903 - $unset_content = false;
2904 - }//end if
2775 + ob_start();
2776 + self::show_lone_success_message( $args );
2777 + $response_data['content'] = ob_get_clean();
2905 2778
2906 2779 $response_data['fallbackMsg'] = self::get_redirect_fallback_message( $args['success_url'], $args );
2907 - }//end if
2908 -
2909 - if ( $unset_content && '' === $response_data['content'] ) {
2910 - unset( $response_data['content'] );
2911 2780 }
2912 2781
2913 2782 return $response_data;
2914 2783 }
@@ -2920,9 +2789,9 @@
2920 2789 *
2921 2790 * @param array $args See {@see FrmFormsController::run_success_action()}.
2922 2791 */
2923 2792 private static function redirect_after_submit_using_js( $args ) {
2924 - $success_msg = $args['form']->options['redirect_delay_msg'];
2793 + $success_msg = FrmOnSubmitHelper::get_default_redirect_msg();
2925 2794 $redirect_msg = self::get_redirect_message( $args['success_url'], $success_msg, $args );
2926 2795 $success_url = esc_url_raw( $args['success_url'] );
2927 2796
2928 2797 /**
@@ -2931,9 +2800,9 @@
2931 2800 * @since 6.0
2932 2801 *
2933 2802 * @param int $delay_time Delay time in milliseconds.
2934 2803 */
2935 - $delay_time = apply_filters( 'frm_redirect_delay_time', 1000 * $args['form']->options['redirect_delay_time'] );
2804 + $delay_time = apply_filters( 'frm_redirect_delay_time', 8000 );
2936 2805
2937 2806 if ( ! empty( $args['form']->options['open_in_new_tab'] ) ) {
2938 2807 $redirect_js = 'window.open("' . $success_url . '", "_blank")';
2939 2808 } else {
@@ -2962,10 +2831,8 @@
2962 2831 * @param string $success_msg
2963 2832 * @param array $args
2964 2833 */
2965 2834 private static function get_redirect_message( $success_url, $success_msg, $args ) {
2966 - $success_msg = apply_filters( 'frm_content', $success_msg, $args['form'], $args['entry_id'] );
2967 - $success_msg = do_shortcode( FrmAppHelper::use_wpautop( $success_msg ) );
2968 2835 $redirect_msg = '<div class="' . esc_attr( FrmFormsHelper::get_form_style_class( $args['form'] ) ) . '"><div class="frm-redirect-msg" role="status">' . $success_msg . '<br/>' .
2969 2836 self::get_redirect_fallback_message( $success_url, $args ) .
2970 2837 '</div></div>';
2971 2838
@@ -3051,9 +2918,9 @@
3051 2918
3052 2919 $include_form_tag = apply_filters( 'frm_include_form_tag', true, $form );
3053 2920
3054 2921 $frm_settings = FrmAppHelper::get_settings();
3055 - $submit = $form->options['submit_value'] ?? $frm_settings->submit_value;
2922 + $submit = isset( $form->options['submit_value'] ) ? $form->options['submit_value'] : $frm_settings->submit_value;
3056 2923
3057 2924 global $frm_vars;
3058 2925 self::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
3059 2926
@@ -3141,12 +3008,12 @@
3141 3008 * @return string
3142 3009 */
3143 3010 private static function prepare_submit_message( $form, $entry_id, $args = array() ) {
3144 3011 $frm_settings = FrmAppHelper::get_settings( array( 'current_form' => $form->id ) );
3145 - $opt = $args['success_opt'] ?? 'success';
3012 + $opt = isset( $args['success_opt'] ) ? $args['success_opt'] : 'success';
3146 3013
3147 3014 if ( $entry_id && is_numeric( $entry_id ) ) {
3148 - $message = $form->options[ $opt . '_msg' ] ?? $frm_settings->success_msg;
3015 + $message = isset( $form->options[ $opt . '_msg' ] ) ? $form->options[ $opt . '_msg' ] : $frm_settings->success_msg;
3149 3016 $class = 'frm_message';
3150 3017 } else {
3151 3018 $message = $frm_settings->failed_msg;
3152 3019 $class = FrmFormsHelper::form_error_class();
@@ -3250,10 +3117,8 @@
3250 3117
3251 3118 if ( ! FrmAppHelper::is_admin() && $location !== 'header' && ! empty( $frm_vars['forms_loaded'] ) ) {
3252 3119 // load formidable js
3253 3120 wp_enqueue_script( 'formidable' );
3254 -
3255 - FrmHoneypot::maybe_print_honeypot_js();
3256 3121 }
3257 3122 }
3258 3123
3259 3124 /**