Skip to content

Commit 30ee148

Browse files
authored
Merge pull request #3058 from jasonbahl/test/pr-with-bad-formatting
fix: prevent wpml from redirecting in WPGraphQL requests
2 parents 18a22f5 + 088a06b commit 30ee148

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/WPGraphQL.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,24 @@ static function ( $interfaces, $config, $type ) {
335335
10,
336336
3
337337
);
338+
339+
/**
340+
* Prevent WPML from redirecting within WPGraphQL requests
341+
*
342+
* @see https://github.com/wp-graphql/wp-graphql/issues/1626#issue-769089073
343+
* @since @todo
344+
*/
345+
add_filter(
346+
'wpml_is_redirected',
347+
static function ( bool $is_redirect ) {
348+
if ( is_graphql_request() ) {
349+
return false;
350+
}
351+
return $is_redirect;
352+
},
353+
10,
354+
1
355+
);
338356
}
339357

340358
/**

0 commit comments

Comments
 (0)