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

157 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 if ( empty( $values ) || empty( $values['fields'] ) || $only_contain_submit ) { ?>
18 <div class="frm_forms <?php echo esc_attr( FrmFormsHelper::get_form_style_class( $form ) ); ?>" id="frm_form_<?php echo esc_attr( $form->id ); ?>_container">
19 <div class="frm_error_style">
20 <strong><?php esc_html_e( 'Oops!', 'formidable' ); ?></strong>
21 <?php
22 printf(
23 /* translators: %1$s: HTML open link, %2$s: HTML close link */
24 esc_html__( 'You did not add any fields to your form. %1$sGo back%2$s and add some.', 'formidable' ),
25 '<a href="' . esc_url( FrmForm::get_edit_link( $form->id ) ) . '">',
26 '</a>'
27 );
28 ?>
29 </div>
30 </div>
31 <?php
32 return;
33 }
34
35 global $frm_vars;
36 FrmFormsController::maybe_load_css( $form, $values['custom_style'], $frm_vars['load_css'] );
37
38 // Get conditionally hidden fields
39 $frm_hide_fields = FrmAppHelper::get_post_param( 'frm_hide_fields_' . $form->id, '', 'sanitize_text_field' );
40
41 ?>
42 <div class="frm_form_fields <?php echo esc_attr( apply_filters( 'frm_form_fields_class', '', $values ) ); ?>">
43 <fieldset>
44 <?php
45 /**
46 * @since 5.5.1
47 */
48 do_action( 'frm_before_title', compact( 'form' ) );
49 echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['before_html'], $form, $title, $description ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
50 ?>
51 <div <?php echo wp_strip_all_tags( apply_filters( 'frm_fields_container_class', 'class="frm_fields_container"' ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>>
52 <?php do_action( 'frm_after_title', compact( 'form' ) ); ?>
53 <input type="hidden" name="frm_action" value="<?php echo esc_attr( $form_action ); ?>" />
54 <input type="hidden" name="form_id" value="<?php echo esc_attr( $form->id ); ?>" />
55 <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 ); ?>" />
56 <input type="hidden" name="form_key" value="<?php echo esc_attr( $form->form_key ); ?>" />
57 <input type="hidden" name="item_meta[0]" value="" />
58 <?php wp_nonce_field( 'frm_submit_entry_nonce', 'frm_submit_entry_' . $form->id ); ?>
59 <?php if ( isset( $id ) ) { ?>
60 <input type="hidden" name="id" value="<?php echo esc_attr( $id ); ?>" />
61 <?php } ?>
62 <?php
63 if ( ! $only_contain_submit ) {
64 /**
65 * Allows modifying the list of fields in the frontend form.
66 *
67 * @since 5.0.04
68 *
69 * @param array $fields Array of fields.
70 * @param array $args The arguments. Contains `form`.
71 */
72 $fields_to_show = apply_filters( 'frm_fields_in_form', $values['fields'], compact( 'form' ) );
73
74 if ( FrmAppHelper::is_admin_page( 'formidable-entries' ) ) {
75 // Remove submit field when add or edit entry in backend.
76 FrmSubmitHelper::remove_submit_field_from_list( $fields_to_show );
77 }
78
79 FrmFieldsHelper::show_fields( $fields_to_show, $errors, $form, $form_action );
80 }//end if
81
82 $frm_settings = FrmAppHelper::get_settings();
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 // close open section div
102 if ( ! empty( $frm_vars['div'] ) ) {
103 echo "</div>\n";
104 unset( $frm_vars['div'] );
105 }
106
107 // close open collapsible toggle div
108 if ( ! empty( $frm_vars['collapse_div'] ) ) {
109 echo "</div>\n";
110 unset( $frm_vars['collapse_div'] );
111 }
112
113 echo FrmAppHelper::maybe_kses( FrmFormsHelper::replace_shortcodes( $values['after_html'], $form ) ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
114 if ( FrmForm::show_submit( $form ) && ! FrmSubmitHelper::has_submit_field_on_current_page( $values ) ) {
115 /**
116 * @since 5.5.1
117 */
118 do_action( 'frm_before_submit_btn', compact( 'form' ) );
119
120 $copy_values = $values;
121 unset( $copy_values['fields'] );
122
123 if ( isset( $form->options['form_class'] ) && strpos( $form->options['form_class'], 'frm_inline_success' ) !== false ) {
124 ob_start();
125 ob_implicit_flush( false );
126 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
127 $clip = ob_get_clean();
128
129 ob_start();
130 ob_implicit_flush( false );
131 include FrmAppHelper::plugin_path() . '/classes/views/frm-entries/errors.php';
132 $message = ob_get_clean();
133
134 echo preg_replace( '~\<\/div\>(?!.*\<\/div\>)~', $message . '</div>', $clip ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
135 } else {
136 FrmFormsHelper::get_custom_submit( $copy_values['submit_html'], $form, $submit, $form_action, $copy_values );
137 }
138
139 /**
140 * @since 5.5.1
141 */
142 do_action( 'frm_after_submit_btn', compact( 'form' ) );
143 }//end if
144 ?>
145 </div>
146 </fieldset>
147 </div>
148 <?php if ( has_action( 'frm_entries_footer_scripts' ) ) { ?>
149 <script type="text/javascript"><?php do_action( 'frm_entries_footer_scripts', $values['fields'], $form ); ?></script>
150 <?php } ?>
151
152 <?php
153 // Add the shortcode back with the original callbacks
154 if ( $original_input_shortcode_callback ) {
155 add_shortcode( 'input', $original_input_shortcode_callback );
156 }
157