| @@ -27,9 +27,9 @@ | ||
| 27 | 27 | $siteKey = Arr::get($settings, 'site_key', ''); |
| 28 | 28 | |
| 29 | 29 | $isActive = ($enableTurnstile === 'yes' && !empty($siteKey)); |
| 30 | 30 | ?> |
| 31 | - <div class="fct-turnstile-wrapper" data-fluent-cart-turnstile-widget style="position: fixed; bottom: 0; left: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none;" data-turnstile-active="<?php echo $isActive ? 'yes' : 'no'; ?>"> | |
| 31 | + <div class="fct-turnstile-wrapper" data-fluent-cart-turnstile-widget data-turnstile-active="<?php echo $isActive ? 'yes' : 'no'; ?>"> | |
| 32 | 32 | <?php if ($isActive): ?> |
| 33 | 33 | <div class="cf-turnstile" |
| 34 | 34 | data-sitekey="<?php echo esc_attr($siteKey); ?>" |
| 35 | 35 | data-callback="fluentCartTurnstileCallback" |
| @@ -73,9 +73,8 @@ | ||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | 76 | * Inject widget via wp_footer as last resort |
| 77 | - * This should ALWAYS work since wp_footer fires on every page | |
| 78 | 77 | */ |
| 79 | 78 | public function injectWidgetViaFooter() |
| 80 | 79 | { |
| 81 | 80 | if ($this->isCheckoutContext()) { |
| @@ -111,8 +110,9 @@ | ||
| 111 | 110 | |
| 112 | 111 | try { |
| 113 | 112 | const renderedId = turnstile.render(widget, { |
| 114 | 113 | sitekey: siteKey, |
| 114 | + execution: 'render', | |
| 115 | 115 | callback: function(token) { |
| 116 | 116 | if (typeof window.fluentCartTurnstileCallback === 'function') { |
| 117 | 117 | window.fluentCartTurnstileCallback(token); |
| 118 | 118 | } else { |
| @@ -145,9 +145,9 @@ | ||
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | if (!renderTurnstileWidget()) { |
| 148 | 148 | let attempts = 0; |
| 149 | - const maxAttempts = 50; // 5 seconds | |
| 149 | + const maxAttempts = 50; | |
| 150 | 150 | const checkInterval = setInterval(function() { |
| 151 | 151 | attempts++; |
| 152 | 152 | if (renderTurnstileWidget() || attempts >= maxAttempts) { |
| 153 | 153 | clearInterval(checkInterval); |
| @@ -181,11 +181,8 @@ | ||
| 181 | 181 | |
| 182 | 182 | return false; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - /** | |
| 186 | - * Get widget HTML as string | |
| 187 | - */ | |
| 188 | 185 | private function getWidgetHtml() |
| 189 | 186 | { |
| 190 | 187 | $settings = ModuleSettings::getSettings('turnstile'); |
| 191 | 188 | $enableTurnstile = Arr::get($settings, 'active', 'no'); |
| @@ -191,9 +188,9 @@ | ||
| 191 | 188 | $enableTurnstile = Arr::get($settings, 'active', 'no'); |
| 192 | 189 | $siteKey = Arr::get($settings, 'site_key', ''); |
| 193 | 190 | $isActive = ($enableTurnstile === 'yes' && !empty($siteKey)); |
| 194 | 191 | |
| 195 | - $html = '<div class="fct-turnstile-wrapper" data-fluent-cart-turnstile-widget style="position: fixed; bottom: 0; left: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none;" data-turnstile-active="' . ($isActive ? 'yes' : 'no') . '">'; | |
| 192 | + $html = '<div class="fct-turnstile-wrapper" data-fluent-cart-turnstile-widget data-turnstile-active="' . ($isActive ? 'yes' : 'no') . '">'; | |
| 196 | 193 | |
| 197 | 194 | if ($isActive) { |
| 198 | 195 | $html .= '<div class="cf-turnstile" data-sitekey="' . esc_attr($siteKey) . '" data-callback="fluentCartTurnstileCallback" data-size="flexible" data-appearance="interaction-only" data-theme="auto"></div>'; |
| 199 | 196 | } else { |
| @@ -204,5 +201,4 @@ | ||
| 204 | 201 | |
| 205 | 202 | return $html; |
| 206 | 203 | } |
| 207 | 204 | } |
| 208 | - | |