Last active
June 6, 2021 16:35
-
-
Save Jany-M/887c7430277ae8f226fa to your computer and use it in GitHub Desktop.
[WordPress] WPML Custom Language Selector
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (function_exists('icl_get_languages')) { | |
// Native Lang Name | |
function get_language_name($code=''){ | |
global $sitepress; | |
$details = $sitepress->get_language_details($code); | |
$language_name = $details['display_name']; //english_name //display_name | |
return $language_name; | |
} | |
// Custom Lang Selector | |
function languages_list_header(){ | |
$languages = icl_get_languages('skip_missing=0&orderby=code'); | |
if(!empty($languages)){ | |
foreach($languages as $l) { | |
if(!$l['active']) echo '<a class="btnLang" href="'.$l['url'].'" title="'.get_language_name($l['language_code']).'"><img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" /></a>'; | |
} | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment