Forum Replies Created

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter tarmakmedia

    (@tarmakmedia)

    Ok thanks for that, would you be able to point me as to which function handles the displaying of the language and the flag in the front and back end of wordpress?
    Something I wanna share that could be useful to enhance the display of the blogs in the back end. It basically adds the language and the flags next to your blogs in a dropdown menu of the admin bar. Also does so instead of the dashboard. Very useful to differentiate your blogs. Repo is at: https://github.com/tarmak/Wordpress-Multisite-Simple-Custom-Admin
    You can view the screenshots.
    You are welcome to use and adapt any code into your plugin:

    // Change the "My Sites" dropdown menu WP logos to the language flags and add the language locale at the end of the site name
    if ( ! function_exists( 'simplify_add_mysites_logo' ) ) {
    	function simplify_add_mysites_logo() {
    		global $wp_admin_bar;
    		foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    			$menu_id  = 'blog-' . $blog->userblog_id;
    			$blogname = empty( $blog->blogname ) ? $blog->domain : $blog->blogname;
    			if ( is_multisite( ) ) $lang = get_blog_option( $blog->userblog_id, 'WPLANG' );
    			else $lang = get_bloginfo( 'language' );
    			switch($lang){
    				case "":
    				$language = "EN";
    				$flag = "us";
    				break;
    				case "ar":
    				$language = "AR";
    				$flag = "lb";
    				break;
    				default:
    				$flag = strtolower( substr( $lang, -2 ) );
    				$language = strtoupper( substr( $lang, -2 ) );
    				break;
    			}
    			$blavatar = '<img src="' . content_url() .'/mu-plugins/simple-custom-admin/flags/' . $flag .'.png" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="11" class="blavatar"/>';
    			$wp_admin_bar->add_menu( array(
    				'parent'        => 'my-sites-list',
    				'id'            => $menu_id,
    				'title'         => $blavatar . $blogname . ' ' . $language ,
    				'href'          => get_admin_url( $blog->userblog_id ) )
    			);
                    }
    		$wp_admin_bar->remove_node('comments');
    		$wp_admin_bar->remove_node('new-content');
    		$wp_admin_bar->remove_node('wp-logo');
    		if ( is_multisite( ) ) { $wp_admin_bar->remove_node('site-name'); }
    		$wp_admin_bar->remove_node('network-admin');
    		$wp_admin_bar->remove_node('wpseo-menu');
    		$wp_admin_bar->remove_node('search');
    
    	if ( is_super_admin( ) && is_multisite( ) ) {
    		$wp_admin_bar->add_menu( array(
    					'id' 		=> 'network-administration',
    					'title' 	=>  __('Network Admin') ,
    					'href' 		=> get_admin_url( 1, 'network' )
    					));
    
    		$wp_admin_bar->add_menu( array(
    					'id' 		=> 'my-sites',
    					'href' 		=> '#',
    					));
    	}
        }
    }
    add_action( 'wp_before_admin_bar_render', 'simplify_add_mysites_logo' );
    
    // Replace the name "Dashboard" for each site with the language
    if ( ! function_exists( 'simplify_edit_admin_menus' ) ) {
    	function simplify_edit_admin_menus() {
    	    global $menu;
    	    global $userblog_id;
    		if ( is_multisite( ) ) { $lang = get_blog_option( $userblog_id, 'WPLANG' ); $blog_name = get_blog_option( $userblog_id, 'blogname') . " / "; }
    		else { $lang = get_bloginfo( 'language' ); $blog_name = get_option('blogname') . " / "; }
    		    switch($lang) {
    				case "":
    				$flag = "us";
    				$language = "EN";
    				break;
    				case "ar":
    				$language = "AR";
    				$flag = "lb";
    				break;
    				default:
    				$flag = strtolower( substr( $lang, -2 ) );
    				$language = strtoupper( substr( $lang, -2 ) );
    				break;
    			}
    		$menu[2] = array( $blog_name . $language, 'read', 'index.php', '', 'menu-top menu-top-first', 'menu-dashboard', content_url() .'/mu-plugins/simple-custom-admin/flags/' . $flag .'.png' );
    	}
    }
    add_action( 'admin_menu', 'simplify_edit_admin_menus' );
    Thread Starter tarmakmedia

    (@tarmakmedia)

    Yes language values are set in the the blogs.

    I can only think of something alone the lines of getting the language:

    $lang = get_blog_option( $blog->userblog_id, 'WPLANG' );

    And then forcing the flags for the culprits:

    switch($lang){
    				case "":
    				$language = "EN";
    				$flag = "us";
    				break;
    				case "ar":
    				$language = "AR";
    				$flag = "lb";
    				break;
    				default:
    				$flag = strtolower( substr( $lang, -2 ) );
    				$language = strtoupper( substr( $lang, -2 ) );
    				break;
    			}

    But this does not seem like a very efficient solution.
    Are you able to reproduce this problem from your side when installing Arabic?

    Thread Starter tarmakmedia

    (@tarmakmedia)

    Sorry you are right, I typed it the wrong way around. I have those settings, however I cannot get it to display the right flag in the back and front end. I have been looking through pages of code and even resulted to renaming the actual image files to over come this problem.
    Could you perhaps point me into the direction if where to find this in your code as it seems to happen when wordpress does not specify any locale?
    Thanks

    Thread Starter tarmakmedia

    (@tarmakmedia)

    Nice one +1 for this feature, but would it not also make sense to remove the article from the dropdown via a function as for example one article only has one translation for each language so if the translation or link exists then it does not make sense to keep it in the list.
    ET

    Same for me.
    Another problem is that I have deleted some profiles and created new ones which do not appear in the list at the moment. Could this be a caching issue. The fact that you see deleted profile is really a problem as I have a long list of them and things start getting a bit confusing.
    Is there a way to resolve this? Have tried removing plugin, de-authorizing GA and resetting it without any success. Does GA archive the profiles and the plugin calls in on this archive rather than the active ones?
    Thanks
    ET

    Thanks for that update on your side. So far I reverted back to 1.4.7 which seems more stable on my setup. Did you upgrade wordpress to 3.5.2
    ET

    Does the latest version 1.4.10 fix this issue?

    Same thing here! This however only happens when logged in the admin area. Anonymous users do not see the page twice.
    Seems to be a bug. I have wordpress Multisite installed BTW

    Thread Starter tarmakmedia

    (@tarmakmedia)

    Thanks for the swift reply. With GA I have seperate profile names and property names. It seems that your plugin pulls the root domain for each site rather than the profile name from GA’s API. So it ends up with all sites being named example.com rather than example.com/1/ + example.com/2/

    I found that the galleries cannot be shared between sites within the same network. This functionality would be a great addition. I wonder if this is technically possible or if wordpress has restrictions within the way it deals with galleries.
    Great plugin!

    Thread Starter tarmakmedia

    (@tarmakmedia)

    Cool thanks Sayontan, that worked!
    Great plugin will get my vote !
    ET

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