Hey there
I want to repost a bug in the wpml latest version.
Ok so wordpress introduced a new filter for the function term_exists() since version 6.0.0
/**
* Filters default query arguments for checking if a term exists.
*
* @since 6.0.0
*
* @param array $defaults An array of arguments passed to get_terms().
* @param int|string $term The term to check. Accepts term ID, slug, or name.
* @param string $taxonomy The taxonomy name to use. An empty string indicates
* the search is against all taxonomies.
* @param int|null $parent ID of parent term under which to confine the exists search.
* Null indicates the search is unconfined.
*/
$defaults = apply_filters( 'term_exists_default_query_args', $defaults, $term, $taxonomy, $parent );
let's say i have the category Test (id = 31) and Test FR which is the translation of Test
Test FR has id 32
if i use term_exists(32) it will return array('id' => 31, 'term_taxonomy_id' => 31) which is the original language id , this breaks a lot of features when trying to save a post in the second language and adding the categories programmatically
Before the wordpress update if you used term_exists(10); (wich is the translated category from english in italian) you would get 10. now you get the category depending on the language you are. This affects all programatic and custom work because now you have to switch language in order to ge the correct id