Skip to content

reCaptcha script not being loaded#2893

Merged
azaozz merged 2 commits intoAutomattic:trunkfrom
Gnodesign:fix/recaptcha
Aug 19, 2025
Merged

reCaptcha script not being loaded#2893
azaozz merged 2 commits intoAutomattic:trunkfrom
Gnodesign:fix/recaptcha

Conversation

@Gnodesign
Copy link
Collaborator

Fixes #2850

Changes Proposed in this Pull Request

The reCAPTCHA scripts aren't being loaded on any themes other than the default ones.

Testing Instructions

  • Setup reCaptcha
  • Switch to a non default theme
  • Go to the job submission

@azaozz
Copy link
Contributor

azaozz commented Aug 18, 2025

This change makes sense: the callback won't be executed when attempting to use a hook (an action) after it has been run. As far as I see the maybe_enable_recaptcha() function seems to run in the middle of the page, long after the WP's init action.

May be missing something but looking at all the comments suggests that reCAPTCHA v2 works but v3 fails. I'm not very familiar with how exactly the different versions of reCAPTCHA work, but as far as I see both require some js? Or perhaps the js for v2 was added in a different way?

In any case this change shouldn't break anything and is good to go.

@Gnodesign
Copy link
Collaborator Author

@azaozz the issue comes from the main reCaptcha script not being loaded correctly. With the provided fix, both versions work as expected.

@azaozz
Copy link
Contributor

azaozz commented Aug 19, 2025

issue comes from the main reCaptcha script not being loaded correctly

Yep, I understand. What I was wondering about is why v2 works nevertheless.

Seems this bug was introduced in Commit a6e0757 most likely by this change on L:139: a6e0757#diff-69b5a8dc728e5b801b8b59d2cf75e0470846f28cab3f1698413c5bcfb02c3fe6L139. Not understanding and fixing the underlying timing issue might eventually cause problems in the future when other scripts have to be enqueued, etc.

In any case, this patch seems okay for now.

@azaozz azaozz merged commit 3fac4cf into Automattic:trunk Aug 19, 2025
11 checks passed
@donnchawp donnchawp added this to the 2.4.1 milestone Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recaptcha v3 not working. Other recaptcha plugins work with the same keys

3 participants