PluginProbe ʕ •ᴥ•ʔ
SureForms – Drag & Drop Contact Form & Form Builder, Payment Form, Survey, Quiz & Calculator / 2.12.0
SureForms – Drag & Drop Contact Form & Form Builder, Payment Form, Survey, Quiz & Calculator v2.12.0
2.12.2 2.12.1 2.12.0 2.11.1 2.11.0 2.10.1 2.10.0 2.9.1 2.9.0 2.8.2 2.8.1 2.7.0 2.7.1 2.8.0 trunk 0.0.10 0.0.11 0.0.12 0.0.13 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 0.0.8 0.0.9 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.1.0 1.1.1 1.1.2 1.10.0 1.10.1 1.11.0 1.12.0 1.12.1 1.12.2 1.12.3 1.13.0 1.13.1 1.13.2 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.8.0 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.1.0 2.1.1 2.2.0 2.2.1 2.2.2 2.3.0 2.4.0 2.5.0 2.5.2 2.6.0
sureforms / templates / single-form.php
sureforms / templates Last commit date
single-form.php 3 weeks ago
single-form.php
223 lines
1 <?php
2 /**
3 * Form Single template.
4 *
5 * @package SureForms
6 */
7
8 use SRFM\Inc\Generate_Form_Markup;
9 use SRFM\Inc\Helper;
10
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit; // Exit if accessed directly.
13 }
14
15 // phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scoped variables consumed only within this template, not true plugin globals.
16
17 $srfm_custom_post_id = absint( get_the_ID() );
18 $srfm_form_preview = isset( $_GET['form_preview'] ) ? boolval( wp_unslash( $_GET['form_preview'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is not required here.
19 $srfm_live_mode_data = Helper::get_instant_form_live_data();
20
21 $instant_form_settings = ! empty( $srfm_live_mode_data ) ? $srfm_live_mode_data : Helper::get_array_value( Helper::get_post_meta( $srfm_custom_post_id, '_srfm_instant_form_settings' ) );
22 $site_logo = $instant_form_settings['site_logo'];
23 $bg_type = $instant_form_settings['bg_type'];
24 $bg_color = $instant_form_settings['bg_color'];
25 $cover_type = $instant_form_settings['cover_type'];
26 $cover_color = $instant_form_settings['cover_color'];
27 $cover_image = $instant_form_settings['cover_image'];
28 $enable_instant_form = $instant_form_settings['enable_instant_form'];
29 $form_container_width = $instant_form_settings['form_container_width'];
30 $single_page_form_title = $instant_form_settings['single_page_form_title'];
31 $use_banner_as_page_background = $instant_form_settings['use_banner_as_page_background'];
32
33 $srfm_cover_image_url = $cover_image ? rawurldecode( strval( $cover_image ) ) : '';
34
35 // Filter to use custom bg image and color combination on the Instant Form page.
36 if ( apply_filters( 'srfm_use_color_or_image_as_bg', true ) ) {
37 if ( 'image' === $bg_type ) {
38 $bg_color = '#ffffff';
39 } else {
40 $bg_color = $bg_color ? $bg_color : '';
41 }
42 }
43
44 $body_classes = [];
45
46 if ( $use_banner_as_page_background ) {
47 $body_classes[] = 'srfm-has-banner-page-bg';
48
49 if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) {
50 $body_classes[] = 'srfm-has-cover-img';
51 }
52 }
53
54 ?>
55 <!DOCTYPE html>
56 <html class="srfm-html" <?php language_attributes(); ?>>
57
58 <head>
59 <meta charset="<?php bloginfo( 'charset' ); ?>">
60 <meta http-equiv="x-ua-compatible" content="ie=edge">
61 <?php if ( ! wp_is_block_theme() ) { ?>
62 <meta name="viewport" content="width=device-width, initial-scale=1">
63 <?php
64 }
65 ?>
66 <style>
67 <?php
68 echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) );
69
70 if ( $srfm_live_mode_data ) {
71 ?>
72 html {
73 margin: 0 !important;
74 opacity: 0;
75 transition: all 0.5s ease-in-out;
76 }
77 #wpadminbar {
78 display: none;
79 }
80 body {
81 pointer-events: none;
82 }
83 <?php
84 }
85
86 if ( ! $srfm_form_preview ) {
87 ?>
88 body * {
89 /* Maintain consistent box-sizing for different themes. */
90 box-sizing: border-box;
91 }
92 #srfm-single-page-container {
93 --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>;
94 --srfm-bg-color: <?php echo $bg_color && is_string( $bg_color ) ? esc_html( $bg_color ) : ''; ?>;
95 }
96 <?php
97 $selector = '.single-sureforms_form .srfm-single-page-container .srfm-page-banner';
98
99 if ( $use_banner_as_page_background ) {
100 $selector = 'html body.single-sureforms_form';
101 }
102 ?>
103 <?php echo esc_html( $selector ); ?> {
104 <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) { ?>
105 background-image: url(<?php echo esc_attr( $srfm_cover_image_url ); ?> );
106 background-position: center;
107 background-repeat: no-repeat;
108 background-size: cover;
109 <?php if ( $use_banner_as_page_background ) { ?>
110 background-attachment: fixed;
111 <?php } ?>
112 <?php } else { ?>
113 background-color: <?php echo esc_attr( $cover_color ); ?>;
114 <?php } ?>
115 }
116 <?php
117 } else {
118 ?>
119 html.srfm-html {
120 margin-top: 0 !important;
121 /* make the background transparent for the sureforms/form block preview */
122 background-color: transparent;
123 /* Needs to be important to remove margin-top added by WordPress admin bar */
124 }
125 body.single.single-sureforms_form {
126 background-color: transparent;
127 }
128 .srfm-form-container~div,
129 .srfm-instant-form-wrn-ctn {
130 display: none !important;
131 /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
132 }
133 <?php
134 }
135 ?>
136 </style>
137
138 <?php wp_head(); ?>
139 </head>
140
141 <?php
142 // Filter to use custom body content on the Instant Form page.
143 if ( ! apply_filters( 'srfm_use_custom_body_template', false ) ) {
144 ?>
145 <body <?php body_class( $body_classes ); ?>>
146 <?php if ( ! $srfm_form_preview ) { ?>
147 <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo (bool) $single_page_form_title ? 'has-form-title' : ''; ?>">
148 <div class="srfm-page-banner">
149 <?php
150 if ( ! empty( $site_logo ) ) {
151 ?>
152 <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>">
153 <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>">
154 </a>
155 <?php
156 }
157
158 if ( ! empty( $single_page_form_title ) ) {
159 ?>
160 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
161 <?php
162 }
163 ?>
164 </div>
165 <div class="srfm-form-wrapper">
166 <?php
167 // phpcs:ignore
168 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' );
169 // phpcs:ignoreEnd
170 ?>
171 </div>
172 <?php
173 if ( ! Helper::has_pro() ) {
174 // Display SureForms branding if SureForms Pro is not activated.
175 echo wp_kses_post(
176 sprintf(
177 '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>',
178 esc_url( SRFM_WEBSITE ),
179 /* translators: Here %s is the plugin's name. */
180 sprintf( esc_html__( 'Crafted with ♡ %s', 'sureforms' ), 'SureForms' )
181 )
182 );
183 }
184 ?>
185 </div>
186 <?php } else { ?>
187 <?php
188 show_admin_bar( false );
189 // phpcs:ignore
190 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' );
191 // phpcs:ignoreEnd
192 }
193 wp_footer();
194 ?>
195 </body>
196 <?php
197 }
198
199 if ( ! $srfm_form_preview && empty( $enable_instant_form ) ) {
200 ?>
201 <div class="srfm-form-status-badge"><?php esc_html_e( 'Instant Form Disabled', 'sureforms' ); ?></div>
202 <?php
203 }
204
205 // Action to load custom body content on the Instant Form page.
206 do_action( 'srfm_after_instant_form_body', $srfm_custom_post_id, $instant_form_settings, $body_classes );
207
208 if ( $srfm_live_mode_data ) {
209 ?>
210 <script>
211 (function() {
212 document.addEventListener('DOMContentLoaded', function() {
213 document.querySelector('html').style.opacity = 1;
214 });
215 }());
216 </script>
217 <?php
218 }
219 ?>
220
221 </html>
222 <?php
223