get_setting( 'taxonomies_sync_option' ); $translate_event_cat = ! empty( $tax_sync_options[ Tribe__Events__Main::TAXONOMY ] ); $using_lang_query_var = $sitepress->get_setting( 'language_negotiation_type' ) == 3; if ( ! $translate_event_cat || $using_lang_query_var ) { $slug = 'category'; } else { $lang = $sitepress->get_locale( ICL_LANGUAGE_CODE ); $tec_translation = Tribe__Events__Integrations__WPML__Utils::get_wpml_i18n_strings( [ 'category' ], $lang ); $slug = ! empty( $tec_translation[0] ) ? end( $tec_translation[0] ) : $slug; $remove_accents = true; /** * Whether accents should be removed from the translated slug or not. * * Returning a falsy value here will prevent accents from being removed. * E.g. "catégorie" would become "categorie" if this filter value is truthy; * it would instead remain unchanged if this filters returns a falsy value. * * @param bool $remove_accents Defaults to `true`. */ $remove_accents = apply_filters( 'tribe_events_integrations_category_slug_remove_accents', $remove_accents ); if ( $remove_accents ) { $slug = remove_accents( urldecode( $slug ) ); } } return $slug; } /** * Supplies an array containing all translated forms of the events category slug. * * The default (English) slug will not be containied in the resulting array. * Example: [ 'categorie', 'kategorie', 'categoria' ] // French, German, Italian * * @return array */ public function get_translated_base_slugs() { /** @var SitePress $sitepress */ global $sitepress; $translations = []; $tax_sync_options = $sitepress->get_setting( 'taxonomies_sync_option' ); $should_translate = ! empty( $tax_sync_options[ Tribe__Events__Main::TAXONOMY ] ); // If the event category slug shouldn't be translated, return an empty list if ( ! $should_translate ) { return []; } // Determine the translated form of the category slug for each active locale foreach ( Tribe__Events__Integrations__WPML__Utils::get_active_locales() as $lang ) { $slugs = Tribe__Events__Integrations__WPML__Utils::get_wpml_i18n_strings( [ 'category' ], $lang ); // We expect an array of arrays with at least one element to come back if ( empty( $slugs[0] ) ) { continue; } // Following the strategy used elsewhere, use the final translation if there are multiple $translations[] = end( $slugs[0] ); } $translations = array_map( 'urldecode', $translations ); $translations = array_map( 'remove_accents', $translations ); return array_unique( $translations ); } }