Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions wp-graphql-wpml.php
Original file line number Diff line number Diff line change
Expand Up @@ -773,6 +773,20 @@ function wpgraphqlwpml__remove_term_adjust_id_filter() {
remove_filter('get_term', array($sitepress, 'get_term_adjust_id'), 1);
}

/**
* Set the `icl_adjust_id_url_filter_off` global used in the
* `WPML_Term_Adjust_Id->filter()` function to indicate if term ids
* should be adjusted. Setting this global to `true` ensures that
* term ids are not adjusted during GraphQL queries.
*/
function wpgraphqlwpml__set_global_adjust_id_filter_off() {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am confused here, doesnt do this the same as line 773?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rburgst yes, but they're used in different places in WPML. I added both to be sure we were covering our bases. Like I said here, we could set these around the resolver functions if that helps isolate the impact.

// Set global for adjust ids in case the filter is added
// again at some point in the request
global $icl_adjust_id_url_filter_off;

$icl_adjust_id_url_filter_off = true;
}

function wpgraphqlwpml_action_init()
{
if (!wpgraphqlwpml_is_graphql_request()) {
Expand Down Expand Up @@ -839,6 +853,13 @@ function wpgraphqlwpml_action_init()
0
);

// Set the global adjust id filter to allow for multi-language term queries
add_action(
'init_graphql_request',
'wpgraphqlwpml__set_global_adjust_id_filter_off',
10,
0
);
}


Expand Down