siteKey = $stored_key; } if (!empty($stored_secret)) { $this->secretKey = $stored_secret; } } $validator = new AccuaForm_Validation_Turnstile(__("Turnstile verification failed. Please try again.", 'contact-forms')); $validator->configure(array('secretKey' => $this->secretKey)); $this->setValidation($validator); } public function render() { // Check if Simple Cloudflare Turnstile plugin is installed if (!function_exists('cfturnstile_field_show')) { echo '
'; echo '' . esc_html__('Plugin Required:', 'contact-forms') . ' '; echo esc_html__('The Turnstile field requires the', 'contact-forms') . ' '; echo ''; echo esc_html__('Simple Cloudflare Turnstile', 'contact-forms'); echo ' ' . esc_html__('plugin to be installed and activated.', 'contact-forms'); echo '
'; return; } // Check if Turnstile is configured if (empty($this->siteKey) || empty($this->secretKey)) { echo '
'; echo '' . esc_html__('Configuration Required:', 'contact-forms') . ' '; echo esc_html__('Please configure your Cloudflare Turnstile API keys in', 'contact-forms') . ' '; echo ''; echo esc_html__('Settings → Cloudflare Turnstile', 'contact-forms'); echo '.'; echo '
'; return; } // Generate unique ID for this instance $unique_id = '-accua-form-' . esc_attr($this->attributes['id']); $form_id = $this->form ? $this->form->getId() : 'unknown'; // Use Simple Cloudflare Turnstile plugin's function to render the widget // This ensures consistent rendering and avoids double-initialization // Note: Pass empty action to avoid Turnstile's strict alphanumeric validation echo '
'; cfturnstile_field_show('', '', '', $unique_id, 'accua-forms-turnstile'); echo '
'; // Add form reset handlers for AJAX submissions if ($this->form) { $container_id = 'cf-turnstile' . $unique_id; ?>