PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.0.2
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.0.2
2.12.6 2.12.5 2.12.4 2.12.3 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 All 96 releases
sureforms / templates / single-form.php
single-form.php
209 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $srfm_custom_post_id = absint( get_the_ID() );
16 $srfm_form_preview = isset( $_GET['form_preview'] ) ? boolval( sanitize_text_field( wp_unslash( $_GET['form_preview'] ) ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
17 $srfm_live_mode_data = Helper::get_instant_form_live_data();
18
19 $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' ) );
20 $site_logo = $instant_form_settings['site_logo'];
21 $bg_type = $instant_form_settings['bg_type'];
22 $bg_color = $instant_form_settings['bg_color'];
23 $bg_image = $instant_form_settings['bg_image'];
24 $cover_type = $instant_form_settings['cover_type'];
25 $cover_color = $instant_form_settings['cover_color'];
26 $cover_image = $instant_form_settings['cover_image'];
27 $enable_instant_form = $instant_form_settings['enable_instant_form'];
28 $form_container_width = $instant_form_settings['form_container_width'];
29 $single_page_form_title = $instant_form_settings['single_page_form_title'];
30 $use_banner_as_page_background = $instant_form_settings['use_banner_as_page_background'];
31
32 $srfm_cover_image_url = $cover_image ? rawurldecode( strval( $cover_image ) ) : '';
33
34 if ( 'image' === $bg_type ) {
35 $bg_image = $bg_image ? 'url(' . $bg_image . ')' : '';
36 $bg_color = '#ffffff';
37 } else {
38 $bg_image = 'none';
39 $bg_color = $bg_color ? $bg_color : '';
40 }
41
42 $body_classes = [];
43
44 if ( $use_banner_as_page_background ) {
45 $body_classes[] = 'srfm-has-banner-page-bg';
46
47 if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) {
48 $body_classes[] = 'srfm-has-cover-img';
49 }
50 }
51
52 ?>
53 <!DOCTYPE html>
54 <html class="srfm-html" <?php language_attributes(); ?>>
55
56 <head>
57 <meta charset="<?php bloginfo( 'charset' ); ?>">
58 <meta http-equiv="x-ua-compatible" content="ie=edge">
59 <?php if ( ! wp_is_block_theme() ) { ?>
60 <meta name="viewport" content="width=device-width, initial-scale=1">
61 <?php
62 }
63 wp_head();
64 ?>
65 <style>
66 <?php
67 echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) );
68
69 if ( $srfm_live_mode_data ) {
70 ?>
71 html {
72 margin: 0 !important;
73 opacity: 0;
74 transition: all 0.5s ease-in-out;
75 }
76 #wpadminbar {
77 display: none;
78 }
79 body {
80 pointer-events: none;
81 }
82 <?php
83 }
84
85 if ( ! $srfm_form_preview ) {
86 ?>
87 body * {
88 /* Maintain consistent box-sizing for different themes. */
89 box-sizing: border-box;
90 }
91 #srfm-single-page-container {
92 --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>;
93 --srfm-bg-image: <?php echo $bg_image && is_string( $bg_image ) ? esc_html( $bg_image ) : ''; ?>;
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 else : ?>
110 background-color: <?php echo esc_attr( $cover_color ); ?>;
111 <?php endif; ?>
112 }
113 <?php
114 } else {
115 ?>
116 html.srfm-html {
117 margin-top: 0 !important;
118 /* make the background transparent for the sureforms/form block preview */
119 background-color: transparent;
120 /* Needs to be important to remove margin-top added by WordPress admin bar */
121 }
122 body.single.single-sureforms_form {
123 background-color: transparent;
124 }
125 .srfm-form-container~div,
126 .srfm-instant-form-wrn-ctn {
127 display: none !important;
128 /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
129 }
130 <?php
131 }
132 ?>
133 </style>
134 </head>
135
136 <body <?php body_class( $body_classes ); ?>>
137 <?php if ( ! $srfm_form_preview ) { ?>
138 <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo ! ! $single_page_form_title ? 'has-form-title' : ''; ?>">
139 <div class="srfm-page-banner">
140 <?php
141 if ( ! empty( $site_logo ) ) {
142 ?>
143 <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>">
144 <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>">
145 </a>
146 <?php
147 }
148
149 if ( ! empty( $single_page_form_title ) ) {
150 ?>
151 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
152 <?php
153 }
154
155 if ( empty( $enable_instant_form ) ) {
156 ?>
157 <div class="srfm-form-status-badge"><?php esc_html_e( 'Instant Form Disabled', 'sureforms' ); ?></div>
158 <?php
159 }
160 ?>
161 </div>
162 <div class="srfm-form-wrapper">
163 <?php
164 // phpcs:ignore
165 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' );
166 // phpcs:ignoreEnd
167 ?>
168 </div>
169 <?php
170 if ( ! defined( 'SRFM_PRO_VER' ) ) {
171 // Display SureForms branding if SureForms Pro is not activated.
172 echo wp_kses_post(
173 sprintf(
174 '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>',
175 esc_url( SRFM_WEBSITE ),
176 /* translators: Here %s is the plugin's name. */
177 sprintf( esc_html__( 'Crafted with ♡ %s', 'sureforms' ), 'SureForms' )
178 )
179 );
180 }
181 ?>
182 </div>
183 <?php } else { ?>
184 <?php
185 show_admin_bar( false );
186 // phpcs:ignore
187 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' );
188 // phpcs:ignoreEnd
189 }
190
191 wp_footer();
192
193 if ( $srfm_live_mode_data ) {
194 ?>
195 <script>
196 (function() {
197 document.addEventListener('DOMContentLoaded', function() {
198 document.querySelector('html').style.opacity = 1;
199 });
200 }());
201 </script>
202 <?php
203 }
204 ?>
205 </body>
206
207 </html>
208 <?php
209