<!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] [3411] branches/1.2/bp-core/bp-core-adminbar.php:
Clean up bp-core-adminbar.php.</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd>3411</dd>
<dt>Author</dt> <dd>johnjamesjacoby</dd>
<dt>Date</dt> <dd>2010-11-14 04:37:04 +0000 (Sun, 14 Nov 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Clean up bp-core-adminbar.php. Move inline multisite check into function.</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 (3410 => 3411)</h4>
<pre class="diff"><span>
<span class="info">--- branches/1.2/bp-core/bp-core-adminbar.php        2010-11-14 04:28:36 UTC (rev 3410)
+++ branches/1.2/bp-core/bp-core-adminbar.php        2010-11-14 04:37:04 UTC (rev 3411)
</span><span class="lines">@@ -44,9 +44,8 @@
</span><span class="cx">         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>';
</span><span class="cx">
</span><span class="cx">         // Show "Sign Up" link if user registrations are allowed
</span><del>-        if ( bp_get_signup_allowed() ) {
</del><ins>+        if ( bp_get_signup_allowed() )
</ins><span class="cx">                 echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
</span><del>-        }
</del><span class="cx"> }
</span><span class="cx">
</span><span class="cx">
</span><span class="lines">@@ -176,22 +175,26 @@
</span><span class="cx">         _e( 'Notifications', 'buddypress' );
</span><span class="cx">
</span><span class="cx">         if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
</span><del>-                <span><?php echo count($notifications) ?></span>
</del><ins>+                <span><?php echo count( $notifications ) ?></span>
</ins><span class="cx">         <?php
</span><span class="cx">         }
</span><span class="cx">
</span><span class="cx">         echo '</a>';
</span><span class="cx">         echo '<ul>';
</span><span class="cx">
</span><del>-        if ( $notifications ) { ?>
-                <?php $counter = 0; ?>
-                <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
-                        <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
</del><ins>+        if ( $notifications ) {
+                $counter = 0;
+                for ( $i = 0; $i < count($notifications); $i++ ) {
+                        $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
+
</ins><span class="cx">                         <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
</span><del>-                        <?php $counter++; ?>
-                <?php } ?>
-        <?php } else { ?>
</del><ins>+
+                        <?php $counter++;
+                }
+        } else { ?>
+
</ins><span class="cx">                 <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
</span><ins>+
</ins><span class="cx">         <?php
</span><span class="cx">         }
</span><span class="cx">
</span><span class="lines">@@ -203,14 +206,19 @@
</span><span class="cx"> function bp_adminbar_authors_menu() {
</span><span class="cx">         global $bp, $current_blog, $wpdb;
</span><span class="cx">
</span><ins>+        // Only for multisite
+        if ( !bp_core_is_multisite() )
+                return false;
+
+        // Hide on root blog
</ins><span class="cx">         if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( 'bp_blogs_install' ) )
</span><span class="cx">                 return false;
</span><span class="cx">
</span><span class="cx">         $blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
</span><del>-        $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" );
</del><ins>+        $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" );
</ins><span class="cx">
</span><span class="cx">         if ( !empty( $authors ) ) {
</span><del>-                /* This is a blog, render a menu with links to all authors */
</del><ins>+                // This is a blog, render a menu with links to all authors
</ins><span class="cx">                 echo '<li id="bp-adminbar-authors-menu"><a href="/">';
</span><span class="cx">                 _e('Blog Authors', 'buddypress');
</span><span class="cx">                 echo '</a>';
</span><span class="lines">@@ -235,38 +243,43 @@
</span><span class="cx"> // **** "Random" Menu (visible when not logged in) ********
</span><span class="cx"> function bp_adminbar_random_menu() {
</span><span class="cx">         global $bp; ?>
</span><ins>+
</ins><span class="cx">         <li class="align-right" id="bp-adminbar-visitrandom-menu">
</span><span class="cx">                 <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
</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><span class="cx">                         <?php if ( function_exists('groups_install') ) : ?>
</span><del>-                        <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
</del><ins>+
+                                <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
+
</ins><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <?php if ( function_exists('bp_blogs_install') && bp_core_is_multisite() ) : ?>
</span><del>-                        <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
</del><span class="cx">
</span><ins>+                                <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
+
</ins><span class="cx">                         <?php endif; ?>
</span><span class="cx">
</span><span class="cx">                         <?php do_action( 'bp_adminbar_random_menu' ) ?>
</span><ins>+
</ins><span class="cx">                 </ul>
</span><span class="cx">         </li>
</span><ins>+
</ins><span class="cx">         <?php
</span><span class="cx"> }
</span><span class="cx">
</span><del>-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_notifications_menu', 8 );
</del><ins>+// Actions used to build the 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_notifications_menu', 8 );
+add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
+add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
</ins><span class="cx">
</span><del>-if ( bp_core_is_multisite() )
-        add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
</del><ins>+// Actions used to append 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><del>-add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
-
-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>
</div>
</body>
</html>