diff --git a/trunk/includes/class-localize-main.php b/trunk/includes/class-localize-main.php index 07103ef..e88912a 100644 --- a/trunk/includes/class-localize-main.php +++ b/trunk/includes/class-localize-main.php @@ -16,7 +16,7 @@ public function detectLanguage() if ($this->localize_Settings->get_permalink_plain_set()) { return $_GET['lang'] ?? null; } - return $this->findLanguageInUrl(get_permalink()); + return $this->findLanguageInUrl($this->getCurrentUrl()); } public function addLanguageToLinks($html, $args) { @@ -98,5 +98,10 @@ private function findLanguageInQuery($url) { return $queryArray['lang'] ?? null; } + + private function getCurrentUrl() { + $scheme = is_ssl() ? 'https' : 'http'; + return $scheme . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + } } } \ No newline at end of file