<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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 #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#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>
<title>[BuddyPress] [3414] branches/1.2/bp-core/bp-core-adminbar.php:
More bp-core-adminbar clean-up.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>3414</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2010-11-14 04:52:49 +0000 (Sun, 14 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>More bp-core-adminbar clean-up. Backport thisblog function from trunk.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#branches12bpcorebpcoreadminbarphp">branches/1.2/bp-core/bp-core-adminbar.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="branches12bpcorebpcoreadminbarphp"></a>
<div class="modfile"><h4>Modified: branches/1.2/bp-core/bp-core-adminbar.php (3413 => 3414)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-core/bp-core-adminbar.php        2010-11-14 04:42:16 UTC (rev 3413)
+++ branches/1.2/bp-core/bp-core-adminbar.php        2010-11-14 04:52:49 UTC (rev 3414)
</span><span class="lines">@@ -99,66 +99,70 @@
</span><span class="cx"> function bp_adminbar_blogs_menu() {
</span><span class="cx">         global $bp;
</span><span class="cx">
</span><del>-        if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
</del><ins>+        if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><del>-        if ( bp_core_is_multisite() ) {
</del><ins>+        if ( !is_multisite() )
+                return false;
</ins><span class="cx">
</span><del>-                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' );
-                }
</del><ins>+        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' );
+        }
</ins><span class="cx">
</span><del>-                echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">';
</del><ins>+        echo '<li id="bp-adminbar-blogs-menu"><a href="' . $bp->loggedin_user->domain . $bp->blogs->slug . '/">';
</ins><span class="cx">
</span><del>-                _e( 'My Blogs', 'buddypress' );
</del><ins>+        _e( 'My Blogs', 'buddypress' );
</ins><span class="cx">
</span><del>-                echo '</a>';
-                echo '<ul>';
</del><ins>+        echo '</a>';
+        echo '<ul>';
</ins><span class="cx">
</span><del>-                if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
-                        $counter = 0;
-                        foreach ( (array)$blogs['blogs'] as $blog ) {
-                                $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-                                $site_url = esc_attr( $blog->siteurl );
</del><ins>+        if ( is_array( $blogs['blogs'] ) && (int)$blogs['count'] ) {
+                $counter = 0;
+                foreach ( (array)$blogs['blogs'] as $blog ) {
+                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
+                        $site_url = esc_attr( $blog->siteurl );
</ins><span class="cx">
</span><del>-                                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>';
-                                echo '</li>';
-                                $counter++;
-                        }
-                }
-
-                $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : '';
-
-                if ( bp_blog_signup_enabled() ) {
</del><span class="cx">                         echo '<li' . $alt . '>';
</span><del>-                        echo '<a href="' . $bp->root_domain . '/' . $bp->blogs->slug . '/create/">' . __( 'Create a Blog!', 'buddypress' ) . '</a>';
</del><ins>+                        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>';
</ins><span class="cx">                         echo '</li>';
</span><ins>+                        $counter++;
</ins><span class="cx">                 }
</span><ins>+        }
</ins><span class="cx">
</span><del>-                echo '</ul>';
</del><ins>+        $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>';
</ins><span class="cx">                 echo '</li>';
</span><del>-        } elseif ( current_user_can( 'administrator' ) ) {
-                $site_url = site_url();
</del><ins>+        }
</ins><span class="cx">
</span><del>-                echo '<li id="bp-adminbar-admin-menu"><a href="' . admin_url() . '/">';
</del><ins>+        echo '</ul>';
+        echo '</li>';
+}
</ins><span class="cx">
</span><del>-                _e( 'Site Admin', 'buddypress' );
</del><ins>+function bp_adminbar_thisblog_menu() {
+        if ( current_user_can( 'edit_posts' ) ) {
+                echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
</ins><span class="cx">
</span><ins>+                _e( 'Dashboard', 'buddypress' );
+
</ins><span class="cx">                 echo '</a>';
</span><span class="cx">                 echo '<ul>';
</span><span class="cx">
</span><del>-                echo '<li class="alt"><a href="' . admin_url() . '">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
-                echo '<li><a href="' . admin_url( 'post-new.php' ) . '">' . __( 'New Post', 'buddypress' ) . '</a></li>';
-                echo '<li class="alt"><a href="' . admin_url( 'edit.php' ) . '">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
-                echo '<li><a href="' . admin_url( 'edit-comments.php' ) . '">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
</del><ins>+                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' );
+
</ins><span class="cx">                 echo '</ul>';
</span><span class="cx">                 echo '</li>';
</span><span class="cx">         }
</span><span class="lines">@@ -207,11 +211,11 @@
</span><span class="cx">         global $bp, $current_blog, $wpdb;
</span><span class="cx">
</span><span class="cx">         // Only for multisite
</span><del>-        if ( !bp_core_is_multisite() )
</del><ins>+        if ( !is_multisite() )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         // Hide on root blog
</span><del>-        if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( 'bp_blogs_install' ) )
</del><ins>+        if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
</ins><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         $blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
</span><span class="lines">@@ -249,13 +253,13 @@
</span><span class="cx">                 <ul class="random-list">
</span><span class="cx">                         <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
</span><span class="cx">
</span><del>-                        <?php if ( function_exists('groups_install') ) : ?>
</del><ins>+                        <?php if ( bp_is_active( 'groups' ) ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
</span><span class="cx">
</span><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><del>-                        <?php if ( function_exists('bp_blogs_install') && bp_core_is_multisite() ) : ?>
</del><ins>+                        <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>
</ins><span class="cx">
</span><span class="cx">                                 <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
</span><span class="cx">
</span><span class="lines">@@ -274,6 +278,7 @@
</span><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
</span><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
</span><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
</span><ins>+add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
</ins><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
</span><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
</span><span class="cx"> add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
</span></span></pre>
</div>
</div>
</body>
</html>