PluginProbe
Contact Forms by Cimatti / 2.3.6
Contact Forms by Cimatti v2.3.6
2.3.6 2.3.5 2.3.0 2.2.32 2.2.4 2.2.0 2.1.2 2.1.1 trunk 1.0 1.1 1.2 1.2.1 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8 1.3.9 1.4.0 1.4.1 All 62 releases
contact-forms / classes / Element / Captcha2.php

Captcha2.php in Contact Forms by Cimatti 2.3.6, at classes/Element/Captcha2.php

45 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 // phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC framework extension, HTML output is controlled
3 class AccuaForm_Element_Captcha2 extends Element {
4 protected $privateKey = "";
5 protected $publicKey = "";
6 protected $captchaAction = "";
7 protected $spamAction = "";
8
9 public function __construct($label = "", $unused = null, ?array $properties = null) {
10 if ($properties === null && is_array($unused)) {
11 $properties = $unused;
12 }
13 parent::__construct($label, "recaptcha_response_field", $properties);
14 $validator = new AccuaForm_Validation_Captcha2b(__("The reCAPTCHA response provided was incorrect. Please retry.", 'contact-forms'));
15 $validator->configure(array('privateKey' => $this->privateKey, 'captchaAction' => $this->captchaAction, 'spamAction' => $this->spamAction));
16 $this->setValidation($validator);
17 }
18
19 public function render() {
20 wp_enqueue_script(
21 'accua-forms-recaptcha2',
22 ACCUA_FORMS_DIR_URL . 'assets/js/frontend/recaptcha2.js',
23 array('jquery'),
24 ACCUA_FORMS_JS_VERSION,
25 true
26 );
27
28 $js_registration = _accua_forms_json_encode(array(
29 $this->attributes["id"],
30 array('sitekey' => $this->publicKey),
31 $this->form->getLanguage(),
32 ));
33 $field_id = htmlspecialchars($this->attributes["id"], ENT_QUOTES);
34 // No input with the element name exists in the DOM (the widget POSTs g-recaptcha-response),
35 // so expose the name here for the error JS label/anchor fallback.
36 $field_name = htmlspecialchars($this->attributes["name"], ENT_QUOTES);
37 echo <<<EOT
38 <div id="{$field_id}" class="accua_forms_recaptcha2_container" data-accua-name="{$field_name}" style="min-height: 78px !important;"></div>
39 <script type="text/javascript">
40 (window.accuaformRecaptcha2Queue = window.accuaformRecaptcha2Queue || []).push( $js_registration );
41 </script>
42 EOT;
43 }
44 }
45