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

161 lines 5.9 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 $frm_settings = FrmAppHelper::get_settings();
84
85 if ( FrmAppHelper::is_admin() && ( ! isset( $_GET['action'] ) || 'elementor' !== $_GET['action'] ) ) {
86 ?>
87 <div class="frm_form_field form-field">
88 <label class="frm_primary_label"><?php esc_html_e( 'Entry Key', 'formidable' ); ?></label>
89 <input type="text" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
90 </div>
91 <?php
92 } else {
93 ?>
94 <input type="hidden" name="item_key" value="<?php echo esc_attr( $values['item_key'] ); ?>" />
95 <?php
96 FrmHoneypot::maybe_render_field( $form->id );
97 FrmFormState::maybe_render_state_field( $form );
98 }
99
100 do_action( 'frm_entry_form', $form, $form_action, $errors );
101
102 global $frm_vars;
103
104 // close open section div
105 if ( ! empty( $frm_vars['div'] ) ) {
106 echo "</div>\n";
107 unset( $frm_vars['div'] );
108 }
109
110 // close open collapsible toggle div
111 if ( ! empty( $frm_vars['collapse_div'] ) ) {
112 echo "</div>\n";
113 unset( $frm_vars['collapse_div'] );
114 }
115
116 echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
117
118 if ( FrmForm::show_submit( $form ) && ! FrmSubmitHelper::has_submit_field_on_current_page( $values ) ) {
119 /**
120 * @since 5.5.1
121 */
122 do_action( 'frm_before_submit_btn', compact( 'form' ) );
123
124 $copy_values = $values;
125 unset( $copy_values['fields'] );
126
127 if ( isset( $form->options['form_class'] ) && strpos( $form->options['form_class'], 'frm_inline_success' ) !== false ) {
128 ob_start();
129 ob_implicit_flush( false );
130 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
131 $clip = ob_get_clean();
132
133 ob_start();
134 ob_implicit_flush( false );
135 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
136 $message = ob_get_clean();
137
138 echo preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $message . '</div>', $clip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
139 } else {
140 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
141 }
142
143 /**
144 * @since 5.5.1
145 */
146 do_action( 'frm_after_submit_btn', compact( 'form' ) );
147 }//end if
148 ?>
149 </div>
150 </fieldset>
151 </div>
152 <?php if ( has_action( 'frm_entries_footer_scripts' ) ) { ?>
153 <script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script>
154 <?php } ?>
155
156 <?php
157 // Add the shortcode back with the original callbacks
158 if ( $original_input_shortcode_callback ) {
159 add_shortcode( 'input', $original_input_shortcode_callback );
160 }
161