WordPress.org

Ready to get started?Download WordPress

Forums

WordPress Admin Bar
front-end/back-end menu inconsistency (5 posts)

  1. I've created a menu specifically for showing all of the sites the logged-in user has access to.

    In the backend, this works wonderfully with the admin bar - on the front end, the bar doesn't reflect my menu placement.

    screenshot: http://cl.ly/2zL0

    http://wordpress.org/extend/plugins/wordpress-admin-bar/

  2. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    How are you adding the menu item? Can you paste that part of your plugin?

  3. add_action('admin_menu', 'create_my_sites_menu',1);
    function create_my_sites_menu() {
    global $current_user;
    get_currentuserinfo();

    $user_blogs = get_blogs_of_user($current_user->ID,true);

    add_menu_page( 'My Sites', "My Sites <span class='update-plugins'><span class='pending-count'>".count($user_blogs)."</span></span>", 'unfiltered_html', 'list-my-sites', 'my_sites');

    foreach($user_blogs as $k=>$blog) {
    add_submenu_page( 'list-my-sites', $blog->blogname, substr($blog->blogname,0,15), 'unfiltered_html', 'siteid-'.$k, 'nothin');
    }

    function my_sites() {echo '';}
    function nothin() {echo '';}

    }

    add_action('admin_menu','change_links',1);
    function change_links() {

    global $submenu,$menu;
    $mysites = $menu['100'];
    $mysites['4'] = str_replace('menu-top-first','',$mysites['4']);
    unset($menu['100']);
    $menu['1'] = $mysites;
    $menu['1.5'] = array('','read','separator-last','','wp-menu-separator-last');
    $submenu['list-my-sites']['0']['2'] = 'my-sites.php';

    foreach($submenu['list-my-sites'] as $site=>$info) {
    if ($site == '0') continue;
    $id = str_replace('siteid-','',$submenu['list-my-sites'][$site]['2']);
    $site_details = get_blogaddress_by_id($id);
    $submenu['list-my-sites'][$site]['2'] = $site_details.'wp-admin/';
    }

    }

    After staring at it for awhile, it occurred to me that it's probably related to the admin_menu hook since that's not run on the front end - I just haven't had a chance to test that yet...

  4. Alex Mills (Viper007Bond)
    Moderator
    Plugin Author

    Posted 3 years ago #

    It could be that or it could be due to the manual $menu/$submenu manipulation. I'm not sure.

    I wouldn't spend much time on this though as the mutli-site compatible admin bar from WordPress.com is already into the WordPress 3.1 alpha and it's a lot, lot better than my plugin. My plugin is being discontinued and will receive no further updates.

  5. yeah... definitely looking forward to the 3.1 admin bar - just looking for something to help me out until it has a stable release.

    thanks for taking a look

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic