| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package SureForms |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | +use SRFM\Inc\Compatibility\Multilingual\String_Translator; | |
| 8 | 9 | use SRFM\Inc\Generate_Form_Markup; |
| 9 | 10 | use SRFM\Inc\Helper; |
| 10 | 11 | |
| 11 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -11,10 +12,12 @@ | ||
| 11 | 12 | if ( ! defined( 'ABSPATH' ) ) { |
| 12 | 13 | exit; // Exit if accessed directly. |
| 13 | 14 | } |
| 14 | 15 | |
| 16 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- Template-scoped variables consumed only within this template, not true plugin globals. | |
| 17 | + | |
| 15 | 18 | $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 | |
| 19 | +$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 | 20 | $srfm_live_mode_data = Helper::get_instant_form_live_data(); |
| 18 | 21 | |
| 19 | 22 | $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 | 23 | $site_logo = $instant_form_settings['site_logo']; |
| @@ -19,9 +22,8 @@ | ||
| 19 | 22 | $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 | 23 | $site_logo = $instant_form_settings['site_logo']; |
| 21 | 24 | $bg_type = $instant_form_settings['bg_type']; |
| 22 | 25 | $bg_color = $instant_form_settings['bg_color']; |
| 23 | -$bg_image = $instant_form_settings['bg_image']; | |
| 24 | 26 | $cover_type = $instant_form_settings['cover_type']; |
| 25 | 27 | $cover_color = $instant_form_settings['cover_color']; |
| 26 | 28 | $cover_image = $instant_form_settings['cover_image']; |
| 27 | 29 | $enable_instant_form = $instant_form_settings['enable_instant_form']; |
| @@ -30,14 +32,15 @@ | ||
| 30 | 32 | $use_banner_as_page_background = $instant_form_settings['use_banner_as_page_background']; |
| 31 | 33 | |
| 32 | 34 | $srfm_cover_image_url = $cover_image ? rawurldecode( strval( $cover_image ) ) : ''; |
| 33 | 35 | |
| 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 : ''; | |
| 36 | +// Filter to use custom bg image and color combination on the Instant Form page. | |
| 37 | +if ( apply_filters( 'srfm_use_color_or_image_as_bg', true ) ) { | |
| 38 | + if ( 'image' === $bg_type ) { | |
| 39 | + $bg_color = '#ffffff'; | |
| 40 | + } else { | |
| 41 | + $bg_color = $bg_color ? $bg_color : ''; | |
| 42 | + } | |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | 45 | $body_classes = []; |
| 43 | 46 | |
| @@ -42,8 +45,12 @@ | ||
| 42 | 45 | $body_classes = []; |
| 43 | 46 | |
| 44 | 47 | if ( $use_banner_as_page_background ) { |
| 45 | 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 | + } | |
| 46 | 53 | } |
| 47 | 54 | |
| 48 | 55 | ?> |
| 49 | 56 | <!DOCTYPE html> |
| @@ -55,9 +62,8 @@ | ||
| 55 | 62 | <?php if ( ! wp_is_block_theme() ) { ?> |
| 56 | 63 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 57 | 64 | <?php |
| 58 | 65 | } |
| 59 | - wp_head(); | |
| 60 | 66 | ?> |
| 61 | 67 | <style> |
| 62 | 68 | <?php |
| 63 | 69 | echo wp_kses_post( Helper::get_meta_value( $srfm_custom_post_id, '_srfm_form_custom_css' ) ); |
| @@ -85,9 +91,8 @@ | ||
| 85 | 91 | box-sizing: border-box; |
| 86 | 92 | } |
| 87 | 93 | #srfm-single-page-container { |
| 88 | 94 | --srfm-form-container-width: <?php echo esc_attr( $form_container_width . 'px' ); ?>; |
| 89 | - --srfm-bg-image: <?php echo $bg_image && is_string( $bg_image ) ? esc_html( $bg_image ) : ''; ?>; | |
| 90 | 95 | --srfm-bg-color: <?php echo $bg_color && is_string( $bg_color ) ? esc_html( $bg_color ) : ''; ?>; |
| 91 | 96 | } |
| 92 | 97 | <?php |
| 93 | 98 | $selector = '.single-sureforms_form .srfm-single-page-container .srfm-page-banner'; |
| @@ -96,16 +101,19 @@ | ||
| 96 | 101 | $selector = 'html body.single-sureforms_form'; |
| 97 | 102 | } |
| 98 | 103 | ?> |
| 99 | 104 | <?php echo esc_html( $selector ); ?> { |
| 100 | - <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) : ?> | |
| 105 | + <?php if ( 'image' === $cover_type && ! empty( $srfm_cover_image_url ) ) { ?> | |
| 101 | 106 | background-image: url(<?php echo esc_attr( $srfm_cover_image_url ); ?> ); |
| 102 | 107 | background-position: center; |
| 103 | 108 | background-repeat: no-repeat; |
| 104 | 109 | background-size: cover; |
| 105 | - <?php else : ?> | |
| 110 | + <?php if ( $use_banner_as_page_background ) { ?> | |
| 111 | + background-attachment: fixed; | |
| 112 | + <?php } ?> | |
| 113 | + <?php } else { ?> | |
| 106 | 114 | background-color: <?php echo esc_attr( $cover_color ); ?>; |
| 107 | - <?php endif; ?> | |
| 115 | + <?php } ?> | |
| 108 | 116 | } |
| 109 | 117 | <?php |
| 110 | 118 | } else { |
| 111 | 119 | ?> |
| @@ -126,79 +134,91 @@ | ||
| 126 | 134 | <?php |
| 127 | 135 | } |
| 128 | 136 | ?> |
| 129 | 137 | </style> |
| 138 | + | |
| 139 | + <?php wp_head(); ?> | |
| 130 | 140 | </head> |
| 131 | 141 | |
| 132 | -<body <?php body_class( $body_classes ); ?>> | |
| 133 | - <?php if ( ! $srfm_form_preview ) { ?> | |
| 134 | - <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo ! ! $single_page_form_title ? 'has-form-title' : ''; ?>"> | |
| 135 | - <div class="srfm-page-banner"> | |
| 136 | - <?php | |
| 137 | - if ( ! empty( $site_logo ) ) { | |
| 138 | - ?> | |
| 139 | - <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>"> | |
| 140 | - <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>"> | |
| 141 | - </a> | |
| 142 | - <?php | |
| 143 | - } | |
| 142 | + <?php | |
| 143 | + // Filter to use custom body content on the Instant Form page. | |
| 144 | + if ( ! apply_filters( 'srfm_use_custom_body_template', false ) ) { | |
| 145 | + ?> | |
| 146 | + <body <?php body_class( $body_classes ); ?>> | |
| 147 | + <?php if ( ! $srfm_form_preview ) { ?> | |
| 148 | + <div id="srfm-single-page-container" class="srfm-single-page-container <?php echo (bool) $single_page_form_title ? 'has-form-title' : ''; ?>"> | |
| 149 | + <div class="srfm-page-banner"> | |
| 150 | + <?php | |
| 151 | + if ( ! empty( $site_logo ) ) { | |
| 152 | + ?> | |
| 153 | + <a href="<?php echo esc_url( home_url() ); ?>" aria-label="<?php esc_attr_e( 'Link to homepage', 'sureforms' ); ?>"> | |
| 154 | + <img class="srfm-site-logo" src="<?php echo esc_url( $site_logo ); ?>" alt="<?php esc_attr_e( 'Instant form site logo', 'sureforms' ); ?>"> | |
| 155 | + </a> | |
| 156 | + <?php | |
| 157 | + } | |
| 144 | 158 | |
| 145 | - if ( ! empty( $single_page_form_title ) ) { | |
| 146 | - ?> | |
| 147 | - <h1 class="srfm-single-banner-title"><?php echo esc_html( get_the_title() ); ?></h1> | |
| 159 | + if ( ! empty( $single_page_form_title ) ) { | |
| 160 | + $srfm_banner_title = String_Translator::get_instance()->translate_form_title( (int) get_the_ID(), Helper::get_string_value( get_the_title() ) ); | |
| 161 | + ?> | |
| 162 | + <h1 class="srfm-single-banner-title"><?php echo esc_html( $srfm_banner_title ); ?></h1> | |
| 163 | + <?php | |
| 164 | + } | |
| 165 | + ?> | |
| 166 | + </div> | |
| 167 | + <div class="srfm-form-wrapper"> | |
| 168 | + <?php | |
| 169 | + // phpcs:ignore | |
| 170 | + echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' ); | |
| 171 | + // phpcs:ignoreEnd | |
| 172 | + ?> | |
| 173 | + </div> | |
| 148 | 174 | <?php |
| 149 | - } | |
| 150 | - | |
| 151 | - if ( empty( $enable_instant_form ) ) { | |
| 175 | + if ( ! Helper::has_pro() ) { | |
| 176 | + // Display SureForms branding if SureForms Pro is not activated. | |
| 177 | + echo wp_kses_post( | |
| 178 | + sprintf( | |
| 179 | + '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>', | |
| 180 | + esc_url( SRFM_WEBSITE ), | |
| 181 | + /* translators: Here %s is the plugin's name. */ | |
| 182 | + sprintf( esc_html__( 'Crafted with ♡ %s', 'sureforms' ), 'SureForms' ) | |
| 183 | + ) | |
| 184 | + ); | |
| 185 | + } | |
| 152 | 186 | ?> |
| 153 | - <div class="srfm-form-status-badge"><?php esc_html_e( 'Instant Form Disabled', 'sureforms' ); ?></div> | |
| 154 | - <?php | |
| 155 | - } | |
| 156 | - ?> | |
| 157 | - </div> | |
| 158 | - <div class="srfm-form-wrapper"> | |
| 187 | + </div> | |
| 188 | + <?php } else { ?> | |
| 159 | 189 | <?php |
| 190 | + show_admin_bar( false ); | |
| 160 | 191 | // phpcs:ignore |
| 161 | - echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, '', 'sureforms_form' ); | |
| 192 | + echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' ); | |
| 162 | 193 | // phpcs:ignoreEnd |
| 163 | - ?> | |
| 164 | - </div> | |
| 165 | - <?php | |
| 166 | - if ( ! defined( 'SRFM_PRO_VER' ) ) { | |
| 167 | - // Display SureForms branding if SureForms Pro is not activated. | |
| 168 | - echo wp_kses_post( | |
| 169 | - sprintf( | |
| 170 | - '<a href="%1$s" class="srfm-branding" target="_blank">%2$s</a>', | |
| 171 | - esc_url( SRFM_WEBSITE ), | |
| 172 | - /* translators: Here %s is the plugin's name. */ | |
| 173 | - sprintf( esc_html__( 'Crafted with ♡ %s', 'sureforms' ), 'SureForms' ) | |
| 174 | - ) | |
| 175 | - ); | |
| 176 | - } | |
| 177 | - ?> | |
| 178 | - </div> | |
| 179 | - <?php } else { ?> | |
| 194 | + } | |
| 195 | + wp_footer(); | |
| 196 | + ?> | |
| 197 | + </body> | |
| 180 | 198 | <?php |
| 181 | - show_admin_bar( false ); | |
| 182 | - // phpcs:ignore | |
| 183 | - echo Generate_Form_Markup::get_form_markup( $srfm_custom_post_id, false, 'sureforms_form' ); | |
| 184 | - // phpcs:ignoreEnd | |
| 185 | 199 | } |
| 186 | 200 | |
| 187 | - wp_footer(); | |
| 201 | + if ( ! $srfm_form_preview && empty( $enable_instant_form ) ) { | |
| 202 | + ?> | |
| 203 | + <div class="srfm-form-status-badge"><?php esc_html_e( 'Instant Form Disabled', 'sureforms' ); ?></div> | |
| 204 | + <?php | |
| 205 | + } | |
| 188 | 206 | |
| 207 | + // Action to load custom body content on the Instant Form page. | |
| 208 | + do_action( 'srfm_after_instant_form_body', $srfm_custom_post_id, $instant_form_settings, $body_classes ); | |
| 209 | + | |
| 189 | 210 | if ( $srfm_live_mode_data ) { |
| 190 | 211 | ?> |
| 191 | - <script> | |
| 192 | - (function() { | |
| 193 | - document.addEventListener('DOMContentLoaded', function() { | |
| 194 | - document.querySelector('html').style.opacity = 1; | |
| 195 | - }); | |
| 196 | - }()); | |
| 197 | - </script> | |
| 212 | + <script> | |
| 213 | + (function() { | |
| 214 | + document.addEventListener('DOMContentLoaded', function() { | |
| 215 | + document.querySelector('html').style.opacity = 1; | |
| 216 | + }); | |
| 217 | + }()); | |
| 218 | + </script> | |
| 198 | 219 | <?php |
| 199 | 220 | } |
| 200 | 221 | ?> |
| 201 | -</body> | |
| 202 | 222 | |
| 203 | 223 | </html> |
| 204 | 224 | <?php |