public function __construct($domains, $default_language, $hidden_languages)
 {
     parent::__construct($default_language, $hidden_languages);
     $this->domains = preg_replace('#^(http|https)://#', '', $domains);
     add_filter('login_url', array($this, 'convert_url'));
     add_filter('logout_url', array($this, 'convert_url'));
 }
 public function __construct($default_language, $hidden_languages)
 {
     parent::__construct($default_language, $hidden_languages);
     add_filter('request', array($this, 'request_filter'));
     add_filter('get_pagenum_link', array($this, 'paginated_url_filter'));
     add_filter('wp_link_pages_link', array($this, 'paginated_link_filter'));
 }
 protected function validate_language($language, $url)
 {
     if (!($language === null && $this->dir_default && !$this->is_url_admin($url))) {
         $language = parent::validate_language($language, $url);
     }
     return $language;
 }
 /**
  * @param string[] $domains
  * @param string   $default_language
  * @param string[] $hidden_languages
  */
 public function __construct($domains, $default_language, $hidden_languages)
 {
     parent::__construct($default_language, $hidden_languages);
     $this->domains = preg_replace('#^(http(?:s?))://#', '', array_map('trailingslashit', $domains));
     add_filter('login_url', array($this, 'convert_url'));
     add_filter('logout_url', array($this, 'convert_url'));
     $this->wpml_xdomain_parser = new WPML_XDomain_Data_Parser();
 }
 /**
  * Finds the correct language a post belongs to by handling the special case of the post edit screen.
  *
  * @param WP_Post $post_object
  *
  * @return bool|mixed|null|String
  */
 private function get_permalink_filter_lang($post_object)
 {
     if (isset($_POST['action']) && $_POST['action'] === 'sample-permalink') {
         $code = $this->get_language_from_url();
         $code = $code ? $code : (!isset($_SERVER['HTTP_REFERER']) ? $this->sitepress->get_default_language() : $this->url_converter->get_language_from_url($_SERVER["HTTP_REFERER"]));
     } else {
         $code = $this->post_translation->get_element_lang_code($post_object);
     }
     return $code;
 }
 /**
  * @param array       $domains
  * @param string      $default_language
  * @param array       $active_languages
  * @param WPML_WP_API $wpml_wp_api
  */
 public function __construct($domains, $default_language, $active_languages, &$wpml_wp_api)
 {
     parent::__construct($default_language, $active_languages);
     $this->wpml_wp_api =& $wpml_wp_api;
     $this->domains = preg_replace('#^(http(?:s?))://#', '', array_map('trailingslashit', $domains));
     if (isset($this->domains[$this->default_language])) {
         unset($this->domains[$this->default_language]);
     }
     add_filter('login_url', array($this, 'convert_url'));
     add_filter('logout_url', array($this, 'convert_url'));
     add_filter('admin_url', array($this, 'admin_url_filter'), 1, 2);
     $this->wpml_xdomain_parser = new WPML_XDomain_Data_Parser();
 }
 /**
  * @param string            $link
  * @param int               $post
  * @param WPML_Post_Element $post_element
  *
  * @return bool|false|mixed|string
  */
 public function get_translated_permalink($link, $post, $post_element)
 {
     $code = $this->get_permalink_filter_lang($post);
     $post_id = $post_element->get_element_id();
     $current_language = $this->sitepress->get_current_language();
     if (!is_admin() && $this->sitepress->get_setting('auto_adjust_ids') && $post_element->get_language_code() !== $this->sitepress->get_current_language() && ($post_id = $this->post_translation->element_id_in($post_id, $current_language))) {
         $link = get_permalink($post_id);
     } else {
         $link = $this->url_converter->convert_url($link, $code);
     }
     if ($this->sitepress->get_wp_api()->is_feed()) {
         $link = str_replace('&lang=', '&lang=', $link);
     }
     return $link;
 }
Esempio n. 8
0
/**
 * @param string             $req_uri
 * @param WPML_URL_Converter $wpml_url_converter
 * @param bool               $directory
 *
 * @return string
 */
function wpml_validate_host($req_uri, $wpml_url_converter, $directory = true)
{
    if ($directory === true) {
        $req_uri_parts = array_filter(explode('/', $req_uri));
        $lang_slug = array_pop($req_uri_parts);
        if (strpos($lang_slug, '?') === 0) {
            $lang_slug = array_pop($req_uri_parts);
        } elseif (strpos($lang_slug, '?') !== false) {
            $parts = explode('?', $lang_slug);
            $lang_slug = array_shift($parts);
        }
    } else {
        $lang_slug = '';
    }
    return '<!--' . untrailingslashit(trailingslashit($wpml_url_converter->get_abs_home()) . $lang_slug) . '-->';
}
 public function get_admin_ajax_url($url)
 {
     if ($this->wpml_wp_api->is_front_end()) {
         global $sitepress;
         $url = $this->convert_url($url, $sitepress->get_current_language());
     } else {
         $url = parent::get_admin_ajax_url($url);
     }
     return $url;
 }
 public function __construct($default_language, $hidden_languages)
 {
     parent::__construct($default_language, $hidden_languages);
     add_filter('request', array($this, 'request_filter'));
 }
 /**
  * Update home_url for language per-domain configuration to return correct URL in sitemap.
  */
 public function get_home_url_filter($home_url)
 {
     return $this->wpml_url_converter->convert_url($home_url, $this->sitepress->get_current_language());
 }
 private function get_sample_url($sample_lang_code)
 {
     $abs_home = $this->url_converter->get_abs_home();
     return untrailingslashit(trailingslashit($abs_home) . $sample_lang_code);
 }