Created
March 17, 2020 20:44
-
-
Save wpmudev-sls/aa7f0fcade9fe3342a7c4f2e71b88c23 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Fix Google's ReCaptcha conflict with Divi Theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Forminator Pro] - Fix Google's ReCaptcha conflict with Divi Theme | |
* Plugin URI: https://premium.wpmudev.org/ | |
* Description: Dequeue Divi's ReCaptcha scripts when Forminator is activated to avoid JS conflicts (as of 1.12) | |
* Author: Alessandro Kaounas @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org/ | |
* Task: 0/1135022585412927/1166085706874201 | |
* License: GPLv2 or later | |
*/ | |
add_action( 'template_redirect', function(){ | |
if( ! class_exists( 'Forminator_Recaptcha' ) ){ | |
return; | |
} | |
// Remove Divi's ReCaptcha scripts | |
remove_action( 'wp_enqueue_scripts', array( ET_Core_API_Spam_Providers::instance()->get( 'recaptcha', '' ), 'action_wp_enqueue_scripts' ) ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code solves the problem in a different way:
It removes Forminators recaptcha code and injects it with a script-loader. The ReCaptcha API of Forminator is loaded after the page finished loading. This has two side effects:
Here's the un-minified code of that script-loader, for the records: