txtw
Forum Replies Created
-
Removed the plugin from the live site because it didn’t work but I did some debugging on a local installation and found the source of the problem.
The site uses ACF and one of the custom fields contains a shortcode to a wpcf7 contact form.
The custom theme called get_fields() from ACF before wp_head(). The call resolved the shortcode and called wpcf7_contact_form_tag_func that eventually called iqfix_wpcf7_recaptcha_form_tag_handler callback before iqfix_wpcf7_recaptcha_enqueue_scripts registered the ‘google-recaptcha’ script (too early).
Therfore, it ended up in this if statement:
if ( ! wp_script_is( ‘google-recaptcha’, ‘registered’ ) && function_exists( ‘wpcf7_recaptcha_enqueue_scripts’ ) ) { wpcf7_recaptcha_enqueue_scripts(); }it evaluated true because of the above-mentioned situation and called the original wpcf7_recaptcha_enqueue_scripts() function which always loads v3.
I don’t know if it is good to always call the original wpcf7_recaptcha_enqueue_scripts from wpcf7 (loads v3) in this if statement instead of checking which one (v2 or v3) in use and calling accordingly either wpcf7_recaptcha_enqueue_scripts or iqfix_wpcf7_recaptcha_enqueue_scripts.
Please note, I haven’t reviewed the whole wpcf7 codebase so this is just a guess.
Anyways, I think on average this if statement never evaluates to true because iqfix_wpcf7_recaptcha_enqueue_scripts registered the script beforehand.
I fixed my custom theme so it calls get_fields() after wp_head() and everything works well.
- This reply was modified 5 years, 3 months ago by txtw.