Created
March 10, 2016 20:51
-
-
Save lonchbox/999616a3586f2817af71 to your computer and use it in GitHub Desktop.
WPML custom language switcher
This file contains 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 | |
/* | |
* WPML language switcher customizations: htp://wpml.org | |
*/ | |
function custom_wpml_lang_switcher() { | |
if (function_exists('icl_get_languages')){ | |
// remove WPML default css | |
define('ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true); | |
// Custom language layout selector ?> | |
<div class="languages"> | |
<ul> | |
<?php | |
$languages = icl_get_languages('skip_missing=N&orderby=KEY&order=DIR&link_empty_to=str'); | |
foreach($languages as $language){ | |
//$flag = $language['country_flag_url']; | |
$url = $language['url']; | |
$isActive = $language['active']; | |
$name = $language['native_name'] | |
?> | |
<li> | |
<a class="<?php if($isActive == 1){ ?> class="active" <?php } ?>" href="<?php echo $url; ?>"> | |
<?php echo $name; ?> | |
</a> | |
</li> | |
<?php } ?> | |
</ul> | |
<?php } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment