Skip to content

Instantly share code, notes, and snippets.

@jameslutley
Created January 2, 2014 21:44
Show Gist options
  • Select an option

  • Save jameslutley/8227505 to your computer and use it in GitHub Desktop.

Select an option

Save jameslutley/8227505 to your computer and use it in GitHub Desktop.
// Disable Included CSS Files
define ( 'ICL_DONT_LOAD_NAVIGATION_CSS', true );
define ( 'ICL_DONT_LOAD_LANGUAGE_SELECTOR_CSS', true );
define ( 'ICL_DONT_LOAD_LANGUAGES_JS', 'true');
function catBuild_WPML_languageSwitcher() {
if (function_exists('icl_get_languages')) {
$existing_languages = icl_get_languages('skip_missing=0');
foreach($existing_languages as $lang) {
if ($lang['active']) {
printf('
<li class="languageSelector %s dropdown">
<a class="dropdownToggle" href="%s">%s
<span class="flag">
<img src="%s" alt="%s">
</span>
<span class="dropdownArrow"></span>
</a>
',
$lang['language_code'],
$lang['url'],
$lang['native_name'],
$lang['country_flag_url'],
$lang['native_name']
);
break;
}
}
foreach($existing_languages as $lang) {
if (!$lang['active']) {
printf('
<ul class="subMenuDropdown">
<li class="%s">
<a href="%s">%s
<span class="flag">
<img src="%s" alt="%s">
</span>
</a>
</li>
',
$lang['language_code'],
$lang['url'],
$lang['native_name'],
$lang['country_flag_url'],
$lang['native_name']
);
}
}
printf('</ul></li>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment