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

221 lines 6.7 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 $cover_type = $instant_form_settings['cover_type'];
24 $cover_color = $instant_form_settings['cover_color'];
25 $cover_image = $instant_form_settings['cover_image'];
26 $enable_instant_form = $instant_form_settings['enable_instant_form'];
27 $form_container_width = $instant_form_settings['form_container_width'];
28 $single_page_form_title = $instant_form_settings['single_page_form_title'];
29 $use_banner_as_page_background = $instant_form_settings['use_banner_as_page_background'];
30
31 $srfm_cover_image_url = $cover_image ? rawurldecode( strval( $cover_image ) ) : '';
32
33 // Filter to use custom bg image and color combination on the Instant Form page.
34 if ( apply_filters( 'srfm_use_color_or_image_as_bg', true ) ) {
35 if ( 'image' === $bg_type ) {
36 $bg_color = '#ffffff';
37 } else {
38 $bg_color = $bg_color ? $bg_color : '';
39 }
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 ?>
64 <style>
65 <?php
66 echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) );
67
68 if ( $srfm_live_mode_data ) {
69 ?>
70 html {
71 margin: 0 !important;
72 opacity: 0;
73 transition: all 0.5s ease-in-out;
74 }
75 #wpadminbar {
76 display: none;
77 }
78 body {
79 pointer-events: none;
80 }
81 <?php
82 }
83
84 if ( ! $srfm_form_preview ) {
85 ?>
86 body * {
87 /* Maintain consistent box-sizing for different themes. */
88 box-sizing: border-box;
89 }
90 #srfm-single-page-container {
91 --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>;
92 --srfm-bg-color: <?php echo $bg_color && is_string( $bg_color ) ? esc_html( $bg_color ) : ''; ?>;
93 }
94 <?php
95 $selector = '.single-sureforms_form .srfm-single-page-container .srfm-page-banner';
96
97 if ( $use_banner_as_page_background ) {
98 $selector = 'html body.single-sureforms_form';
99 }
100 ?>
101 <?php echo esc_html( $selector ); ?> {
102 <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) { ?>
103 background-image: url(<?php echo esc_attr( $srfm_cover_image_url ); ?> );
104 background-position: center;
105 background-repeat: no-repeat;
106 background-size: cover;
107 <?php if ( $use_banner_as_page_background ) { ?>
108 background-attachment: fixed;
109 <?php } ?>
110 <?php } else { ?>
111 background-color: <?php echo esc_attr( $cover_color ); ?>;
112 <?php } ?>
113 }
114 <?php
115 } else {
116 ?>
117 html.srfm-html {
118 margin-top: 0 !important;
119 /* make the background transparent for the sureforms/form block preview */
120 background-color: transparent;
121 /* Needs to be important to remove margin-top added by WordPress admin bar */
122 }
123 body.single.single-sureforms_form {
124 background-color: transparent;
125 }
126 .srfm-form-container~div,
127 .srfm-instant-form-wrn-ctn {
128 display: none !important;
129 /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
130 }
131 <?php
132 }
133 ?>
134 </style>
135
136 <?php wp_head(); ?>
137 </head>
138
139 <?php
140 // Filter to use custom body content on the Instant Form page.
141 if ( ! apply_filters( 'srfm_use_custom_body_template', false ) ) {
142 ?>
143 <body <?php body_class( $body_classes ); ?>>
144 <?php if ( ! $srfm_form_preview ) { ?>
145 <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo (bool) $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 </div>
163 <div class="srfm-form-wrapper">
164 <?php
165 // phpcs:ignore
166 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' );
167 // phpcs:ignoreEnd
168 ?>
169 </div>
170 <?php
171 if ( ! Helper::has_pro() ) {
172 // Display SureForms branding if SureForms Pro is not activated.
173 echo wp_kses_post(
174 sprintf(
175 '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>',
176 esc_url( SRFM_WEBSITE ),
177 /* translators: Here %s is the plugin's name. */
178 sprintf( esc_html__( 'Crafted with ♡ %s', 'sureforms' ), 'SureForms' )
179 )
180 );
181 }
182 ?>
183 </div>
184 <?php } else { ?>
185 <?php
186 show_admin_bar( false );
187 // phpcs:ignore
188 echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' );
189 // phpcs:ignoreEnd
190 }
191 wp_footer();
192 ?>
193 </body>
194 <?php
195 }
196
197 if ( ! $srfm_form_preview && empty( $enable_instant_form ) ) {
198 ?>
199 <div class="srfm-form-status-badge"><?php esc_html_e( 'Instant Form Disabled', 'sureforms' ); ?></div>
200 <?php
201 }
202
203 // Action to load custom body content on the Instant Form page.
204 do_action( 'srfm_after_instant_form_body', $srfm_custom_post_id, $instant_form_settings, $body_classes );
205
206 if ( $srfm_live_mode_data ) {
207 ?>
208 <script>
209 (function() {
210 document.addEventListener('DOMContentLoaded', function() {
211 document.querySelector('html').style.opacity = 1;
212 });
213 }());
214 </script>
215 <?php
216 }
217 ?>
218
219 </html>
220 <?php
221