WordPress.org

Ready to get started?Download WordPress

Forums

WPML flag in menu
[resolved] correction to the flag position - rtl (2 posts)

  1. Simon
    Member
    Posted 2 years ago #

    Hi,

    As I'm using an RTL language website,
    I added functionality to put the flag at the right side of the menu.

    Here is the corrected code,
    please update the plugin.

    function plugin_wpml_flag_in_menu($items, $args = NULL)
    {
    	if(function_exists('icl_get_languages'))
    	{
    		$new_items = '';
    		$languages = icl_get_languages('skip_missing=0&orderby=code');
    		if(!empty($languages)){
    			foreach($languages as $l){
    				// Exclude current viewing language
    				if($l['language_code'] != ICL_LANGUAGE_CODE)
    				{
    					$new_items .= '<li class="menu-item menu-item-type-post_type menu-item-object-page">';
    					if(!$l['active']) $new_items .= '<a href="'.$l['url'].'">';
    					if($l['country_flag_url']){
    						$new_items .= '<img src="'.$l['country_flag_url'].'" height="12" alt="'.$l['language_code'].'" width="18" />';
    					}
    					// $new_items .= icl_disp_language($l['native_name'], $l['translated_name']);
    					if(!$l['active']) $new_items .= '</a>';
    					$new_items .= '</li>';
    				}
    			}
    		}
    
    		// Place the flags at the correct side of the menu according to the the language direction
    		if (is_rtl())
    		{
    			$items = $new_items.$items;
    		} else {
    			$items .= $new_items;
    		}
    	}
    	return $items;
    }
    ?>

    Thank you for a very helpful plugin!

    Simon

    http://wordpress.org/extend/plugins/wpml-flag-in-menu/

  2. ramon fincken
    Member
    Plugin Author

    Posted 2 years ago #

    Thanks for your input. New version coming up!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.