PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.10
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.10
2.12.8 2.12.7 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 All 98 releases
sureforms / templates / single-form.php

single-form.php in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 0.0.10, at templates/single-form.php

216 lines 6.5 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 ?>
43 <!DOCTYPE html>
44 <html class="srfm-html" <?php language_attributes(); ?>>
45
46 <head>
47 <meta charset="<?php bloginfo( 'charset' ); ?>">
48 <meta http-equiv="x-ua-compatible" content="ie=edge">
49 <?php if ( ! wp_is_block_theme() ) { ?>
50 <meta name="viewport" content="width=device-width, initial-scale=1">
51 <?php
52 }
53 wp_head();
54 ?>
55 <style>
56 <?php
57 echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) );
58
59 if ( $srfm_live_mode_data ) {
60 ?>
61 html {
62 margin: 0 !important;
63 opacity: 0;
64 transition: all 0.5s ease-in-out;
65 }
66 #wpadminbar {
67 display: none;
68 }
69 body {
70 pointer-events: none;
71 }
72 <?php
73 }
74
75 if ( ! $srfm_form_preview ) {
76 ?>
77 body * {
78 /* Maintain consistent box-sizing for different themes. */
79 box-sizing: border-box;
80 }
81 #srfm-single-page-container {
82 --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>;
83 --srfm-bg-image: <?php echo $bg_image && is_string( $bg_image ) ? esc_html( $bg_image ) : ''; ?>;
84 --srfm-bg-color: <?php echo $bg_color && is_string( $bg_color ) ? esc_html( $bg_color ) : ''; ?>;
85 }
86 <?php
87 $selector = '.single-sureforms_form .srfm-single-page-container .srfm-page-banner';
88
89 if ( $use_banner_as_page_background ) {
90 $selector = 'html body.single-sureforms_form';
91 }
92 ?>
93 <?php echo esc_html( $selector ); ?> {
94 <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) : ?>
95 background-image: url(<?php echo esc_attr( $srfm_cover_image_url ); ?> );
96 background-position: center;
97 background-repeat: no-repeat;
98 background-size: cover;
99 <?php else : ?>
100 background-color: <?php echo esc_attr( $cover_color ); ?>;
101 <?php endif; ?>
102 }
103 <?php
104 if ( $use_banner_as_page_background ) {
105 // Some special edge case css when banner as page background enabled.
106 ?>
107 .single-sureforms_form .srfm-single-page-container.has-form-title .srfm-page-banner {
108 height: 172px;
109 }
110 .single-sureforms_form .srfm-single-page-container .srfm-page-banner {
111 height: 112px;
112 padding-bottom: 60px;
113 }
114 .single-sureforms_form .srfm-single-page-container .srfm-form-wrapper {
115 padding-bottom: 100px;
116 height: 100%;
117 }
118 .single-sureforms_form .srfm-single-page-container .srfm-form-wrapper .srfm-form-container {
119 position: static;
120 }
121 <?php
122 }
123 } else {
124 ?>
125 html.srfm-html {
126 margin-top: 0 !important;
127 /* Needs to be important to remove margin-top added by WordPress admin bar */
128 }
129 body.single.single-sureforms_form {
130 background-color: transparent;
131 }
132 .srfm-form-container~div,
133 .srfm-instant-form-wrn-ctn {
134 display: none !important;
135 /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
136 }
137 <?php
138 }
139 ?>
140 </style>
141 </head>
142
143 <body <?php body_class(); ?>>
144 <?php if ( ! $srfm_form_preview ) { ?>
145 <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo ! ! $single_page_form_title ? 'has-form-title' : ''; ?>">
146 <div class="srfm-page-banner">
147 <?php
148 if ( ! empty( $site_logo ) ) {
149 ?>
150 <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>">
151 <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>">
152 </a>
153 <?php
154 }
155
156 if ( ! empty( $single_page_form_title ) ) {
157 ?>
158 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
159 <?php
160 }
161
162 if ( empty( $enable_instant_form ) ) {
163 ?>
164 <div class="srfm-form-status-badge"><?php esc_html_e( 'Unpublished', 'sureforms' ); ?></div>
165 <?php
166 }
167 ?>
168 </div>
169 <div class="srfm-form-wrapper">
170 <?php
171 // phpcs:ignore
172 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' );
173 // phpcs:ignoreEnd
174 ?>
175 </div>
176 <?php
177 if ( ! defined( 'SRFM_PRO_VER' ) ) {
178 // Display SureForms branding if SureForms Pro is not activated.
179 echo wp_kses_post(
180 sprintf(
181 '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>',
182 esc_url( SRFM_WEBSITE ),
183 /* translators: Here %s is the plugin's name. */
184 sprintf( esc_html__( 'Powered By %s', 'sureforms' ), 'SureForms' )
185 )
186 );
187 }
188 ?>
189 </div>
190 <?php } else { ?>
191 <?php
192 show_admin_bar( false );
193 // phpcs:ignore
194 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' );
195 // phpcs:ignoreEnd
196 }
197
198 wp_footer();
199
200 if ( $srfm_live_mode_data ) {
201 ?>
202 <script>
203 (function() {
204 document.addEventListener('DOMContentLoaded', function() {
205 document.querySelector('html').style.opacity = 1;
206 });
207 }());
208 </script>
209 <?php
210 }
211 ?>
212 </body>
213
214 </html>
215 <?php
216