From 7c18257830fe2d08fa27345f4e1285c18cf14cb9 Mon Sep 17 00:00:00 2001 From: Mark Fabrizio Date: Mon, 30 Mar 2026 09:51:56 -0400 Subject: [PATCH] fix: update language detection to use current URL instead of permalink --- trunk/includes/class-localize-main.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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