Last active
March 1, 2016 08:11
-
-
Save pixedelic/b8d898343aa678d0ee97 to your computer and use it in GitHub Desktop.
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 | |
function pixedelic_wpml_custom_switch() { | |
$args = apply_filters( 'logan_custom_language_switcher_args', 'skip_missing=0&orderby=code&link_empty_to=' . esc_url(get_home_url() ) ); | |
$languages = icl_get_languages( $args ); | |
if ( !empty( $languages ) ) { | |
foreach($languages as $lang => $l) { | |
if ( $l['active'] ) { | |
$active = $lang; | |
break; | |
} | |
} | |
$out = '<ul class="wpml_custom_language_top_selector">'; | |
$langs = ''; | |
$out .= '<li>'; | |
if ( apply_filters('logan_custom_language_switcher_flag', false) ) | |
$out .= '<img src="'.$languages[$lang]['country_flag_url'].'" alt="'.$languages[$lang]['language_code'].'">'; | |
if ( apply_filters('logan_custom_language_switcher_name', true) ) | |
$out .= '<span class="wpml-native-name">' . $languages[$lang]['native_name'] . '</span>'; | |
foreach($languages as $l){ | |
if ( !$l['active'] ) { | |
$langs .= '<li><a href="'.esc_url($l['url']).'">'; | |
if ( apply_filters('logan_custom_language_switcher_flag', false) ) | |
$langs .= '<img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'">'; | |
if ( apply_filters('logan_custom_language_switcher_name', true) ) | |
$langs .= '<span class="wpml-native-name">' . $l['native_name'] . '</span>'; | |
$langs .= '</a></li>'; | |
} | |
} | |
$out .= '<ul>' . $langs . '</ul>'; | |
$out .= '</li>'; | |
$out .= '</ul>'; | |
return $out; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment