PluginProbe
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz / 0.0.3
SureForms – Contact Form Builder, AI Forms, Payment Form, Survey & Quiz v0.0.3
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
164 lines 7.2 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\SRFM_Generate_Form_Markup;
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit; // Exit if accessed directly.
12 }
13
14 $srfm_form_preview = '';
15
16 $srfm_form_preview_attr = isset( $_GET['form_preview'] ) ? sanitize_text_field( wp_unslash( $_GET['form_preview'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
17
18 if ( $srfm_form_preview_attr ) {
19 $srfm_form_preview = filter_var( $srfm_form_preview_attr, FILTER_VALIDATE_BOOLEAN );
20 }
21
22 ?>
23 <!DOCTYPE html>
24 <html class="srfm-html" <?php language_attributes(); ?>>
25 <head>
26 <meta charset="<?php bloginfo( 'charset' ); ?>">
27 <meta http-equiv="x-ua-compatible" content="ie=edge">
28 <?php wp_head(); ?>
29 </head>
30 <body <?php body_class(); ?>>
31 <?php
32 $srfm_custom_post_id = get_the_ID();
33 $srfm_color1_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_color1', true );
34 $srfm_bg_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_bg_image', true );
35 $srfm_fontsize_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_fontsize', true );
36 $srfm_submit_type_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_type', true );
37 $srfm_thankyou_message_title = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_thankyou_message_title', true );
38 $srfm_thankyou_message_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_thankyou_message', true );
39 $srfm_submit_url_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_url', true );
40 $srfm_form_container_width = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_form_container_width', true ) ? strval( get_post_meta( intval( $srfm_custom_post_id ), '_srfm_form_container_width', true ) ) : 650;
41 $srfm_submit_button_text = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_button_text', true );
42 $srfm_show_title_on_single_form_page = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_single_page_form_title', true ) ? strval( get_post_meta( intval( $srfm_custom_post_id ), '_srfm_single_page_form_title', true ) ) : '';
43
44 $srfm_color_primary = $srfm_color1_val ? strval( $srfm_color1_val ) : '#0284c7';
45 $srfm_background_image_url = $srfm_bg_val ? rawurldecode( strval( $srfm_bg_val ) ) : '';
46 $srfm_form_font_size = $srfm_fontsize_val ? $srfm_fontsize_val : '';
47 $srfm_success_submit_type = $srfm_submit_type_val ? strval( $srfm_submit_type_val ) : '';
48 $srfm_success_message_title = $srfm_thankyou_message_title ? strval( $srfm_thankyou_message_title ) : '';
49 $srfm_success_message = $srfm_thankyou_message_val ? strval( $srfm_thankyou_message_val ) : '';
50 $srfm_success_url = $srfm_submit_url_val ? strval( $srfm_submit_url_val ) : '';
51
52 // Submit button.
53 $srfm_button_text = $srfm_submit_button_text ? strval( $srfm_submit_button_text ) : '';
54 $srfm_button_alignment = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_alignment', true ) ? strval( get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_alignment', true ) ) : '';
55
56 if ( ! $srfm_form_preview ) {
57
58
59
60 if ( 'justify' === $srfm_button_alignment ) {
61 $srfm_full = true;
62 } else {
63 $srfm_full = false;
64 }
65
66 $srfm_recaptcha_version = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_form_recaptcha', true ) ? strval( get_post_meta( intval( $srfm_custom_post_id ), '_srfm_form_recaptcha', true ) ) : '';
67 $srfm_google_captcha_site_key = '';
68 switch ( $srfm_recaptcha_version ) {
69 case 'v2-checkbox':
70 $srfm_google_captcha_site_key = ! empty( get_option( 'srfm_v2_checkbox_site' ) ) ? strval( get_option( 'srfm_v2_checkbox_site' ) ) : '';
71 break;
72 case 'v2-invisible':
73 $srfm_google_captcha_site_key = ! empty( get_option( 'srfm_v2_invisible_site' ) ) ? strval( get_option( 'srfm_v2_invisible_site' ) ) : '';
74 break;
75 case 'v3-reCAPTCHA':
76 $srfm_google_captcha_site_key = ! empty( get_option( 'srfm_v3_site' ) ) ? strval( get_option( 'srfm_v3_site' ) ) : '';
77 break;
78 default:
79 break;
80 }
81 ?>
82 <style>
83 #srfm-single-page-container {
84 --srfm-form-container-width:
85 <?php
86 echo esc_attr( $srfm_form_container_width . 'px' );
87 ?>
88 }
89 </style>
90 <div id="srfm-single-page-container" class="srfm-single-page-container">
91 <div class="srfm-page-banner" style="background-color: <?php echo esc_attr( $srfm_color_primary ); ?>">
92 <?php if ( '1' !== $srfm_show_title_on_single_form_page ) : ?>
93 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
94 <?php endif; ?>
95 </div>
96 <div class="srfm-form-wrapper">
97 <?php
98 // phpcs:ignore
99 echo SRFM_Generate_Form_Markup::get_form_markup( absint( $srfm_custom_post_id ), false,'', 'sureforms_form' );
100 // phpcs:ignoreEnd
101 ?>
102 <div id="srfm-success-message-page-<?php echo esc_attr( $srfm_custom_post_id ); ?>" style="height:0; opacity:0; min-height:0;" class="srfm-single-form srfm-success-box in-page">
103 <i class="fa-regular fa-circle-check"></i>
104 <article class="srfm-success-box-header">
105 <?php echo esc_html( $srfm_success_message_title ); ?>
106 </article>
107 <article class="srfm-success-box-subtxt srfm-text-gray-900">
108 <?php echo esc_html( $srfm_success_message ); ?>
109 </article>
110 </div>
111 <?php
112 if ( isset( $srfm_success_message ) && isset( $srfm_success_message_title ) ) {
113 ?>
114 <div id="srfm-success-message-page-<?php echo esc_attr( $srfm_custom_post_id ); ?>" style="display:none;" class="srfm-single-form srfm-success-box">
115 <i class="fa-regular fa-circle-check"></i>
116 <article class="srfm-success-box-header">
117 <?php echo esc_html( $srfm_success_message_title ); ?>
118 </article>
119 <article class="srfm-success-box-subtxt srfm-text-gray-900">
120 <?php echo esc_html( $srfm_success_message ); ?>
121 </article>
122 </div>
123 <?php
124 }
125 ?>
126 <p id="srfm-error-message" class="srfm-error-message" hidden="true"><?php echo esc_attr__( 'There was an error trying to submit your form. Please try again.', 'sureforms' ); ?></p>
127 <?php
128 $srfm_page_url = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
129 $srfm_page_path = strval( wp_parse_url( $srfm_page_url, PHP_URL_PATH ) );
130 $srfm_segments = explode( '/', $srfm_page_path );
131 $srfm_form_path = isset( $srfm_segments[1] ) ? $srfm_segments[1] : '';
132 wp_footer();
133 ?>
134 </div>
135 </div>
136
137 <?php } else { ?>
138 <style>
139 html.srfm-html {
140 margin-top: 0 !important; /* Needs to be important to remove margin-top added by WordPress admin bar */
141 }
142
143 body.single.single-sureforms_form {
144 background-color: transparent;
145 }
146
147 .srfm-form-container ~ div, .srfm-instant-form-wrn-ctn {
148 display: none !important; /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
149 }
150 </style>
151 <?php
152
153 show_admin_bar( false );
154
155 // phpcs:ignore
156 echo SRFM_Generate_Form_Markup::get_form_markup( absint( $srfm_custom_post_id ), false, 'sureforms_form' );
157 // phpcs:ignoreEnd
158
159 wp_footer();
160 }
161 ?>
162 </body>
163 </html>
164