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

158 lines 7.0 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_form_preview = '';
16
17 $srfm_form_preview_attr = isset( $_GET['form_preview'] ) ? sanitize_text_field( wp_unslash( $_GET['form_preview'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
18
19 if ( $srfm_form_preview_attr ) {
20 $srfm_form_preview = filter_var( $srfm_form_preview_attr, FILTER_VALIDATE_BOOLEAN );
21 }
22
23 ?>
24 <!DOCTYPE html>
25 <html class="srfm-html" <?php language_attributes(); ?>>
26 <head>
27 <meta charset="<?php bloginfo( 'charset' ); ?>">
28 <meta http-equiv="x-ua-compatible" content="ie=edge">
29 <?php wp_head(); ?>
30 <?php
31 $srfm_custom_post_id = get_the_ID();
32 $form_custom_css_meta = get_post_meta( $srfm_custom_post_id, '_srfm_form_custom_css', true );
33 $custom_css = ! empty( $form_custom_css_meta ) && is_string( $form_custom_css_meta ) ? $form_custom_css_meta : '';
34 ?>
35 <style>
36 <?php echo wp_kses_post( $custom_css ); ?>
37 </style>
38 </head>
39 <body <?php body_class(); ?>>
40 <?php
41 $srfm_color1_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_color1', true );
42 $srfm_bg_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_bg_image', true );
43 $srfm_fontsize_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_fontsize', true );
44 $srfm_submit_type_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_type', true );
45 $srfm_thankyou_message_title = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_thankyou_message_title', true );
46 $srfm_thankyou_message_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_thankyou_message', true );
47 $srfm_submit_url_val = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_url', true );
48 $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;
49 $srfm_submit_button_text = get_post_meta( intval( $srfm_custom_post_id ), '_srfm_submit_button_text', true );
50 $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 ) ) : '';
51 $show_title = 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 ) ) : '';
52 $instant_form = Helper::get_meta_value( $srfm_custom_post_id, '_srfm_instant_form' );
53
54 $srfm_color_primary = $srfm_color1_val ? strval( $srfm_color1_val ) : '#0284c7';
55 $srfm_background_image_url = $srfm_bg_val ? rawurldecode( strval( $srfm_bg_val ) ) : '';
56 $srfm_form_font_size = $srfm_fontsize_val ? $srfm_fontsize_val : '';
57 $srfm_success_submit_type = $srfm_submit_type_val ? strval( $srfm_submit_type_val ) : '';
58 $srfm_success_message_title = $srfm_thankyou_message_title ? strval( $srfm_thankyou_message_title ) : '';
59 $srfm_success_message = $srfm_thankyou_message_val ? strval( $srfm_thankyou_message_val ) : '';
60 $srfm_success_url = $srfm_submit_url_val ? strval( $srfm_submit_url_val ) : '';
61
62 // Submit button.
63 $srfm_button_text = $srfm_submit_button_text ? strval( $srfm_submit_button_text ) : '';
64 $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 ) ) : '';
65
66 if ( ! $srfm_form_preview ) {
67
68
69
70 if ( 'justify' === $srfm_button_alignment ) {
71 $srfm_full = true;
72 } else {
73 $srfm_full = false;
74 }
75 ?>
76 <style>
77 #srfm-single-page-container {
78 --srfm-form-container-width:
79 <?php
80 echo esc_attr( $srfm_form_container_width . 'px' );
81 ?>
82 }
83 </style>
84 <div id="srfm-single-page-container" class="srfm-single-page-container">
85 <div class="srfm-page-banner" style="background-color: <?php echo esc_attr( $srfm_color_primary ); ?>">
86 <?php if ( ! empty( $show_title ) && ! empty( $instant_form ) ) : ?>
87 <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1>
88 <?php endif; ?>
89 </div>
90 <div class="srfm-form-wrapper">
91 <?php
92 // phpcs:ignore
93 echo Generate_Form_Markup::get_form_markup( absint( $srfm_custom_post_id ), false,'', 'sureforms_form' );
94 // phpcs:ignoreEnd
95 ?>
96 <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">
97 <i class="fa-regular fa-circle-check"></i>
98 <article class="srfm-success-box-header">
99 <?php echo esc_html( $srfm_success_message_title ); ?>
100 </article>
101 <article class="srfm-success-box-subtxt srfm-text-gray-900">
102 <?php echo esc_html( $srfm_success_message ); ?>
103 </article>
104 </div>
105 <?php
106 if ( isset( $srfm_success_message ) && isset( $srfm_success_message_title ) ) {
107 ?>
108 <div id="srfm-success-message-page-<?php echo esc_attr( $srfm_custom_post_id ); ?>" style="display:none;" class="srfm-single-form srfm-success-box">
109 <i class="fa-regular fa-circle-check"></i>
110 <article class="srfm-success-box-header">
111 <?php echo esc_html( $srfm_success_message_title ); ?>
112 </article>
113 <article class="srfm-success-box-subtxt srfm-text-gray-900">
114 <?php echo esc_html( $srfm_success_message ); ?>
115 </article>
116 </div>
117 <?php
118 }
119 ?>
120 <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>
121 <?php
122 $srfm_page_url = isset( $_SERVER['REQUEST_URI'] ) ? sanitize_text_field( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '';
123 $srfm_page_path = strval( wp_parse_url( $srfm_page_url, PHP_URL_PATH ) );
124 $srfm_segments = explode( '/', $srfm_page_path );
125 $srfm_form_path = isset( $srfm_segments[1] ) ? $srfm_segments[1] : '';
126 wp_footer();
127 ?>
128 </div>
129 </div>
130
131 <?php } else { ?>
132 <style>
133 html.srfm-html {
134 margin-top: 0 !important; /* Needs to be important to remove margin-top added by WordPress admin bar */
135 }
136
137 body.single.single-sureforms_form {
138 background-color: transparent;
139 }
140
141 .srfm-form-container ~ div, .srfm-instant-form-wrn-ctn {
142 display: none !important; /* Needs to be important to remove any blocks added by external plugins in wp_footer() */
143 }
144 </style>
145 <?php
146
147 show_admin_bar( false );
148
149 // phpcs:ignore
150 echo Generate_Form_Markup::get_form_markup( absint( $srfm_custom_post_id ), false, 'sureforms_form' );
151 // phpcs:ignoreEnd
152
153 wp_footer();
154 }
155 ?>
156 </body>
157 </html>
158