refactor(checkout): replace captcha-specific JS with generic hooks#909
refactor(checkout): replace captcha-specific JS with generic hooks#909superdav42 merged 1 commit intomainfrom
Conversation
The inline-login flow in checkout.js previously read and reset reCAPTCHA / hCaptcha / Cap token inputs directly, coupling the core plugin to specific captcha providers. Replace that with generic wp.hooks extension points so any addon can participate in the lifecycle: * wu_inline_login_data (filter) — augment the AJAX request payload (e.g. append captcha tokens) * wu_inline_login_success (action) — react to a successful login * wu_inline_login_error (action) — react to a failed login (e.g. reset a captcha widget) * wu_inline_login_prompt_ready (action) — initialize widgets once the prompt container is live in the DOM The captcha addon now hooks these instead of relying on hardcoded selectors and a window.wuCaptchaResetInlineLogin global. Supersedes #901. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 16 minutes and 43 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔨 Build Complete - Ready for Testing!📦 Download Build Artifact (Recommended)Download the zip build, upload to WordPress and test:
🌐 Test in WordPress Playground (Very Experimental)Click the link below to instantly test this PR in your browser - no installation needed! Login credentials: |
|
Performance Test Results Performance test results for de05d65 are in 🛎️! Note: the numbers in parentheses show the difference to the previous (baseline) test run. Differences below 2% or 0.5 in absolute values are not shown. URL:
|
Summary
Replaces the captcha-specific inline-login code in
checkout.jswith genericwp.hooksextension points. Any addon — not just the captcha addon — can now participate in the inline-login lifecycle.Supersedes #901. That PR tried to scope captcha token selectors to the prompt container; this one removes captcha knowledge from
checkout.jsentirely.Why
checkout.jsshould not know aboutg-recaptcha-response,h-captcha-response,cap-token, or awindow.wuCaptchaResetInlineLoginglobal. Those are concerns of the captcha addon. Hardcoding them in core means:New hooks
Fired via
wp.hooks(the existing pattern used elsewhere incheckout.js):wu_inline_login_data(data, fieldType) => datawu_inline_login_success(results, fieldType)wu_inline_login_error(error, fieldType)wu_inline_login_prompt_ready(fieldType, container)Together with the already-existing server-side hooks —
wu_inline_login_prompt_before_submit(for injecting markup) andwu_before_inline_login(for server-side validation) — addons now have a complete lifecycle to plug into.Companion PR
The captcha addon's rewrite to use these hooks lives at Ultimate-Multisite/ultimate-multisite-captcha (replacement for the reverted PR #17 in that repo).
Test plan
🤖 Generated with Claude Code