Use Admin toolbar switch button in Multisite Admin bar Switcher

I have a little project I am going to try to accomplish for us all. I want to use the Multisite Admin bar Switcher plug in - it's pretty cool, and for a large multisite network will really help. The problem is, when you turn it on, it eliminates the current site admin drop down (the house logo-ed menu) and just uses the MySites drop down. Now, I want Easy Mode to be available to be turned on and off, and the Use Admin toolbar switch button, puts it in the House logo-ed drop down. I have asked the plug in author for help as to where I would be able to move the easy mode link to his plug in, so the other side of the equation is, what is the exact code I will want to use to add once I know where it would go in his plug in.

With a little testing and doing here, I think this would probably work out fine and provide a new option for us multisite operators with networks that will have a lot of sites. So if I can find out what I need to know here, I'll do the leg work and testing, and post the results and procedure to get it working.

  • Adam Czajczyk

    Hey AIPMan1,

    I hope you're well today and thank you for your question!

    First of all, please check our "Custom Admin Bar" plugin. It will let you customize logo, menu, links etc of the admin bar right through your dashboard. It's also capable of altering the "About" menu (this "WP-icon" menu). There's a good chance that you'll find it a handy tool :slight_smile:

    https://premium.wpmudev.org/project/custom-admin-bar/

    You may also find this article useful:
    http://codex.wordpress.org/Function_Reference/add_menu_page

    If you have any further questions, please ask. I'll be glad to assist!

    Cheers,
    Adam

  • AIPman1

    I'll look at the codex article when i can. I'm not using the WP icon menu at all, and know about the custom admin bar tools - have it already set up, and the plug in I refer to works with it just fine. I'll have to look at adding an easy mode switcher that way only if the Multisite Admin Bar switcher plugin won't allow me to add it in...as I would like to keep it with the site's links. I'll have to look closer at the specific code the EASY MODE adds to the admin bar when turned on and how it gets there, I was just hoping someone would be able to say "That file is in XXX folder" so I knew what file to look for without spending hours of searching for it.

    Will post results as I can. Still waiting to hear from the plug in developer as to best way to leverage his code to do it.

  • AIPman1

    Yes, I mean the button in the admin bar that allows you to switch easy mode on and off. I like it there, and put it there in the settings of easy blogging...but the other plug in I want to use, then eliminates the spot where easy blogging puts that link in the admin bar...so I am looking to make custom code to add it to the other plug in...however, the plug in developer has yet to respond to my request for info, so I may be on my own on it. I will be looking at this deeper this week now that the new issue of our magazine has been released.

  • AIPman1

    I have located the specific Easy Blogging plugin I need to be able to hijack/move the link:
    Admin toolbar switch button
    Replace the standard Easy mode toggle button with an Admin toolbar menu entry.
    Version 1.0 | by Ve Bailovity (Incsub)

    Where, specifically, is that code? I'll keep looking but my work day is just about done. If anyone can tell me for the morning, it'd really jump start my day!

  • AIPman1

    OK! I think this is the file that does the work:
    at /wp-content/plugins/easyblogging/lib/plugins/wdeb-theme-toolbar_switch_button.php

    <?php
    /*
    Plugin Name: Admin toolbar switch button
    Description: Replace the standard Easy mode toggle button with an Admin toolbar menu entry.
    Plugin URI: https://premium.wpmudev.org/project/easy-blogging
    Version: 1.0
    Author: Ve Bailovity (Incsub)
    */
    
    class Wdeb_Theme_ToolbarSwitchButton {
    
    	private function __construct () {}
    
    	public static function serve () {
    		$me = new Wdeb_Theme_ToolbarSwitchButton;
    		$me->_add_hooks();
    	}
    
    	private function _add_hooks () {
    		add_action('admin_print_scripts', array($this, 'dequeue_scripts'), 19);
    		add_action('admin_bar_menu', array($this, 'add_to_admin_bar'), 99);
    	}
    
    	function dequeue_scripts () {
    		wp_dequeue_script('wdeb_switch');
    	}
    
    	function add_to_admin_bar () {
    		global $wp_admin_bar;
    		if (!(defined('WDEB_IS_IN_EASY_MODE') && WDEB_IS_IN_EASY_MODE)) {
    			$href = apply_filters('wdeb_easy_mode_init', WDEB_LANDING_PAGE . '?wdeb_on');
    			$title = __('Activate easy mode', 'wdeb');
    		} else {
    			$data = new Wdeb_Options;
    			$auto_enter_roles = $data->get_option('auto_enter_role');
    			if (!$auto_enter_roles || !wdeb_current_user_can($auto_enter_roles)) {
    				$href = apply_filters('wdeb_easy_mode_init', WDEB_LANDING_PAGE . '?wdeb_off');
    				$title = __('Exit easy mode', 'wdeb');
    			} else return false; // Not showing exit easy mode link if not applicable
    		}
    		$wp_admin_bar->add_menu(array(
    			'parent' => 'site-name',
    			'id' => 'wdeb-my_sites-ttsb',
    			'title' => $title,
    			'href' => $href,
    		));
    	}
    }
    if (is_admin()) Wdeb_Theme_ToolbarSwitchButton::serve();

    My limited knoweldge of code tells me the 'parent' => 'site-name', is likely what places it into the menu with the house logo...the question is then, what is the code to use to place it under the lock-logo-ed menu "my sites" or even better put it into it's own menu. or an in-use custom menu. Perhaps NOT putting it into the "my sites" would be best because the other plug in changes it anyway.

  • AIPman1

    Well, after playing with it and digging in to the other plug in, I have come to the conclusion hat it will be a LOT easier to just turn off the easy blogging admin button plug in, let it show in the admin bar as turn on easy mode from there, and let people go out of easy mode on the bottom of the dashboard left column. I think it would be a messy thing to try to get the plug ins to play together...this sides steps that, not as pretty in use, but functional. sorry if I got anyone's hopes up.

  • AIPman1

    LOL, you rock Adam, no worries. I sometimes do much better working out a thought or idea by putting it "out there" and then figure it out. Having the Easy Mode toggle on in the admin bar but off at the bottom of the dashboard left side does confuse newbs a bit, I wouldn't MIND working on bringing the Admin toolbar switch button plug in of the easy blogging system, to work with the Multisite Admin bar Switcher

    I am not sure if the plug in developer would have any interest in doing anything for it, he replied in my thread about how I did the improvements to his work by basically saying I should make my own plug in...but I'm not a coder, I couldn't do one from scratch really. The improvements I did make it rock though, lol. you can see it in action at indyfestusa.com - coupled with the Join My Multisite plug in, so when a user visits a site in multisite they become a member of it...it adds sites to the alphabet as they visit them, kinds like a bookmarking system so they can easily get back to sites they visited in the network...and the full directory is still elsewhere so it doesn't overwhelm new members with all these sites in the drop down.

    There's only one php file to edit so somewhere in there is the info we need to be able to send the easy mode toggle button to the right place. Here's the code (as I have it edited):

    <?php
    /*
    	Plugin Name: Multisite Admin bar Switcher
    	Plugin URI: http://www.flynsarmy.com
    	Description: Replaces the built in 'My Sites' drop down with a better layed out one
    	Version: 1.1
    	Author: Flyn San
    	Author URI: http://www.flynsarmy.com/
    
    	Copyright 2013  Flyn San  (email : flynsarmy@gmail.com)
    
    	This program is free software; you can redistribute it and/or modify
    	it under the terms of the GNU General Public License, version 2, as
    	published by the Free Software Foundation.
    
    	This program is distributed in the hope that it will be useful,
    	but WITHOUT ANY WARRANTY; without even the implied warranty of
    	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    	GNU General Public License for more details.
    
    	You should have received a copy of the GNU General Public License
    	along with this program; if not, write to the Free Software
    	Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    */
    
    function mabs_require_with($partial, $data)
    {
    	extract($data);
    	ob_start();
    		require $partial;
    	return ob_get_clean();
    }
    
    // From http://wordpress.stackexchange.com/questions/16474/how-to-add-field-for-new-site-wide-option-on-network-settings-screen
    add_action('network_admin_menu', function() {
    	add_submenu_page('settings.php', 'Multisite Admin Bar Switcher', 'Multisite Admin Bar Switcher', 'manage_network_options', 'mabs-settings', function() {
    		echo mabs_require_with(dirname(__FILE__).'/partials/network-admin/settings.php', array(
    			'options' => get_site_option('mabs'),
    		));
    	});
    });
    
    add_action('wp_ajax_clear_mabs_cache', function() {
    	mabs_clear_cache();
    	exit("Cache cleared.");
    });
    
    add_action('admin_bar_menu', function() {
    	// No need to show MABS
    	if ( !is_multisite() || !is_admin_bar_showing() )
    		return;
    
    	global $wp_admin_bar, $wpdb, $current_blog;
    
    	$wp_admin_bar->remove_node('my-sites');
    	$wp_admin_bar->remove_node('site-name');
    
    	$current_user = wp_get_current_user();
    	$bloginfo = mabs_convert_blog_fields($current_blog);
    
    	// current site path
    	if ( is_network_admin() )
    	{
    		$blogname = __('Network');
    		$url = get_home_url( $current_blog->blog_id );
    	}
    	elseif ( is_admin() )
    	{
    		$blogname = get_blog_option($current_blog->blog_id, "blogname");
    		$url = get_home_url( $current_blog->blog_id );
    	}
    	else
    	{
    		$blogname = get_blog_option($current_blog->blog_id, "blogname");
    		$url = get_admin_url( $current_blog->blog_id );
    	}
    	// Add top menu
    	$wp_admin_bar->add_menu(array(
    		'parent' => false,
    		'id' => 'mabs',
    		'title' => trim(__('Site Organizer:') . ' ' . apply_filters('mabs_blog_name', $blogname, $bloginfo)),
    		'href' => str_replace('/wp-admin/', '', $url)
    	));
    
    	// Add 'Your Site'
    	$url = get_admin_url( $current_blog->blog_id );
    	$wp_admin_bar->add_menu(array(
    		'parent' => 'mabs',
    		'id' => 'mabs_yoursite',
    		'title' =>__('This Site'),
    		'href' => str_replace('/wp-admin/', '', $url)
    	));
    	mabs_display_blog_pages($current_user, 'yoursite', $url);
    
    	// Add 'Network'
    	if ( current_user_can('manage_network') )
    	{
    		// add network menu
    		$url = network_admin_url();
    		$wp_admin_bar->add_menu(array(
    			'parent' => 'mabs',
    			'id' => 'mabs_network',
    			'title' =>__('Network'),
    			'href' => $url,
    		));
    		mabs_display_blog_pages($current_user, 'network', $url);
    	}
    
    	// Add users' blogs
    	mabs_display_blogs_for_user( $current_user );
    }, 40);
    
    add_action( 'wp_enqueue_scripts', 'mabs_enqueue_assets' );
    add_action( 'admin_enqueue_scripts', 'mabs_enqueue_assets' );
    function mabs_enqueue_assets( ) {
    	if ( !is_admin_bar_showing() || !is_user_logged_in() || mabs_site_count_below_minimum(wp_get_current_user()) )
    		return;
    
    	wp_enqueue_script( 'mabs_site_filter', plugins_url( 'assets/js/mabs_site_filter.js', __FILE__ ), array('jquery'), '2014.09.25', true );
    	wp_enqueue_style( 'mabs_site_filter', plugins_url( 'assets/css/mabs_site_filter.css', __FILE__ ) );
    }
    
    add_action( 'wpmu_new_blog', 'mabs_clear_cache');
    add_action( 'wpmu_activate_blog', 'mabs_clear_cache');
    
    add_action('add_user_to_blog', function($user_id) {
    	mabs_clear_user_cache($user_id);
    }, 10, 1);
    add_action('added_existing_user', function($user_id) {
    	mabs_clear_user_cache($user_id);
    }, 10, 1);
    add_action('remove_user_from_blog', function($user_id, $blog_id) {
    	mabs_clear_user_cache($user_id);
    }, 10, 2);
    
    function mabs_clear_cache()
    {
    	if ( !is_user_logged_in() )
    		return;
    
    	$user = wp_get_current_user();
    	wp_cache_delete('mabs_bloglist_'.$user->ID, 'mabs');
    }
    function mabs_clear_user_cache($user_id)
    {
    	wp_cache_delete('mabs_bloglist_'.$user_id, 'mabs');
    }
    
    function mabs_site_count_below_minimum($user)
    {
    	$blogs = mabs_get_blog_list( $user );
    
    	return sizeof($blogs) < 5;
    }
    
    /**
     * Adds a blogs submenu items to the admin drop down menu.
     *
     * @param  string $blog_type 'site' or 'network'
     * @param  integer $id   site ID
     * @param  string $url  '<url>'
     *
     * @return void
     */
    function mabs_display_blog_pages( $user, $id, $admin_url )
    {
    	global $wp_admin_bar;
    	if ( $id == 'network' )
    		$pages = array(
    			'dashboard'     => array('url' => 'index.php'),
    			'sites'         => array('url' => 'sites.php'),
    			'users'         => array('url' => 'users.php'),
    			'themes'        => array('url' => 'themes.php'),
    			'plugins'       => array('url' => 'plugins.php'),
    			'settings'      => array('url' => 'settings.php'),
    			'updates'       => array('url' => 'update-core.php'),
    		);
    	else
    		$pages = array(
    			'dashboard'     => array('url' => 'index.php',          'permission' => 'edit_posts'),
    			'visit'         => array('url' => ''),
    			'posts'         => array('url' => 'edit.php',           'permission' => 'edit_posts'),
    			'media'         => array('url' => 'media.php',          'permission' => 'edit_posts'),
    			'links'         => array('url' => 'link-manager.php',   'permission' => 'manage_links'),
    			'pages'         => array('url' => 'edit.php?post_type=page', 'permission' => 'edit_pages'),
    			'comments'      => array('url' => 'edit-comments.php',  'permission' => 'edit_posts'),
    			'appearance'    => array('url' => 'themes.php',         'permission' => 'switch_themes'),
    			'plugins'       => array('url' => 'plugins.php',        'permission' => 'install_plugins'),
    			'users'         => array('url' => 'users.php',          'permission' => 'list_users'),
    			'tools'         => array('url' => 'tools.php',          'permission' => 'import'),
    			'settings'      => array('url' => 'options-general.php','permission' => 'manage_options'),
    		);
    
    	$pages = apply_filters('mabs_blog_pages', $pages, $id, $user);
    
    	foreach ( $pages as $key => $details )
    	{
    		if ( $key == "visit" )
    			$wp_admin_bar->add_menu(array(
    				'parent' => 'mabs_'.$id,
    				'id' =>'mabs_'.$id.'_'.$key,
    				'title'=>__('Visit Site'),
    				'href'=>str_replace('wp-admin/','',$admin_url)
    			));
    		elseif ( empty($details['permission']) || user_can($user->ID, $details['permission']) )
    			$wp_admin_bar->add_menu(array(
    				'parent' => 'mabs_'.$id,
    				'id' =>'mabs_'.$id.'_'.$key,
    				'title'=> isset($details['title']) ? $details['title'] : __(ucfirst($key)),
    				'href' => $admin_url.$details['url']
    			));
    	}
    }
    
    /**
     * Add the blog list under their respective letters
     *
     * @param  stdClass $user A wordpress user
     *
     * @return void
     */
    function mabs_display_blogs_for_user( $user )
    {
    	global $wp_admin_bar, $wpdb;
    
    /*	// Add Filter field
    	if ( !mabs_site_count_below_minimum($user) )
    		$wp_admin_bar->add_menu(array(
    			'parent' => 'mabs',
    			'id'     => 'mabs_site_filter',
    			'title'  => '<label for="mabs_site_filter_text">'. __( 'Filter My Sites', 'mabs' ) .'</label>' .
    						'<input type="text" id="mabs_site_filter_text" autocomplete="off" placeholder="'. __( 'Search Sites', 'mabs' ) .'" />',
    			'meta'   => array(
    				'class' => 'hide-if-no-js'
    			)
    		));
    */
    	$blogs = mabs_get_blog_list( $user );
    
    	//Add letter submenus
    	mabs_display_letters( $blogs );
    
    	// add menu item for each blog
    	$i = 1;
    	foreach ( $blogs as $key => $blog )
    	{
    		$letter = strtoupper(substr($key, 0, 1));
    		$site_parent = "mabs_".$letter."_letter";
    		$admin_url = get_admin_url( $blog->userblog_id );
    
    		//Add the site
    		$wp_admin_bar->add_menu(array(
    			'parent' => $site_parent,
    			'id' => 'mabs_'.$letter.$i,
    			'title' => apply_filters('mabs_blog_name', $blog->blogname, $blog),
    			'href' => str_replace('wp-admin/','',$admin_url),
    			'meta' => array(
    				'class' => 'mabs_blog',
    			),
    		));
    
    		//Add site submenu options
    
    		$i++;
    	}
    }
    
    /**
     * Adds a letter submenu for each blog to sit in
     *
     * @param  array  $blogs List of blogs
     *
     * @return void
     */
    function mabs_display_letters( array $blogs )
    {
    	global $wp_admin_bar;
    
    	$letters = array();
    	foreach ( $blogs as $key => $blog )
    		$letters[ strtoupper(substr($key, 0, 1)) ] = '';
    
    	foreach ( array_keys($letters) as $letter )
    		$wp_admin_bar->add_menu(array(
    			'parent' => 'mabs',
    			'id' => 'mabs_'.$letter.'_letter',
    			'title' => __($letter),
    			'meta' => array(
    				'class' => 'mabs_letter',
    			),
    		));
    }
    
    /**
     * Returns an alphabetically sorted array of blogs
     *
     * @param  stdClass $user Current user object
     *
     * @return array       Alphabetically sorted array of blogs
     *      stdClass Object
     *      (
     *          [userblog_id] => 1
     *          [blogname] => My Blog
     *          [domain] => myblog.localhost.com
     *          [path] => /
     *          [site_id] => 1
     *          [siteurl] => http://myblog.localhost.com
     *          [archived] => 0
     *          [spam] => 0
     *          [deleted] => 0
     *      )
     */
    $mabs_user_blog_list = array();
    function mabs_get_blog_list( $user )
    {
    	global $mabs_user_blog_list;
    
    	// Only do this once
    	if ( !isset($mabs_user_blog_list[$user->ID]))
    	{
    		// Try to retrieve sorted list from cache
    		$cache = wp_cache_get('mabs_bloglist_'.$user->ID, 'mabs');
    		if ( $cache )
    			$sorted = $mabs_user_blog_list[$user->ID] = $cache;
    
    		if ( empty($mabs_user_blog_list[$user->ID]) )
    		{
    			if ( user_can($user, 'manage_network') )
    				$unsorted_list = mabs_get_blogs_of_network();
    			else
    				$unsorted_list = get_blogs_of_user( $user->ID );
    
    			$sorted = array();
    
    			// Add blogname to key list. Also add a number so we
    			// are certain keys are unique
    			foreach ( $unsorted_list as $key => $blog )
    				$sorted[ strtoupper($blog->blogname) . $key ] = $blog;
    
    			ksort($sorted);
    
    			// Cache sorted list for 30 mins
    			wp_cache_set('mabs_bloglist_'.$user->ID, $sorted, 'mabs', apply_filters('mabs_cache_duration', 60*60*30));
    
    			$mabs_user_blog_list[$user->ID] = $sorted;
    		}
    	}
    	else
    		$sorted = $mabs_user_blog_list[$user->ID];
    
    	return $sorted;
    }
    
    function mabs_get_blogs_of_network()
    {
    	// This method returns different info than get_blogs_of_user(). So make it the same
    	$blog_list = wp_get_sites();
    	$unsorted_list = array();
    
    	foreach ( $blog_list as $id => $info )
    	{
    		$userblog_id = intval($info['blog_id']);
    		$unsorted_list[$userblog_id] = mabs_convert_blog_fields($info);
    	}
    
    	return $unsorted_list;
    }
    
    /**
     * The wp_get_sites() method returns an array with different fields to
     * get_blogs_of_user(). This method converts fields in the former to the latter.
     *
     * @param  array $fields
     *           [blog_id] => 1
     *           [site_id] => 1
     *           [domain] => myblog.localhost.com
     *           [path] => /
     *           [registered] => 2012-04-17 02:42:46
     *           [last_updated] => 2014-09-24 00:46:15
     *           [public] => 1
     *           [archived] => 0
     *           [mature] => 0
     *           [spam] => 0
     *           [deleted] => 0
     *           [lang_id] => 0
     *
     * @return stdClass Object
     *      (
     *          [userblog_id] => 1
     *          [blogname] => My Blog
     *          [domain] => myblog.localhost.com
     *          [path] => /
     *          [site_id] => 1
     *          [siteurl] => http://myblog.localhost.com
     *          [archived] => 0
     *          [spam] => 0
     *          [deleted] => 0
     *      )
     */
    function mabs_convert_blog_fields($fields)
    {
    	// Make sure we're always working with an array
    	$fields = (array)$fields;
    	$userblog_id = intval($fields['blog_id']);
    
    	return (object)array(
    		'userblog_id' => $userblog_id,
    		'blogname' => get_blog_option($fields['blog_id'], 'blogname'),
    		'domain' => $fields['domain'],
    		'path' => $fields['path'],
    		'site_id' => $fields['site_id'],
    		'siteurl' => get_blog_option($fields['blog_id'], 'siteurl'),
    		'archived' => intval($fields['archived']),
    		'spam' => intval($fields['spam']),
    		'deleted' => intval($fields['deleted']),
    	);
    }
    
    ?>

    this is what removes the original my sites and the site menu that the Admin toolbar switch button sends the toggle button to...

    $wp_admin_bar->remove_node('my-sites');
    	$wp_admin_bar->remove_node('site-name');

    this is what adds all the links to the current site being visited that have the permissions set so they only show if you have the access to do them (I modified a couple because they showed the dashboard link even if you didn't have permission, and the media link always showed, so I limited it as well)

    $pages = array(
    			'dashboard'     => array('url' => 'index.php',          'permission' => 'edit_posts'),
    			'visit'         => array('url' => ''),
    			'posts'         => array('url' => 'edit.php',           'permission' => 'edit_posts'),
    			'media'         => array('url' => 'media.php',          'permission' => 'edit_posts'),
    			'links'         => array('url' => 'link-manager.php',   'permission' => 'manage_links'),
    			'pages'         => array('url' => 'edit.php?post_type=page', 'permission' => 'edit_pages'),
    			'comments'      => array('url' => 'edit-comments.php',  'permission' => 'edit_posts'),
    			'appearance'    => array('url' => 'themes.php',         'permission' => 'switch_themes'),
    			'plugins'       => array('url' => 'plugins.php',        'permission' => 'install_plugins'),
    			'users'         => array('url' => 'users.php',          'permission' => 'list_users'),
    			'tools'         => array('url' => 'tools.php',          'permission' => 'import'),
    			'settings'      => array('url' => 'options-general.php','permission' => 'manage_options'),

    PERHAPS there is a simple way to add in a link to this list that would toggle the easy mode on or off, WITHOUT actually using the easy blogging plug in to do it? That would actually be the best way to add it I think. I just have no idea what to write code-wise to do that. since we can limit it showing to only site admins of that site it would not be interfering with anyone else.

    What do you think? Am I on the right track with that line of thinking? Cause then you could turn back off the one that displays on the admin bar itself...and it would be in the same place for both turning on and off easy mode.

  • Adam Czajczyk

    Hey @AIPman1,

    I hope you're well today!

    Thanks for posting this code along with an explanation. This made me heading in a right direction, although I'm a bit surprised that I didn't thought of it first :slight_smile:

    $pages = array(
    			'easymode' => array('url' => 'index.php?wdeb_on', 'permission' => 'edit_posts'),
    			'dashboard'     => array('url' => 'index.php',          'permission' => 'edit_posts'),
    			'visit'         => array('url' => ''),
    			'posts'         => array('url' => 'edit.php',           'permission' => 'edit_posts'),
    			'media'         => array('url' => 'media.php',          'permission' => 'edit_posts'),
    			'links'         => array('url' => 'link-manager.php',   'permission' => 'manage_links'),
    			'pages'         => array('url' => 'edit.php?post_type=page', 'permission' => 'edit_pages'),
    			'comments'      => array('url' => 'edit-comments.php',  'permission' => 'edit_posts'),
    			'appearance'    => array('url' => 'themes.php',         'permission' => 'switch_themes'),
    			'plugins'       => array('url' => 'plugins.php',        'permission' => 'install_plugins'),
    			'users'         => array('url' => 'users.php',          'permission' => 'list_users'),
    			'tools'         => array('url' => 'tools.php',          'permission' => 'import'),
    			'settings'      => array('url' => 'options-general.php','permission' => 'manage_options'),

    I've tested it on my sandbox install, so it should work fine.

    Let me know if it helped!

    Cheers,
    Adam

  • AIPman1

    Yup...that's agreed, works to turn easy mode on, so I can use that instead of the admin bar visible one. Ideally, would like to see the link know if Easy Mode was on, and become an Off button as well, but if that's not possible in this plug in's framework, that's fine. Glad to help get this option going - the presentation of sites in an alphabet format really help on a large network that is designed for readers to find publishers to follow. The default Sites menu can get impossibly manageable for casual users in these types of networks. The more stuff we can integrate the wonderful WPMUDEV software with, the better.

  • Adam Czajczyk

    Hey AIPman1

    I hope you're well today!

    Here's an altered code for you:

    global $wp_admin_bar;
    	if ( $id == 'network' ) {
    		$pages = array(
    			'dashboard'     => array('url' => 'index.php'),
    			'sites'         => array('url' => 'sites.php'),
    			'users'         => array('url' => 'users.php'),
    			'themes'        => array('url' => 'themes.php'),
    			'plugins'       => array('url' => 'plugins.php'),
    			'settings'      => array('url' => 'settings.php'),
    			'updates'       => array('url' => 'update-core.php'),
    		);
    	}
    	else {
    	if (isset($_COOKIE['wdeb_on']) && (int)$_COOKIE['wdeb_on'] > 0)
    			$easy_pages = array('easymode' => array('url' => 'index.php?wdeb_off', 'permission' => 'edit_posts', 'title' => 'Exit easy mode'));
    	    else
    			$easy_pages = array('easymode' => array('url' => 'index.php?wdeb_on', 'permission' => 'edit_posts', 'title' => 'Easy mode on'));
    		$pages = array(
    			'dashboard'     => array('url' => 'index.php',          'permission' => 'edit_posts'),
    			'visit'         => array('url' => ''),
    			'posts'         => array('url' => 'edit.php',           'permission' => 'edit_posts'),
    			'media'         => array('url' => 'media.php',          'permission' => 'edit_posts'),
    			'links'         => array('url' => 'link-manager.php',   'permission' => 'manage_links'),
    			'pages'         => array('url' => 'edit.php?post_type=page', 'permission' => 'edit_pages'),
    			'comments'      => array('url' => 'edit-comments.php',  'permission' => 'edit_posts'),
    			'appearance'    => array('url' => 'themes.php',         'permission' => 'switch_themes'),
    			'plugins'       => array('url' => 'plugins.php',        'permission' => 'install_plugins'),
    			'users'         => array('url' => 'users.php',          'permission' => 'list_users'),
    			'tools'         => array('url' => 'tools.php',          'permission' => 'import'),
    			'settings'      => array('url' => 'options-general.php','permission' => 'manage_options'),
    		);
    		$pages = array_merge($easy_pages,$pages);
    	}
    
    	$pages = apply_filters('mabs_blog_pages', $pages, $id, $user);

    It does detect if the easy mode is on or off and changes "Easymode" link and menu label accordingly. There is however a small glitch: this link changes only after user performed any action on the site. So, if you activate easy mode, the link won't change. It will change though after you click on any other link on a page. The same applies to the "exit easymode" link.

    I hope that helps!

    Cheers,
    Adam

  • AIPman1

    I have tested and confirm everything. I don't feel that the need to go to a new page to see that the link will take you back to on or off will be much of an issue...most people once it's turned on or off, will be going direct to whatever additional options they needed to switch the easy mode view for anyway. So I feel this has become a full success, thanks for the effort on the link code, hope this helps other people who want to have a really nice looking My Sites menu in their larger networks.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.