Title: tomas.kuba's Replies | WordPress.org

---

# tomas.kuba

  [  ](https://wordpress.org/support/users/tomaskuba/)

 *   [Profile](https://wordpress.org/support/users/tomaskuba/)
 *   [Topics Started](https://wordpress.org/support/users/tomaskuba/topics/)
 *   [Replies Created](https://wordpress.org/support/users/tomaskuba/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/tomaskuba/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/tomaskuba/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/tomaskuba/engagements/)
 *   [Favorites](https://wordpress.org/support/users/tomaskuba/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Bogo] Multilingual Menus](https://wordpress.org/support/topic/multilingual-menus/)
 *  [tomas.kuba](https://wordpress.org/support/users/tomaskuba/)
 * (@tomaskuba)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/multilingual-menus/#post-4713857)
 * one more – if you want to have menu dynamically generated from pages that are
   in the actual locale only:
 *     ```
       function my_wp_nav_menu_args( $args = '' ) {
       	$args['fallback_cb'] = 'my_nav_menu_fallback';
       	return $args;
       }
       add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
   
       /**
        * Display or retrieve list of pages with optional home link - shows only pages
        * with current locale given by the Bogo plugin.
        *
        * Overrides wp_page_menu function
        *
        * @param array|string $args
        * @return string html menu
        */function my_nav_menu_fallback( $args = array() ) {
       	$defaults = array('sort_column' => 'menu_order, post_title', 'menu_class' => 'menu', 'echo' => true, 'link_before' => '', 'link_after' => '');
       	$args = wp_parse_args( $args, $defaults );
       	$args = apply_filters( 'wp_page_menu_args', $args );
   
       	$menu = '';
   
       	$list_args = $args;
   
       	// Show Home in the menu
       	if ( ! empty($args['show_home']) ) {
       		if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] )
       			$text = __('Home');
       		else
       			$text = $args['show_home'];
       		$class = '';
       		if ( is_front_page() && !is_paged() )
       			$class = 'class="current_page_item"';
       		$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '" title="' . esc_attr($text) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>';
       		// If the front page is a page, add it to the exclude list
       		if (get_option('show_on_front') == 'page') {
       			if ( !empty( $list_args['exclude'] ) ) {
       				$list_args['exclude'] .= ',';
       			} else {
       				$list_args['exclude'] = '';
       			}
       			$list_args['exclude'] .= get_option('page_on_front');
       		}
       	}
   
       	$list_args['echo'] = false;
       	$list_args['title_li'] = '';
   
       	// filter pages with current locale only
       	$list_args['meta_key'] = '_locale';
       	$list_args['meta_value'] = get_locale();
   
       	$menu .= str_replace( array( "\r", "\n", "\t" ), '', wp_list_pages($list_args) );
   
       	if ( $menu )
       		$menu = '<ul>' . $menu . '</ul>';
   
       	$menu = '<div class="' . esc_attr($args['menu_class']) . '">' . $menu . "</div>\n";
       	$menu = apply_filters( 'wp_page_menu', $menu, $args );
       	if ( $args['echo'] )
       		echo $menu;
       	else
       		return $menu;
       }
       ```
   
 * Again, it is not thoroughly testet so you should be careful when using this. 
   But it can at least give you an idea which way to go.
 * Feel free to use these source codes. I would be happy if it could become a part
   of the plugin.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Bogo] Multilingual Menus](https://wordpress.org/support/topic/multilingual-menus/)
 *  [tomas.kuba](https://wordpress.org/support/users/tomaskuba/)
 * (@tomaskuba)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/multilingual-menus/#post-4713856)
 * I added a small functionality in my twentythirteen template child which generates
   extra menus for each installed bogo language and switches them.
 * If you want to go that way, add this to functions.php in your template:
 *     ```
       function my_bogo_menu_setup() {
           $installed_locales = get_available_languages();
           $installed_locales[] = bogo_get_default_locale();
           $installed_locales[] = 'en_US';
           $installed_locales = array_unique( $installed_locales );
           $installed_locales = array_filter( $installed_locales );
   
           $bogo_languages = bogo_languages();
   
           foreach ( $installed_locales as $locale ) {
       	register_nav_menu( 'menu_'.$locale, $bogo_languages[$locale] );
           }
           unregister_nav_menu('primary');
       }
       ```
   
 * and then change your custom header.php this way (important is the line with wp_nav_menu
   call):
 *     ```
       <div id="navbar" class="navbar">
       				<nav id="site-navigation" class="navigation main-navigation" role="navigation">
       					<h3 class="menu-toggle"><?php _e( 'Menu', 'twentythirteen' ); ?></h3>
       					<a class="screen-reader-text skip-link" href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentythirteen' ); ?>"><?php _e( 'Skip to content', 'twentythirteen' ); ?></a>
       					<?php wp_nav_menu( array( 'theme_location' => 'menu_'.get_locale(), 'menu_class' => 'nav-menu' ) ); ?>
       					<?php get_search_form(); ?>
       				</nav><!-- #site-navigation -->
       			</div><!-- #navbar -->
       ```
   
 * if you want to automatically add pages to the correct menu by the language, you
   can add something like this to your functions.php:
 *     ```
       function _my_auto_add_pages_to_menu( $new_status, $old_status, $post ) {
           if ( 'publish' != $new_status || 'publish' == $old_status || 'page' != $post->post_type )
       	    return;
           if ( ! empty( $post->post_parent ) )
       	    return;
           $auto_add = get_option( 'nav_menu_options' );
           if ( empty( $auto_add ) || ! is_array( $auto_add ) || ! isset( $auto_add['auto_add'] ) )
       	    return;
           $auto_add = $auto_add['auto_add'];
           if ( empty( $auto_add ) || ! is_array( $auto_add ) )
       	    return;
   
           $args = array(
       	    'menu-item-object-id' => $post->ID,
       	    'menu-item-object' => $post->post_type,
       	    'menu-item-type' => 'post_type',
       	    'menu-item-status' => 'publish',
           );
   
           foreach ( $auto_add as $menu_id ) {
       	if ( 'menu_'.get_post_meta($post->ID, '_locale', true) == $menu_id ) {
       	    $items = wp_get_nav_menu_items( $menu_id, array( 'post_status' => 'publish,draft' ) );
       	    if ( ! is_array( $items ) )
       		    continue;
       	    foreach ( $items as $item ) {
       		    if ( $post->ID == $item->object_id )
       			    continue 2;
       	    }
       	    wp_update_nav_menu_item( $menu_id, 0, $args );
       	}
           }
       } 
   
       remove_action( 'transition_post_status',     '_wp_auto_add_pages_to_menu', 10, 3 );
       add_action( 'transition_post_status',     '_my_auto_add_pages_to_menu', 9, 3 );
       ```
   
 * It was a little hack I needed to do quite quickly so I did not play with it very
   much. Therefore I’m not sure whether it will run in all conditions. But it worked
   for me 🙂
 * Hope it helps somebody.
 * It would be nice to find a way how to integrate this into the plugin itself.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Root Relative URLs] Error with wp_mail function](https://wordpress.org/support/topic/error-with-wp_mail-function/)
 *  [tomas.kuba](https://wordpress.org/support/users/tomaskuba/)
 * (@tomaskuba)
 * [12 years, 9 months ago](https://wordpress.org/support/topic/error-with-wp_mail-function/#post-3603295)
 * I had a similar problem with WP e-commerce plugin and have found the cause – 
   the funcion “enable_content_massage” is added as a filter and therefore it should
   return the passing argument but it does not.
 * Open sb_root_relative_urls.php, find this:
 *     ```
       static function enable_content_massage() {
               //this is only called when an external feed is being called
               //this lets the content filter know that we should convert root relative urls back in to absolute urls since
               //some external sources don't understand the html spec
               self::$massage = true;
   
               //massage global post object
               global $post;
               $post->post_content = self::massage_external_content($post->post_content);
               $post->post_excerpt= self::massage_external_content($post->post_excerpt);
           }
       ```
   
 * and change it to this:
 *     ```
       static function enable_content_massage($myarg) {
               //this is only called when an external feed is being called
               //this lets the content filter know that we should convert root relative urls back in to absolute urls since
               //some external sources don't understand the html spec
               self::$massage = true;
   
               //massage global post object
               global $post;
               $post->post_content = self::massage_external_content($post->post_content);
               $post->post_excerpt= self::massage_external_content($post->post_excerpt);
               return $myarg;
           }
       ```
   
 * i.e. add a $myarg argument to the function header and return it in the end. This
   should do the trick.

Viewing 3 replies - 1 through 3 (of 3 total)