fix(sso): add GlotPress compatibility for cross-domain SSO#749
fix(sso): add GlotPress compatibility for cross-domain SSO#749superdav42 merged 1 commit intomainfrom
Conversation
GlotPress uses its own gp_head()/gp_footer() template actions instead of WordPress's wp_head()/wp_footer(). The SSO script is hooked to wp_head, so it never fires on GlotPress pages, preventing cross-domain login on translation sites (e.g. translate.example.com). Register the SSO enqueue_script callback on the gp_head action when GlotPress is active (GP_VERSION defined). The check is deferred to plugins_loaded since SSO startup() runs at sunrise before plugins load.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdded deferred registration for SSO head injection script to activate when GlotPress plugin is present. A new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 cdfc0c2 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:
|
|
Completed via PR #749, merged to main. Merged by deterministic merge pass (pulse-wrapper.sh). No worker summary was available — the worker either crashed before writing one or this PR predates the merge summary convention.aidevops.sh v3.6.19 spent 6m on this as a headless bash routine. |
Summary
enqueue_scriptcallback onto GlotPress'sgp_headaction so the SSO JavaScript loads on GlotPress pagesGP_VERSIONdefined), deferred toplugins_loadedsince SSO starts at sunriseProblem
GlotPress uses its own template system (
gp_head()/gp_footer()) instead of WordPress'swp_head()/wp_footer(). The SSO script is registered onwp_head, so it never fires on GlotPress pages. This means cross-domain login is completely broken for translation sites (e.g.translate.example.com) — users log in on the main site but the session is never propagated to the GlotPress subsite.Root Cause
class-sso.phpline 272 hooksenqueue_scripttowp_headandlogin_head, but GlotPress never calls either of those actions. Its header template callsgp_head()which fires thegp_headaction instead.Fix
Register
enqueue_scriptongp_headin addition towp_headandlogin_head. The registration is deferred toplugins_loadedso we can checkdefined('GP_VERSION')— SSOstartup()runs at sunrise before plugins are loaded.When GlotPress is not installed,
GP_VERSIONis never defined and the hook is not registered. Even if it were registered unconditionally, it would be a no-op sincegp_headwould never fire.Testing
translate.example.com)Summary by CodeRabbit