<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[BuddyPress][3817] trunk/bp-core: Move BuddyBar functions out of bp-core-adminbar and into bp-core-buddybar.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg > ul, #logmsg > ol { margin-left: 0; margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd>3817</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2011-01-22 13:51:41 +0000 (Sat, 22 Jan 2011)</dd>
</dl>
<h3>Log Message</h3>
<pre>Move BuddyBar functions out of bp-core-adminbar and into bp-core-buddybar. Reserve the adminbar file for the WordPress admin bar.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkbpcorebpcoreadminbarphp">trunk/bp-core/bp-core-adminbar.php</a></li>
<li><a href="#trunkbpcorebpcorebuddybarphp">trunk/bp-core/bp-core-buddybar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkbpcorebpcoreadminbarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-adminbar.php (3816 => 3817)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-adminbar.php        2011-01-22 13:43:20 UTC (rev 3816)
+++ trunk/bp-core/bp-core-adminbar.php        2011-01-22 13:51:41 UTC (rev 3817)
</span><span class="lines">@@ -1,312 +1,7 @@
</span><span class="cx"> <?php
</span><span class="cx">
</span><del>-function bp_core_admin_bar() {
-        global $bp, $wpdb, $current_blog;
</del><ins>+/**
+ * Reserved for WordPress admin bar functions
+ */
</ins><span class="cx">
</span><del>-        if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
-                return false;
-
-        if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
-                return false;
-
-        $bp->doing_admin_bar = true;
-
-        echo '<div id="wp-admin-bar"><div class="padder">';
-
-        // **** Do bp-adminbar-logo Actions ********
-        do_action( 'bp_adminbar_logo' );
-
-        echo '<ul class="main-nav">';
-
-        // **** Do bp-adminbar-menus Actions ********
-        do_action( 'bp_adminbar_menus' );
-
-        echo '</ul>';
-        echo "</div></div><!-- #wp-admin-bar -->\n\n";
-
-        $bp->doing_admin_bar = false;
-}
-
-// **** Default BuddyPress admin bar logo ********
-function bp_adminbar_logo() {
-        global $bp;
-
-        echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>';
-}
-
-// **** "Log In" and "Sign Up" links (Visible when not logged in) ********
-function bp_adminbar_login_menu() {
-        global $bp;
-
-        if ( is_user_logged_in() )
-                return false;
-
-        echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
-
-        // Show "Sign Up" link if user registrations are allowed
-        if ( bp_get_signup_allowed() )
-                echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
-}
-
-
-// **** "My Account" Menu ******
-function bp_adminbar_account_menu() {
-        global $bp;
-
-        if ( !$bp->bp_nav || !is_user_logged_in() )
-                return false;
-
-        echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
-
-        echo __( 'My Account', 'buddypress' ) . '</a>';
-        echo '<ul>';
-
-        /* Loop through each navigation item */
-        $counter = 0;
-        foreach( (array)$bp->bp_nav as $nav_item ) {
-                $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-
-                echo '<li' . $alt . '>';
-                echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
-
-                if ( isset( $bp->bp_options_nav[$nav_item['slug']] ) && is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {
-                        echo '<ul>';
-                        $sub_counter = 0;
-
-                        foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
-                                $link = $subnav_item['link'];
-                                $name = $subnav_item['name'];
-
-                                if ( isset( $bp->displayed_user->domain ) )
-                                        $link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
-
-                                if ( isset( $bp->displayed_user->userdata->user_login ) )
-                                        $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
-
-                                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
-                                echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
-                                $sub_counter++;
-                        }
-                        echo '</ul>';
-                }
-
-                echo '</li>';
-
-                $counter++;
-        }
-
-        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-
-        echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( site_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
-        echo '</ul>';
-        echo '</li>';
-}
-
-// *** "My Blogs" Menu ********
-function bp_adminbar_blogs_menu() {
-        global $bp;
-
-        if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
-                return false;
-
-        if ( !is_multisite() )
-                return false;
-
-        if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
-                $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
-                wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
-        }
-
-        echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">';
-
-        _e( 'My Blogs', 'buddypress' );
-
-        echo '</a>';
-        echo '<ul>';
-
-        $counter = 0;
-        if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
-                foreach ( (array)$blogs['blogs'] as $blog ) {
-                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-                        $site_url = esc_attr( $blog->siteurl );
-
-                        echo '<li' . $alt . '>';
-                        echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
-                        echo '<ul>';
-                        echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
-                        echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
-                        echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
-                        echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
-                        echo '</ul>';
-
-                        do_action( 'bp_adminbar_blog_items', $blog );
-
-                        echo '</li>';
-                        $counter++;
-                }
-        }
-
-        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-
-        if ( bp_blog_signup_enabled() ) {
-                echo '<li' . $alt . '>';
-                echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
-                echo '</li>';
-        }
-
-        echo '</ul>';
-        echo '</li>';
-}
-
-function bp_adminbar_thisblog_menu() {
-        if ( current_user_can( 'edit_posts' ) ) {
-                echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
-
-                _e( 'Dashboard', 'buddypress' );
-
-                echo '</a>';
-                echo '<ul>';
-
-                echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
-                echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
-                echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
-
-                do_action( 'bp_adminbar_thisblog_items' );
-
-                echo '</ul>';
-                echo '</li>';
-        }
-}
-
-// **** "Notifications" Menu *********
-function bp_adminbar_notifications_menu() {
-        global $bp;
-
-        if ( !is_user_logged_in() )
-                return false;
-
-        echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
-        _e( 'Notifications', 'buddypress' );
-
-        if ( $notifications = bp_users_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
-                <span><?php echo count( $notifications ) ?></span>
-        <?php
-        }
-
-        echo '</a>';
-        echo '<ul>';
-
-        if ( $notifications ) {
-                $counter = 0;
-                for ( $i = 0; $i < count($notifications); $i++ ) {
-                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
-
-                        <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
-
-                        <?php $counter++;
-                }
-        } else { ?>
-
-                <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
-
-        <?php
-        }
-
-        echo '</ul>';
-        echo '</li>';
-}
-
-// **** "Blog Authors" Menu (visible when not logged in) ********
-function bp_adminbar_authors_menu() {
-        global $bp, $current_blog, $wpdb;
-
-        // Only for multisite
-        if ( !is_multisite() )
-                return false;
-
-        // Hide on root blog
-        if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
-                return false;
-                
-        $blog_prefix = $wpdb->get_blog_prefix( $current_blog->blog_id );
-        $authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
-
-        if ( !empty( $authors ) ) {
-                // This is a blog, render a menu with links to all authors
-                echo '<li id="bp-adminbar-authors-menu"><a href="/">';
-                _e('Blog Authors', 'buddypress');
-                echo '</a>';
-
-                echo '<ul class="author-list">';
-                foreach( (array)$authors as $author ) {
-                        $caps = maybe_unserialize( $author->caps );
-                        if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
-
-                        echo '<li>';
-                        echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
-                        echo bp_core_fetch_avatar( array( 'item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15 ) ) ;
-                         echo ' ' . $author->display_name . '</a>';
-                        echo '<div class="admin-bar-clear"></div>';
-                        echo '</li>';
-                }
-                echo '</ul>';
-                echo '</li>';
-        }
-}
-
-// **** "Random" Menu (visible when not logged in) ********
-function bp_adminbar_random_menu() {
-        global $bp; ?>
-
-        <li class="align-right" id="bp-adminbar-visitrandom-menu">
-                <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
-                <ul class="random-list">
-                        <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
-
-                        <?php if ( bp_is_active( 'groups' ) ) : ?>
-
-                                <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
-
-                        <?php endif; ?>
-
-                        <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>
-
-                                <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
-
-                        <?php endif; ?>
-
-                        <?php do_action( 'bp_adminbar_random_menu' ) ?>
-
-                </ul>
-        </li>
-
-        <?php
-}
-
-function bp_core_load_admin_bar() {
-        global $wp_version;
-        
-        if ( defined( 'BP_USE_WP_ADMIN_BAR' ) && BP_USE_WP_ADMIN_BAR && $wp_version >= 3.1 ) {
-                // TODO: Add BP support to WP admin bar
-                return;
-        } elseif ( !defined( 'BP_DISABLE_ADMIN_BAR' ) || !BP_DISABLE_ADMIN_BAR ) {
-                // Keep the WP admin bar from loading
-                show_admin_bar( false );
-                
-                // Actions used to build the BP admin bar
-                add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
-                add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
-                
-                // Actions used to append BP admin bar to footer
-                add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
-                add_action( 'admin_footer', 'bp_core_admin_bar' );        
-        }
-}
-
</del><span class="cx"> ?>
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkbpcorebpcorebuddybarphp"></a>
<div class="modfile"><h4>Modified: trunk/bp-core/bp-core-buddybar.php (3816 => 3817)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/bp-core/bp-core-buddybar.php        2011-01-22 13:43:20 UTC (rev 3816)
+++ trunk/bp-core/bp-core-buddybar.php        2011-01-22 13:51:41 UTC (rev 3817)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">         extract( $r, EXTR_SKIP );
</span><span class="cx">
</span><span class="cx">         // If we don't have the required info we need, don't create this subnav item
</span><del>-        if ( empty($name) || empty($slug) )
</del><ins>+        if ( empty( $name ) || empty( $slug ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         // If this is for site admins only and the user is not one, don't create the subnav item
</span><span class="lines">@@ -57,16 +57,16 @@
</span><span class="cx">          * If we are not viewing a user, and this is a root component, don't attach the
</span><span class="cx">          * default subnav function so we can display a directory or something else.
</span><span class="cx">          */
</span><del>-        if ( bp_is_root_component( $slug ) && !$bp->displayed_user->id )
</del><ins>+        if ( bp_is_root_component( $slug ) && !bp_displayed_user_id() )
</ins><span class="cx">                 return;
</span><span class="cx">
</span><del>-        if ( $bp->current_component == $slug && !$bp->current_action ) {
</del><ins>+        if ( bp_is_current_component( $slug ) && !bp_current_action() ) {
</ins><span class="cx">                 if ( !is_object( $screen_function[0] ) )
</span><span class="cx">                         add_action( 'wp', $screen_function, 3 );
</span><span class="cx">                 else
</span><span class="cx">                         add_action( 'wp', array( &$screen_function[0], $screen_function[1] ), 3 );
</span><span class="cx">
</span><del>-                if ( $default_subnav_slug )
</del><ins>+                if ( !empty( $default_subnav_slug ) )
</ins><span class="cx">                         $bp->current_action = $default_subnav_slug;
</span><span class="cx">         }
</span><span class="cx"> }
</span><span class="lines">@@ -289,4 +289,318 @@
</span><span class="cx">         unset( $bp->bp_options_nav[$parent_slug] );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+/** Template functions ********************************************************/
+
+function bp_core_admin_bar() {
+        global $bp, $wpdb, $current_blog;
+
+        if ( defined( 'BP_DISABLE_ADMIN_BAR' ) )
+                return false;
+
+        if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
+                return false;
+
+        $bp->doing_admin_bar = true;
+
+        echo '<div id="wp-admin-bar"><div class="padder">';
+
+        // **** Do bp-adminbar-logo Actions ********
+        do_action( 'bp_adminbar_logo' );
+
+        echo '<ul class="main-nav">';
+
+        // **** Do bp-adminbar-menus Actions ********
+        do_action( 'bp_adminbar_menus' );
+
+        echo '</ul>';
+        echo "</div></div><!-- #wp-admin-bar -->\n\n";
+
+        $bp->doing_admin_bar = false;
+}
+
+// **** Default BuddyPress admin bar logo ********
+function bp_adminbar_logo() {
+        global $bp;
+
+        echo '<a href="' . $bp->root_domain . '" id="admin-bar-logo">' . get_blog_option( BP_ROOT_BLOG, 'blogname') . '</a>';
+}
+
+// **** "Log In" and "Sign Up" links (Visible when not logged in) ********
+function bp_adminbar_login_menu() {
+        global $bp;
+
+        if ( is_user_logged_in() )
+                return false;
+
+        echo '<li class="bp-login no-arrow"><a href="' . $bp->root_domain . '/wp-login.php?redirect_to=' . urlencode( $bp->root_domain ) . '">' . __( 'Log In', 'buddypress' ) . '</a></li>';
+
+        // Show "Sign Up" link if user registrations are allowed
+        if ( bp_get_signup_allowed() )
+                echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
+}
+
+
+// **** "My Account" Menu ******
+function bp_adminbar_account_menu() {
+        global $bp;
+
+        if ( !$bp->bp_nav || !is_user_logged_in() )
+                return false;
+
+        echo '<li id="bp-adminbar-account-menu"><a href="' . bp_loggedin_user_domain() . '">';
+
+        echo __( 'My Account', 'buddypress' ) . '</a>';
+        echo '<ul>';
+
+        // Loop through each navigation item
+        $counter = 0;
+        foreach( (array)$bp->bp_nav as $nav_item ) {
+                $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
+
+                if ( -1 == $nav_item['position'] )
+                        continue;
+
+                echo '<li' . $alt . '>';
+                echo '<a id="bp-admin-' . $nav_item['css_id'] . '" href="' . $nav_item['link'] . '">' . $nav_item['name'] . '</a>';
+
+                if ( isset( $bp->bp_options_nav[$nav_item['slug']] ) && is_array( $bp->bp_options_nav[$nav_item['slug']] ) ) {
+                        echo '<ul>';
+                        $sub_counter = 0;
+
+                        foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
+                                $link = $subnav_item['link'];
+                                $name = $subnav_item['name'];
+
+                                if ( isset( $bp->displayed_user->domain ) )
+                                        $link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
+
+                                if ( isset( $bp->displayed_user->userdata->user_login ) )
+                                        $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
+
+                                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
+                                echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
+                                $sub_counter++;
+                        }
+                        echo '</ul>';
+                }
+
+                echo '</li>';
+
+                $counter++;
+        }
+
+        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
+
+        echo '<li' . $alt . '><a id="bp-admin-logout" class="logout" href="' . wp_logout_url( site_url() ) . '">' . __( 'Log Out', 'buddypress' ) . '</a></li>';
+        echo '</ul>';
+        echo '</li>';
+}
+
+// *** "My Blogs" Menu ********
+function bp_adminbar_blogs_menu() {
+        global $bp;
+
+        if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
+                return false;
+
+        if ( !is_multisite() )
+                return false;
+
+        if ( !$blogs = wp_cache_get( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', 'bp' ) ) {
+                $blogs = bp_blogs_get_blogs_for_user( $bp->loggedin_user->id, true );
+                wp_cache_set( 'bp_blogs_of_user_' . $bp->loggedin_user->id . '_inc_hidden', $blogs, 'bp' );
+        }
+
+        echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">';
+
+        _e( 'My Blogs', 'buddypress' );
+
+        echo '</a>';
+        echo '<ul>';
+
+        $counter = 0;
+        if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
+                foreach ( (array)$blogs['blogs'] as $blog ) {
+                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
+                        $site_url = esc_attr( $blog->siteurl );
+
+                        echo '<li' . $alt . '>';
+                        echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
+                        echo '<ul>';
+                        echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
+                        echo '<li><a href="' . $site_url . 'wp-admin/post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
+                        echo '<li class="alt"><a href="' . $site_url . 'wp-admin/edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
+                        echo '<li><a href="' . $site_url . 'wp-admin/edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
+                        echo '</ul>';
+
+                        do_action( 'bp_adminbar_blog_items', $blog );
+
+                        echo '</li>';
+                        $counter++;
+                }
+        }
+
+        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
+
+        if ( bp_blog_signup_enabled() ) {
+                echo '<li' . $alt . '>';
+                echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
+                echo '</li>';
+        }
+
+        echo '</ul>';
+        echo '</li>';
+}
+
+function bp_adminbar_thisblog_menu() {
+        if ( current_user_can( 'edit_posts' ) ) {
+                echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
+
+                _e( 'Dashboard', 'buddypress' );
+
+                echo '</a>';
+                echo '<ul>';
+
+                echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
+                echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
+                echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
+
+                do_action( 'bp_adminbar_thisblog_items' );
+
+                echo '</ul>';
+                echo '</li>';
+        }
+}
+
+// **** "Notifications" Menu *********
+function bp_adminbar_notifications_menu() {
+        global $bp;
+
+        if ( !is_user_logged_in() )
+                return false;
+
+        echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">';
+        _e( 'Notifications', 'buddypress' );
+
+        if ( $notifications = bp_users_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
+                <span><?php echo count( $notifications ) ?></span>
+        <?php
+        }
+
+        echo '</a>';
+        echo '<ul>';
+
+        if ( $notifications ) {
+                $counter = 0;
+                for ( $i = 0; $i < count($notifications); $i++ ) {
+                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
+
+                        <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
+
+                        <?php $counter++;
+                }
+        } else { ?>
+
+                <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
+
+        <?php
+        }
+
+        echo '</ul>';
+        echo '</li>';
+}
+
+// **** "Blog Authors" Menu (visible when not logged in) ********
+function bp_adminbar_authors_menu() {
+        global $bp, $current_blog, $wpdb;
+
+        // Only for multisite
+        if ( !is_multisite() )
+                return false;
+
+        // Hide on root blog
+        if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
+                return false;
+
+        $blog_prefix = $wpdb->get_blog_prefix( $current_blog->blog_id );
+        $authors = $wpdb->get_results( "SELECT user_id, user_login, user_nicename, display_name, user_email, meta_value as caps FROM $wpdb->users u, $wpdb->usermeta um WHERE u.ID = um.user_id AND meta_key = '{$blog_prefix}capabilities' ORDER BY um.user_id" );
+
+        if ( !empty( $authors ) ) {
+                // This is a blog, render a menu with links to all authors
+                echo '<li id="bp-adminbar-authors-menu"><a href="/">';
+                _e('Blog Authors', 'buddypress');
+                echo '</a>';
+
+                echo '<ul class="author-list">';
+                foreach( (array)$authors as $author ) {
+                        $caps = maybe_unserialize( $author->caps );
+                        if ( isset( $caps['subscriber'] ) || isset( $caps['contributor'] ) ) continue;
+
+                        echo '<li>';
+                        echo '<a href="' . bp_core_get_user_domain( $author->user_id, $author->user_nicename, $author->user_login ) . '">';
+                        echo bp_core_fetch_avatar( array( 'item_id' => $author->user_id, 'email' => $author->user_email, 'width' => 15, 'height' => 15 ) ) ;
+                         echo ' ' . $author->display_name . '</a>';
+                        echo '<div class="admin-bar-clear"></div>';
+                        echo '</li>';
+                }
+                echo '</ul>';
+                echo '</li>';
+        }
+}
+
+// **** "Random" Menu (visible when not logged in) ********
+function bp_adminbar_random_menu() {
+        global $bp; ?>
+
+        <li class="align-right" id="bp-adminbar-visitrandom-menu">
+                <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
+                <ul class="random-list">
+                        <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
+
+                        <?php if ( bp_is_active( 'groups' ) ) : ?>
+
+                                <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
+
+                        <?php endif; ?>
+
+                        <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>
+
+                                <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
+
+                        <?php endif; ?>
+
+                        <?php do_action( 'bp_adminbar_random_menu' ) ?>
+
+                </ul>
+        </li>
+
+        <?php
+}
+
+function bp_core_load_admin_bar() {
+        global $wp_version;
+
+        if ( defined( 'BP_USE_WP_ADMIN_BAR' ) && BP_USE_WP_ADMIN_BAR && $wp_version >= 3.1 ) {
+                // TODO: Add BP support to WP admin bar
+                return;
+        } elseif ( !defined( 'BP_DISABLE_ADMIN_BAR' ) || !BP_DISABLE_ADMIN_BAR ) {
+                // Keep the WP admin bar from loading
+                show_admin_bar( false );
+
+                // Actions used to build the BP admin bar
+                add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
+                add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
+
+                // Actions used to append BP admin bar to footer
+                add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
+                add_action( 'admin_footer', 'bp_core_admin_bar' );
+        }
+}
+
</ins><span class="cx"> ?>
</span></span></pre>
</div>
</div>
</body>
</html>