[Forminator Pro] - Fix Google's ReCaptcha conflict with Divi Theme
<?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 comment has been minimized.
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: