From 9d8fee27d8b6515b3c301a1966236b3a8a4744eb Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 31 Aug 2023 11:18:53 -0700 Subject: [PATCH] Revert conditional enqueueing of reCAPTCHA script --- modules/recaptcha/recaptcha.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/recaptcha/recaptcha.php b/modules/recaptcha/recaptcha.php index 7bafecd8..24749c42 100644 --- a/modules/recaptcha/recaptcha.php +++ b/modules/recaptcha/recaptcha.php @@ -23,13 +23,22 @@ function wpcf7_recaptcha_register_service() { add_action( - 'wpcf7_enqueue_scripts', + 'wp_enqueue_scripts', 'wpcf7_recaptcha_enqueue_scripts', 20, 0 ); /** * Enqueues frontend scripts for reCAPTCHA. + * + * Note that this runs at the `wp_enqueue_scripts` action instead of `wpcf7_enqueue_scripts` because the reCAPTCHA + * v3 documentation states that the script should be included on every page of a site, even on pages that don't use it: + * + * > reCAPTCHA works best when it has the most context about interactions with your site, which comes from seeing both + * > legitimate and abusive behavior. For this reason, we recommend including reCAPTCHA verification on forms or actions + * > as well as in the background of pages for analytics. + * + * @link https://developers.google.com/recaptcha/docs/v3#placement_on_your_website */ function wpcf7_recaptcha_enqueue_scripts() { $service = WPCF7_RECAPTCHA::get_instance();