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 '
';
return;
}
// Check if Turnstile is configured
if (empty($this->siteKey) || empty($this->secretKey)) {
echo '';
return;
}
// Generate unique ID for this instance
$unique_id = '-accua-form-' . esc_attr($this->attributes['id']);
// 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
//
// Tokens are single-use: the widget (div id "cf-turnstile{$unique_id}") is
// reset after every AJAX response by the generated form JS in AccuaForm.php,
// next to the recaptcha2/v3 and Cap resets — no per-instance script needed
echo '';
cfturnstile_field_show('', '', '', $unique_id, 'accua-forms-turnstile');
echo '
';
}
}