PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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
formidable / classes / views / frm-entries / form.php

form.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More trunk, at classes/views/frm-entries/form.php

159 lines 5.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 // Temporarily remove the [input] shortcode if it exists to avoid conflicts.
7 // This includes the Payment form by Paystack plugin.
8 global $shortcode_tags;
9
10 // Store the current callbacks for the shortcode
11 $original_input_shortcode_callback = $shortcode_tags['input'] ?? false;
12
13 // Remove the shortcode
14 remove_shortcode( 'input' );
15
16 $only_contain_submit = isset( $values['fields'] ) && FrmSubmitHelper::only_contains_submit_field( $values['fields'] );
17
18 if ( empty( $values ) || empty( $values['fields'] ) || $only_contain_submit ) { ?>
19 <div class="frm_forms <?php echo esc_attr( FrmFormsHelper::get_form_style_class( $form ) ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container">
20 <div class="frm_error_style">
21 <strong><?php esc_html_e( 'Oops!', 'formidable' ); ?></strong>
22 <?php
23 printf(
24 /* translators: %1$s: HTML open link, %2$s: HTML close link */
25 esc_html__( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ),
26 '<a href="' . esc_url( FrmForm::get_edit_link( $form->id ) ) . '">',
27 '</a>'
28 );
29 ?>
30 </div>
31 </div>
32 <?php
33 return;
34 }
35
36 global $frm_vars;
37 FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
38
39 // Get conditionally hidden fields
40 $frm_hide_fields = FrmAppHelper::get_post_param( 'frm_hide_fields_' . $form->id, '', 'sanitize_text_field' );
41
42 ?>
43 <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
44 <fieldset>
45 <?php
46 /**
47 * @since 5.5.1
48 */
49 do_action( 'frm_before_title', compact( 'form' ) );
50 echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
51 ?>
52 <div <?php echo wp_strip_all_tags( apply_filters( 'frm_fields_container_class', 'class="frm_fields_container"' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
53 <?php do_action( 'frm_after_title', compact( 'form' ) ); ?>
54 <input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ); ?>" />
55 <input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ); ?>" />
56 <input type="hidden" name="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" id="frm_hide_fields_<?php echo esc_attr( $form->id ); ?>" value="<?php echo esc_attr( $frm_hide_fields ); ?>" />
57 <input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ); ?>" />
58 <input type="hidden" name="item_meta[0]" value="" />
59 <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
60 <?php if ( isset( $id ) ) { ?>
61 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
62 <?php } ?>
63 <?php
64 if ( ! $only_contain_submit ) {
65 /**
66 * Allows modifying the list of fields in the frontend form.
67 *
68 * @since 5.0.04
69 *
70 * @param array $fields Array of fields.
71 * @param array $args The arguments. Contains `form`.
72 */
73 $fields_to_show = apply_filters( 'frm_fields_in_form', $values['fields'], compact( 'form' ) );
74
75 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
76 // Remove submit field when add or edit entry in backend.
77 FrmSubmitHelper::remove_submit_field_from_list( $fields_to_show );
78 }
79
80 FrmFieldsHelper::show_fields( $fields_to_show, $errors, $form, $form_action );
81 }//end if
82
83 if ( FrmAppHelper::is_admin() && ( ! isset( $_GET['action'] ) || 'elementor' !== $_GET['action'] ) ) {
84 ?>
85 <div class="frm_form_field form-field">
86 <label class="frm_primary_label"><?php esc_html_e( 'Entry Key', 'formidable' ); ?></label>
87 <input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
88 </div>
89 <?php
90 } else {
91 ?>
92 <input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
93 <?php
94 FrmHoneypot::maybe_render_field( $form->id );
95 FrmFormState::maybe_render_state_field( $form );
96 }
97
98 do_action( 'frm_entry_form', $form, $form_action, $errors );
99
100 global $frm_vars;
101
102 // Close open section div
103 if ( ! empty( $frm_vars['div'] ) ) {
104 echo "</div>\n";
105 unset( $frm_vars['div'] );
106 }
107
108 // Close open collapsible toggle div
109 if ( ! empty( $frm_vars['collapse_div'] ) ) {
110 echo "</div>\n";
111 unset( $frm_vars['collapse_div'] );
112 }
113
114 echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
115
116 if ( FrmForm::show_submit( $form ) && ! FrmSubmitHelper::has_submit_field_on_current_page( $values ) ) {
117 /**
118 * @since 5.5.1
119 */
120 do_action( 'frm_before_submit_btn', compact( 'form' ) );
121
122 $copy_values = $values;
123 unset( $copy_values['fields'] );
124
125 if ( isset( $form->options['form_class'] ) && str_contains( $form->options['form_class'], 'frm_inline_success' ) ) {
126 ob_start();
127 ob_implicit_flush( false );
128 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
129 $clip = ob_get_clean();
130
131 ob_start();
132 ob_implicit_flush( false );
133 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
134 $message = ob_get_clean();
135
136 echo preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $message . '</div>', $clip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
137 } else {
138 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
139 }
140
141 /**
142 * @since 5.5.1
143 */
144 do_action( 'frm_after_submit_btn', compact( 'form' ) );
145 }//end if
146 ?>
147 </div>
148 </fieldset>
149 </div>
150 <?php if ( has_action( 'frm_entries_footer_scripts' ) ) { ?>
151 <script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script>
152 <?php } ?>
153
154 <?php
155 // Add the shortcode back with the original callbacks
156 if ( $original_input_shortcode_callback ) {
157 add_shortcode( 'input', $original_input_shortcode_callback );
158 }
159