lueDto( $this->determineLanguageCodeLength($languageCode), $languageData['url'], ), ); } return $list; } /** * This method returns the current site URL for the active language. * If the active language cannot be determined, it falls back to the default site URL. * * @return string the URL of the current site in the active language */ public function getSiteUrl(string $languageCode): string { $languages = $this->getActiveLanguages(); $url = $this->wpFunction->getSiteUrl(); foreach ($languages as $wpmlLanguageCode => $language) { if ($languageCode === $this->determineLanguageCodeLength($wpmlLanguageCode) && isset($language['url']) && is_string($language['url'])) { $url = $language['url']; break; } } return $url; } /** * This method returns `true` if the corresponding multi-language plugin is active. */ public function isActive(): bool { return defined('ICL_LANGUAGE_CODE'); } private function getActiveLanguages(): array { $null = null; $languages = $this->wpFunction->applyFilter('wpml_active_languages', $null); if (!is_array($languages)) { $languages = []; } return $languages; } }