| @@ -7,9 +7,8 @@ | ||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | namespace SRFM\Inc\Fields; |
| 10 | 10 | |
| 11 | -use SRFM\Inc\Generate_Form_Markup; | |
| 12 | 11 | use SRFM\Inc\Helper; |
| 13 | 12 | |
| 14 | 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 15 | 14 | exit; // Exit if accessed directly. |
| @@ -119,9 +118,9 @@ | ||
| 119 | 118 | $this->set_properties( $attributes ); |
| 120 | 119 | $this->slug = 'inline-button'; |
| 121 | 120 | $this->button_text = $attributes['buttonText'] ?? ''; |
| 122 | 121 | $this->btn_from_theme = Helper::get_meta_value( $this->form_id, '_srfm_inherit_theme_button' ); |
| 123 | - $page_break_settings = Helper::has_pro() ? get_post_meta( (int) $this->form_id, '_srfm_page_break_settings', true ) : []; | |
| 122 | + $page_break_settings = defined( 'SRFM_PRO_VER' ) ? get_post_meta( (int) $this->form_id, '_srfm_page_break_settings', true ) : []; | |
| 124 | 123 | $page_break_settings = is_array( $page_break_settings ) ? $page_break_settings : []; |
| 125 | 124 | $this->is_page_break = $page_break_settings['is_page_break'] ?? false; |
| 126 | 125 | $this->captcha_security_type = Helper::get_meta_value( $this->form_id, '_srfm_captcha_security_type' ); |
| 127 | 126 | $this->recaptcha_version = Helper::get_meta_value( $this->form_id, '_srfm_form_recaptcha' ); |
| @@ -172,17 +171,17 @@ | ||
| 172 | 171 | <?php if ( ! $this->is_page_break ) { ?> |
| 173 | 172 | <?php if ( $this->captcha_security_type && 'none' !== $this->captcha_security_type ) { ?> |
| 174 | 173 | <div class="srfm-captcha-container <?php echo esc_attr( $container_hidden_class ); ?>"> |
| 175 | 174 | <?php if ( 'g-recaptcha' === $this->captcha_security_type && 'v2-checkbox' === $this->recaptcha_version ) { ?> |
| 176 | - <div class='g-recaptcha' data-callback='onSuccess' data-error-callback='onGCaptchaV2CheckBoxError' recaptcha-type='<?php echo esc_attr( $this->recaptcha_version ); ?>' data-sitekey='<?php echo esc_attr( strval( $this->google_captcha_site_key ) ); ?>'></div> | |
| 175 | + <?php echo "<div class='g-recaptcha' data-callback='onSuccess' data-error-callback='onGCaptchaV2CheckBoxError' recaptcha-type='" . esc_attr( $this->recaptcha_version ) . "' data-sitekey='" . esc_attr( strval( $this->google_captcha_site_key ) ) . "'></div>"; ?> | |
| 177 | 176 | <?php } ?> |
| 178 | 177 | <?php if ( 'cf-turnstile' === $this->captcha_security_type && $this->cf_turnstile_site_key ) { ?> |
| 179 | - <div id='srfm-cf-sitekey' class='cf-turnstile' data-callback='onSuccess' data-error-callback='onTurnstileError' data-theme='<?php echo esc_attr( strval( $this->cf_appearance_mode ) ); ?>' data-sitekey='<?php echo esc_attr( strval( $this->cf_turnstile_site_key ) ); ?>'></div> | |
| 178 | + <?php echo "<div id='srfm-cf-sitekey' class='cf-turnstile' data-callback='onSuccess' data-error-callback='onTurnstileError' data-theme='" . esc_attr( strval( $this->cf_appearance_mode ) ) . "' data-sitekey='" . esc_attr( strval( $this->cf_turnstile_site_key ) ) . "'></div>"; ?> | |
| 180 | 179 | <?php } ?> |
| 181 | 180 | <?php if ( 'hcaptcha' === $this->captcha_security_type && $this->hcaptcha_site_key ) { ?> |
| 182 | - <div id='srfm-hcaptcha-sitekey' data-callback='onSuccess' data-error-callback='onHCaptchaError' class='h-captcha' data-sitekey='<?php echo esc_attr( strval( $this->hcaptcha_site_key ) ); ?>'></div> | |
| 181 | + <?php echo "<div id='srfm-hcaptcha-sitekey' data-callback='onSuccess' data-error-callback='onHCaptchaError' class='h-captcha' data-sitekey='" . esc_attr( strval( $this->hcaptcha_site_key ) ) . "'></div>"; ?> | |
| 183 | 182 | <?php } ?> |
| 184 | - <div class="srfm-validation-error" id="captcha-error" style="display: none;"><?php echo esc_html__( 'Please verify that you are not a robot.', 'sureforms' ); ?></div> | |
| 183 | + <div class="srfm-validation-error" id="captcha-error" style="display: none;"><?php echo esc_attr__( 'Please verify that you are not a robot.', 'sureforms' ); ?></div> | |
| 185 | 184 | </div> |
| 186 | 185 | <?php } ?> |
| 187 | 186 | <div data-block-id="<?php echo esc_attr( $this->block_id ); ?>" class="<?php echo esc_attr( $this->class_name ); ?> <?php echo esc_attr( $this->conditional_class ); ?> srf-<?php echo esc_attr( $this->slug ); ?>-<?php echo esc_attr( $this->block_id ); ?>-block<?php echo esc_attr( $this->block_width ); ?> srfm-block srfm-custom-button-ctn <?php echo esc_attr( '1' === $this->btn_from_theme ? 'wp-block-button' : '' ); ?>"> |
| 188 | 187 | <?php |
| @@ -207,19 +206,18 @@ | ||
| 207 | 206 | |
| 208 | 207 | if ( 'cf-turnstile' === $this->captcha_security_type ) { |
| 209 | 208 | if ( ! empty( $this->cf_turnstile_site_key ) ) { |
| 210 | 209 | // Cloudflare Turnstile script. |
| 211 | - // phpcs:disable WordPress.WP.EnqueuedResourceParameters.MissingVersion, PluginCheck.CodeAnalysis.EnqueuedResourceOffloading.OffloadedContent -- Cloudflare Turnstile must be loaded from Cloudflare's servers for token verification; the version is controlled by Cloudflare. | |
| 212 | - wp_enqueue_script( | |
| 210 | + wp_enqueue_script( // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 213 | 211 | SRFM_SLUG . '-cf-turnstile', |
| 214 | 212 | 'https://challenges.cloudflare.com/turnstile/v0/api.js', |
| 215 | 213 | [], |
| 216 | 214 | null, |
| 217 | 215 | [ |
| 218 | - 'strategy' => 'defer', | |
| 216 | + false, | |
| 217 | + 'defer' => true, | |
| 219 | 218 | ] |
| 220 | 219 | ); |
| 221 | - // phpcs:enable WordPress.WP.EnqueuedResourceParameters.MissingVersion, PluginCheck.CodeAnalysis.EnqueuedResourceOffloading.OffloadedContent | |
| 222 | 220 | } else { |
| 223 | 221 | Helper::render_missing_sitekey_error( 'Cloudflare Turnstile' ); |
| 224 | 222 | } |
| 225 | 223 | } |
| @@ -224,14 +222,14 @@ | ||
| 224 | 222 | } |
| 225 | 223 | } |
| 226 | 224 | if ( 'hcaptcha' === $this->captcha_security_type ) { |
| 227 | 225 | if ( ! empty( $this->hcaptcha_site_key ) ) { |
| 228 | - wp_enqueue_script( 'hcaptcha', 'https://js.hcaptcha.com/1/api.js', [], null, [ 'strategy' => 'defer' ] ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion, PluginCheck.CodeAnalysis.EnqueuedResourceOffloading.OffloadedContent -- hCaptcha must be loaded from hCaptcha's servers for token verification; the version is controlled by hCaptcha. | |
| 226 | + wp_enqueue_script( 'hcaptcha', 'https://js.hcaptcha.com/1/api.js', [], null, [ 'strategy' => 'defer' ] ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 229 | 227 | } else { |
| 230 | 228 | Helper::render_missing_sitekey_error( 'HCaptcha' ); |
| 231 | 229 | } |
| 232 | 230 | } |
| 233 | - $srfm_custom_button_classes = apply_filters( 'srfm_add_button_classes', [ 'v2-invisible' === $this->recaptcha_version || 'v3-reCAPTCHA' === $this->recaptcha_version ? 'g-recaptcha ' : '', '1' === $this->btn_from_theme ? 'wp-block-button__link' : 'srfm-button srfm-submit-button srfm-btn-frontend srfm-custom-button' ], $this->form_id, Generate_Form_Markup::get_current_block_attrs() ); | |
| 231 | + $srfm_custom_button_classes = apply_filters( 'srfm_add_button_classes', [ 'v2-invisible' === $this->recaptcha_version || 'v3-reCAPTCHA' === $this->recaptcha_version ? 'g-recaptcha ' : '', '1' === $this->btn_from_theme ? 'wp-block-button__link' : 'srfm-button srfm-submit-button srfm-btn-frontend srfm-custom-button' ], $this->form_id ); | |
| 234 | 232 | |
| 235 | 233 | $button_style = $this->btn_from_theme ? '' : ' font-family: inherit; font-weight: var(--wp--custom--font-weight--medium); line-height: normal;'; |
| 236 | 234 | $button_style .= 'width:100%;'; |
| 237 | 235 | |
| @@ -236,12 +234,12 @@ | ||
| 236 | 234 | $button_style .= 'width:100%;'; |
| 237 | 235 | |
| 238 | 236 | $button_attributes = ''; |
| 239 | 237 | if ( 'g-recaptcha' === $this->captcha_security_type && ( 'v2-invisible' === $this->recaptcha_version || 'v3-reCAPTCHA' === $this->recaptcha_version ) ) { |
| 240 | - $button_attributes = 'recaptcha-type="' . esc_attr( $this->recaptcha_version ) . '" data-sitekey="' . esc_attr( $this->google_captcha_site_key ) . '" data-callback="recaptchaCallback"'; | |
| 238 | + $button_attributes = 'recaptcha-type=' . $this->recaptcha_version . ' data-sitekey=' . $this->google_captcha_site_key . ' data-callback="recaptchaCallback"'; | |
| 241 | 239 | } |
| 242 | 240 | ?> |
| 243 | - <button style="<?php echo esc_attr( $button_style ); ?>" id="srfm-submit-btn" class="<?php echo esc_attr( Helper::join_strings( $srfm_custom_button_classes ) ); ?>" <?php echo $button_attributes; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Individual attribute values are escaped with esc_attr() at build time above. ?>> | |
| 241 | + <button style="<?php echo esc_attr( $button_style ); ?>" id="srfm-submit-btn" class="<?php echo esc_attr( Helper::join_strings( $srfm_custom_button_classes ) ); ?>" <?php echo esc_attr( $button_attributes ); ?>> | |
| 244 | 242 | <div class="srfm-submit-wrap"> |
| 245 | 243 | <?php echo esc_html( $this->button_text ); ?> |
| 246 | 244 | <div class="srfm-loader"></div> |
| 247 | 245 | </div> |