2015-05-28 20:35:00

Related Docs

Do You Need Help or Expertise?

Is editing Source Code not Your Thing? Are you in a tight Time Schedule and need to deliver a fully scalable and safe solution fast to your Clients?

Maybe you want to incorporate the Software found on TukuToi unbranded and royalty free in your Clients Projects after customizing it as per your Projects requirements?

Or eventually you need some training on any WordPress Plugin, Theme or their creation and maintenance?

ShortCodeInline Language Switcher – Flags/Code/Code+Flags

Inline (horizontal) custom language selector with different options such as Flags only, Code only, Flags + Code with divisor.
Take the time to study the code.

To use call wpml_custom_language_selector(); in a template

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>';
		}
	}
}