# contact-forms/2.3.5/classes/Element/Captcha2.php

Contact Forms by Cimatti, version 2.3.5. 45 lines.

- Page: https://pluginprobe.com/plugins/contact-forms/2.3.5/code/classes/Element/Captcha2.php
- Raw: https://pluginprobe.com/plugins/contact-forms/2.3.5/raw/classes/Element/Captcha2.php
- Modified: 2026-08-05T09:37:24+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/contact-forms/2.3.5/code/classes/Element/Captcha2.php#L10-L20`.

```php
<?php
// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC framework extension, HTML output is controlled
class AccuaForm_Element_Captcha2 extends Element {
	protected $privateKey = "";
	protected $publicKey = "";
	protected $captchaAction = "";
	protected $spamAction = "";

	public function __construct($label = "", $unused = null, ?array $properties = null) {
	  if ($properties === null && is_array($unused)) {
	    $properties = $unused;
	  }
		parent::__construct($label, "recaptcha_response_field", $properties);
		$validator = new AccuaForm_Validation_Captcha2b(__("The reCAPTCHA response provided was incorrect. Please retry.", 'contact-forms'));
		$validator->configure(array('privateKey' => $this->privateKey, 'captchaAction' => $this->captchaAction, 'spamAction' => $this->spamAction));
		$this->setValidation($validator);
	}

	public function render() {
    wp_enqueue_script(
      'accua-forms-recaptcha2',
      ACCUA_FORMS_DIR_URL . 'assets/js/frontend/recaptcha2.js',
      array('jquery'),
      ACCUA_FORMS_JS_VERSION,
      true
    );

    $js_registration = _accua_forms_json_encode(array(
      $this->attributes["id"],
      array('sitekey' => $this->publicKey),
      $this->form->getLanguage(),
    ));
    $field_id = htmlspecialchars($this->attributes["id"], ENT_QUOTES);
    // No input with the element name exists in the DOM (the widget POSTs g-recaptcha-response),
    // so expose the name here for the error JS label/anchor fallback.
    $field_name = htmlspecialchars($this->attributes["name"], ENT_QUOTES);
	  echo <<<EOT
<div id="{$field_id}" class="accua_forms_recaptcha2_container" data-accua-name="{$field_name}" style="min-height: 78px !important;"></div>
<script type="text/javascript">
(window.accuaformRecaptcha2Queue = window.accuaformRecaptcha2Queue || []).push( $js_registration );
</script>
EOT;
	}
}

```
