/**
  * Filters the `tribe_events_category_slug` to return the category slug that's WPML aware.
  *
  * WPML does not currently support translation of custom taxonomies root ,e.g. `category` in
  * The Events Calendar case. But we do take WPML-managed translations of the `category` slug
  * into account in our rewrite rules and try to show a localized version of the `category` slug
  * in the permalinks.
  *
  * @param string $slug The original, possibily translated, category slug.
  *
  * @return string The category slug in its ENG form if the Events Category translation is not active
  *                or in a translation that The Events Calendar supports.
  */
 public function filter_tribe_events_category_slug($slug)
 {
     /** @var SitePress $sitepress */
     global $sitepress;
     $tax_sync_options = $sitepress->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(array('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;
 }
Ejemplo n.º 2
0
 protected function prepare_organizer_slug_translations()
 {
     $wpml_i18n_strings = Tribe__Events__Integrations__WPML__Utils::get_wpml_i18n_strings(array($this->organizer_slug));
     $post_slug_translations = Tribe__Events__Integrations__WPML__Utils::get_post_slug_translations_for(Tribe__Events__Organizer::POSTTYPE);
     $slug_translations = array_merge($wpml_i18n_strings[0], array_values($post_slug_translations));
     $this->organizer_slug_translations = array_map('esc_attr', array_unique($slug_translations));
 }
Ejemplo n.º 3
0
 /**
  * Filters the "all" fragment of the all recurrences link.
  *
  * @param string $all_frag
  * @param int    $post_id
  */
 public function filter_tribe_events_pro_all_link_frag($all_frag, $post_id)
 {
     $language_information = wpml_get_language_information(null, $post_id);
     if (!is_array($language_information) || empty($language_information['locale'])) {
         return $all_frag;
     }
     $locale = $language_information['locale'];
     $all_frags = Tribe__Events__Integrations__WPML__Utils::get_wpml_i18n_strings(array('all'), $locale);
     if (empty($all_frags[0]) || !is_array($all_frags[0])) {
         return $all_frag;
     }
     // the last translation is the one in the language we seek
     return end($all_frags[0]);
 }