Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Wordpress - Enfold theme - qTranslate language switcher

By: a guest on Nov 11th, 2013  |  syntax: PHP  |  size: 1.12 KB  |  views: 97  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. /**
  2.  * Generate an Enfold compatible qTranslate language switcher
  3.  *
  4.  * @return void
  5.  */
  6. function qtrans_generate_enfold_compatible_language_switcher()
  7. {
  8.         global $q_config;
  9.         $languages = qtrans_getSortedLanguages();
  10.         $num_langs = count($languages);
  11.         $url = is_404() ? get_option('home') : '';
  12.  
  13.         wp_enqueue_style( 'avia-wpml', AVIA_BASE_URL.'config-wpml/wpml-mod.css');
  14.  
  15.         $output = '';
  16.         $output .= "<ul class='avia_wpml_language_switch'>";
  17.  
  18.         if(is_array($languages))
  19.         {
  20.                 foreach ($languages as $lang)
  21.                 {
  22.                         $currentlang = ($lang == $q_config['language']) ? 'avia_current_lang' : '';
  23.  
  24.                         $output .= "<li class='language_".$lang." $currentlang'><a href='".qtrans_convertURL($url, $lang)."'>";
  25.                         $output .= "<span class='language_flag qtrans_flag_" . $lang . " qtrans_flag'></span>";
  26.                         $output .= "<span class='language_native'>".$q_config['language_name'][$lang]."</span>";
  27.                         $output .= "<span class='language_translated'>".$q_config['language_name'][$lang]."</span>";
  28.                         $output .= "<span class='language_code'>".$lang."</span>";
  29.                         $output .= "</a></li>";
  30.                 }
  31.         }
  32.  
  33.         $output .= "</ul>";
  34.  
  35.         echo $output;
  36. }