PluginProbe
Contact Forms by Cimatti / 1.9.2
Contact Forms by Cimatti v1.9.2
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
← All changes | classes/Element/Captcha2.php +39 -23 2.3.51.9.2 View file →
@@ -1,44 +1,60 @@
1 1 <?php
2 -// phpcs:disable WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.Security.EscapeOutput.HeredocOutputNotEscaped, PluginCheck.CodeAnalysis.Heredoc -- PFBC framework extension, HTML output is controlled
3 2 class AccuaForm_Element_Captcha2 extends Element {
4 3 protected $privateKey = "";
5 4 protected $publicKey = "";
6 - protected $captchaAction = "";
7 - protected $spamAction = "";
8 5
9 - public function __construct($label = "", $unused = null, ?array $properties = null) {
6 + public function __construct($label = "", $unused = null, array $properties = null) {
10 7 if ($properties === null && is_array($unused)) {
11 8 $properties = $unused;
12 9 }
13 10 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));
11 + $validator = new AccuaForm_Validation_Captcha2b(__("The reCATPCHA response provided was incorrect. Please re-try.", 'contact-forms'));
12 + $validator->configure(array('privateKey'=>$this->privateKey));
16 13 $this->setValidation($validator);
17 14 }
18 15
19 16 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 - );
17 + $js_lang = _accua_forms_json_encode($this->form->getLanguage());
18 + $js_field_id = _accua_forms_json_encode($this->attributes["id"]);//$this->form->attributes['id'] per id del form
19 + $js_publicKey = _accua_forms_json_encode($this->publicKey);
20 + $js_path = _accua_forms_json_encode(ACCUA_FORMS_DIR_URL . 'accua-recaptcha2.js');
27 21
28 - $js_registration = _accua_forms_json_encode(array(
29 - $this->attributes["id"],
30 - array('sitekey' => $this->publicKey),
31 - $this->form->getLanguage(),
32 - ));
33 22 $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 23 echo <<<EOT
38 -<div id="{$field_id}" class="accua_forms_recaptcha2_container" data-accua-name="{$field_name}" style="min-height: 78px !important;"></div>
39 24 <script type="text/javascript">
40 -(window.accuaformRecaptcha2Queue = window.accuaformRecaptcha2Queue || []).push( $js_registration );
25 +<!--
26 +if (typeof(accuaform_recaptcha2_ajax_loaded) == "undefined" || !accuaform_recaptcha2_ajax_loaded) {
27 + var accuaform_recaptcha2_ajax_loaded = true;
28 + var accuaform_recaptcha2_ajax_delaying = true;
29 + var accuaform_recaptcha2_ajax_loading = true ;
30 + var accuaform_recaptcha2_ajax_controller = jQuery({});
31 + var accuaform_recaptcha2_ajax_initialized = {};
32 + jQuery(".accuaforms-field-required, .pfbc-fieldwrap > *").one('change', function() {
33 + if(accuaform_recaptcha2_ajax_delaying){
34 + accuaform_recaptcha2_ajax_delaying = false;
35 + jQuery.getScript( $js_path , function(){
36 + jQuery.getScript( "https://www.recaptcha.net/recaptcha/api.js?onload=accua_forms_onload_recaptcha2&render=explicit&hl=" + $js_lang );
37 + accuaform_recaptcha2_ajax_loading = false;
38 + accuaform_recaptcha2_ajax_controller.trigger('loaded');
39 + });
40 + }
41 + });
42 +}
43 +if (!accuaform_recaptcha2_ajax_initialized[ $js_field_id ]) {
44 + accuaform_recaptcha2_ajax_initialized[ $js_field_id ] = true;
45 + jQuery(function(){
46 + if (accuaform_recaptcha2_ajax_loading) {
47 + accuaform_recaptcha2_ajax_controller.one('loaded', function(){
48 + accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
49 + })
50 + } else {
51 + accua_forms_show_recaptcha2( $js_field_id , { sitekey: $js_publicKey });
52 + }
53 + });
54 +}
55 +// -->
41 56 </script>
57 +<div id="{$field_id}" class="accua_forms_recaptcha2_container" style="min-height: 78px !important;"></div>
42 58 EOT;
43 59 }
44 60 }