PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 1.4.2
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v1.4.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 in SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz 1.4.2, at templates/single-form.php

223 lines 6.9 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( wp_unslash( $_GET['form_preview'] ) ) : false; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce verification is not required here.
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 // Filter to use custom bg image and color combination on the Instant Form page.
35 if ( apply_filters( 'srfm_use_color_or_image_as_bg', true ) ) {
36 if ( 'image' === $bg_type ) {
37 $bg_image = $bg_image ? 'url(' . $bg_image . ')' : '';
38 $bg_color = '#ffffff';
39 } else {
40 $bg_image = 'none';
41 $bg_color = $bg_color ? $bg_color : '';
42 }
43 }
44
45 $body_classes = [];
46
47 if ( $use_banner_as_page_background ) {
48 $body_classes[] = 'srfm-has-banner-page-bg';
49
50 if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) {
51 $body_classes[] = 'srfm-has-cover-img';
52 }
53 }
54
55 ?>
56 <!DOCTYPE html>
57 <html class="srfm-html" <?php language_attributes(); ?>>
58
59 <head>
60 <meta charset="<?php bloginfo( 'charset' ); ?>">
61 <meta http-equiv="x-ua-compatible" content="ie=edge">
62 <?php if ( ! wp_is_block_theme() ) { ?>
63 <meta name="viewport" content="width=device-width, initial-scale=1">
64 <?php
65 }
66 ?>
67 <style>
68 <?php
69 echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) );
70
71 if ( $srfm_live_mode_data ) {
72 ?>
73 html {
74 margin: 0 !important;
75 opacity: 0;
76 transition: all 0.5s ease-in-out;
77 }
78 #wpadminbar {
79 display: none;
80 }
81 body {
82 pointer-events: none;
83 }
84 <?php
85 }
86
87 if ( ! $srfm_form_preview ) {
88 ?>
89 body * {
90 /* Maintain consistent box-sizing for different themes. */
91 box-sizing: border-box;
92 }
93 #srfm-single-page-container {
94 --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>;
95 --srfm-bg-image: <?php echo $bg_image && is_string( $bg_image ) ? esc_html( $bg_image ) : ''; ?>;
96 --srfm-bg-color: <?php echo $bg_color && is_string( $bg_color ) ? esc_html( $bg_color ) : ''; ?>;
97 }
98 <?php
99 $selector = '.single-sureforms_form .srfm-single-page-container .srfm-page-banner';
100
101 if ( $use_banner_as_page_background ) {
102 $selector = 'html body.single-sureforms_form';
103 }
104 ?>
105 <?php echo esc_html( $selector ); ?> {
106 <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) { ?>
107 background-image: url(<?php echo esc_attr( $srfm_cover_image_url ); ?> );
108 background-position: center;
109 background-repeat: no-repeat;
110 background-size: cover;
111 <?php } else { ?>
112 background-color: <?php echo esc_attr( $cover_color ); ?>;
113 <?php } ?>
114 }
115 <?php
116 } else {
117 ?>
118 html.srfm-html {
119 margin-top: 0 !important;
120 /* make the background transparent for the sureforms/form block preview */
121 background-color: transparent;
122 /* Needs to be important to remove margin-top added by WordPress admin bar */
123 }
124 body.single.single-sureforms_form {
125 background-color: transparent;
126 }
127 .srfm-form-container~div,
128 .srfm-instant-form-wrn-ctn {
129 display: none !important;
130 /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
131 }
132 <?php
133 }
134 ?>
135 </style>
136
137 <?php wp_head(); ?>
138 </head>
139
140 <?php
141 // Filter to use custom body content on the Instant Form page.
142 if ( ! apply_filters( 'srfm_use_custom_body_template', false ) ) {
143 ?>
144 <body <?php body_class( $body_classes ); ?>>
145 <?php if ( ! $srfm_form_preview ) { ?>
146 <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo (bool) $single_page_form_title ? 'has-form-title' : ''; ?>">
147 <div class="srfm-page-banner">
148 <?php
149 if ( ! empty( $site_logo ) ) {
150 ?>
151 <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>">
152 <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>">
153 </a>
154 <?php
155 }
156
157 if ( ! empty( $single_page_form_title ) ) {
158 ?>
159 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
160 <?php
161 }
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 ( ! defined( 'SRFM_PRO_VER' ) ) {
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