Closed pospisk closed 3 months ago
@fredericalpers I will investigate and report back asap
This is mainly due to the method with which the ReCaptcha Script is being added/enqueued because Elementor can't process those scripts.
@pospisk @fredericalpers I agree with you
Fix Example:
if (!is_admin()) { $this->renderCaptchaScript($pFormConfig->getCaptcha()); }
Thanks for your suggestions. However, I checked and found that the "renderCaptchaScript" method is only used in Front-end of the three components: Contact form, Interest form, Owner form. => My suggestion: Load "onoffice-captchacontrol" JS file when necessary at "renderScriptForFormPage" method in "ScriptLoaderGenericConfigurationDefault" class.
Extend notes:
I have refactored the code. You can test and review it at the branch 45882-elementor-recaptcha-bug
@dai-eastgate thank you we will review it carefully. :)
the following is just knowledge sharing:
We have received a message that the use of the function wp_enqueue_script() in combination with the immediate call of wp_print_scripts() for the script onoffice-captchacontrol.min.js within the CaptchaHandler class causes problems. As far as you know, the explicit call of wp_print_scripts() is normally not necessary. Immediately "printing" the script can lead to sequencing problems with the script loads. In this particular case, this call causes the script to be executed before jQuery is loaded, resulting in errors due to the absence of jQuery. He has also sent the following code, which seems to work better: public static function registerScripts() { $siteKey = get_option('onoffice-settings-captcha-sitekey', ''); if ($siteKey !== '') { wp_enqueue_script('onoffice-captchacontrol', plugins_url('/dist/onoffice-captchacontrol.min.js', ONOFFICE_PLUGIN_DIR.'/index.php'), array('jquery'), null, true); // wp_print_scripts() NOT NECESSARY } } Translated with DeepL.com (free version)
@fredericalpers I understand your knowledge sharing.
That logic has been changed in this branch https://github.com/onOffice-Web-Org/oo-wp-plugin/pull/600/files
Released in v4.20 - https://github.com/onOffice-Web-Org/oo-wp-plugin/pull/774
@fredericalpers and I have noticed on customer websites which are using the Elementor Page Builder: If we create a form and add the shortcode in Elementor everything works, but as soon as we activate "Require ReCaptcha" Elementor stops working. (reproducible with a fresh install of oO-WP-Plugin + ReCaptcha + Elementor)
This is mainly due to the method with which the ReCaptcha Script is being added/enqueued because Elementor can't process those scripts.
File:
https://github.com/onOffice-Web-Org/oo-wp-plugin/blob/e871c0ba2f42d4342bd1ddc571c0f3e773cff700/plugin/Form.php#L123
Current:
Fix Example:
Reasoning:
The enqueue method doesn't cause further complications so it can stay as it is. It would be enough to prevent the ReCaptcha Script from being loaded on the Admin pages to prevent the error because ReCaptcha isn't needed/required at that point.
I've tested if the change affects the "Test-Keys" element on the onOffice Settings page and it still works:
TL;DR Elementor Browser Errors: