Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Qtranslate and Custom WordPress Menus

By: brasofilo on Oct 6th, 2011  |  syntax: PHP  |  size: 1.17 KB  |  hits: 2,063  |  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. <?php
  2. /*
  3.  * Qtranslate and Custom WordPress Menus
  4.  * Install : Drop in your functions.php, or create a simple plugin (and drop all your functions there)
  5.  * Description : Display translated page names in Wordpress custom menus configuration page
  6.  * Author : chudoff.a in WP Forums -> http://goo.gl/7FW04
  7.  * Observations : added an error prevention if(function_exists()), in case Qtranslate is inactive
  8.  * Update March 2012 : the error prevention is preventing this hook to work :) with WP 3.3.1 and QT 2.5.28 - faulty lines disabled
  9.  */
  10. // if ( function_exists("qtrans_useTermLib") ) {
  11.         function qtrans_menuitem2( $item ) {
  12.                 foreach ($item as $key=>$values){
  13.                 $item[$key]->title = qtrans_useTermLib($values->title);
  14.         }
  15.         qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $item->title );
  16.            return $item;
  17.         }
  18.         add_filter('wp_nav_menu_objects', 'qtrans_menuitem2', 0);
  19.  
  20.         function qtrans_menuitem( $menu_item ) {
  21.            $menu_item->title = qtrans_useCurrentLanguageIfNotFoundUseDefaultLanguage( $menu_item->title );
  22.            $menu_item->title = qtrans_useTermLib( $menu_item->title );
  23.            return $menu_item;
  24.         }
  25.         add_filter('wp_setup_nav_menu_item', 'qtrans_menuitem', 0);
  26. //}
  27. ?>