Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Inline (horizontal) custom language selector
- *
- * To use call wpml_custom_language_selector(); in a template
- * Note: Take the time to study the output code.
- */
- function wpml_custom_language_selector(){
- // check if wpml is installed
- if (function_exists('icl_get_languages')) {
- // get active languages. Available params here:
- // http://wpml.org/documentation/getting-started-guide/language-setup/custom-language-switcher/
- $languages = icl_get_languages('skip_missing=0&orderby=code&order=desc');
- if(!empty($languages)){
- echo '<div class="lang_selector">';
- foreach($languages as $l){
- // from this point on, uncomment whatever output you like
- // flags only - do not display current language
- /* if(!$l['active']){
- echo '<a href="'.$l['url'].'">
- <img src="'.$l['country_flag_url'].'" alt="'.$l['language_code'].'" />
- </a>';
- } */
- // the output code options below will display the current language
- // this adds an "active" class to the current language anchor
- $class = $l['active'] ? ' class="active"' : NULL;
- // code only
- /*$langs .= '<a ' . $class . ' href="'.$l['url'].'">' . strtoupper ($l['language_code']). '</a> | ';*/
- //flag-code divided by a |
- /*$langs .= '<a ' . $class . ' href="' . $l['url'] . '"><img src="' . $l['country_flag_url'] . '" alt="' . $l['language_code'] . '" />' . strtoupper ($l['language_code']). '</a> | ';*/
- }
- // strip the empty space and | from last language
- $langs = substr($langs,0,-3);
- echo $langs;
- echo '</div>';
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement