Skip to content

Commit 7e4917f

Browse files
authored
fix(sso): add GlotPress compatibility for cross-domain SSO (#749)
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.
1 parent 3b77af0 commit 7e4917f

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

inc/sso/class-sso.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,22 @@ public function startup(): void {
273273

274274
add_action('login_head', [$this, 'enqueue_script']);
275275

276+
/*
277+
* GlotPress uses its own template system with gp_head()/gp_footer()
278+
* instead of wp_head()/wp_footer(). Without this hook the SSO script
279+
* never loads on GlotPress pages, breaking cross-domain login for
280+
* translation sites.
281+
*
282+
* Registration is deferred to plugins_loaded so we can check whether
283+
* GlotPress is actually active before adding the hook.
284+
*/
285+
add_action('plugins_loaded', function (): void {
286+
287+
if (defined('GP_VERSION')) {
288+
add_action('gp_head', [$this, 'enqueue_script']);
289+
}
290+
});
291+
276292
/**
277293
* Allow plugin developers to add additional hooks, if needed.
278294
*

0 commit comments

Comments
 (0)