Skip to:
Content

BuddyPress.org

Changeset 3415


Ignore:
Timestamp:
11/14/2010 04:58:27 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Merge bp-core-adminbar.php changes into trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-adminbar.php

    r3405 r3415  
    77        return false;
    88
    9     if ( isset( $bp->site_options['hide-loggedout-adminbar'] ) && (int)$bp->site_options['hide-loggedout-adminbar'] && !is_user_logged_in() )
     9    if ( (int)get_site_option( 'hide-loggedout-adminbar' ) && !is_user_logged_in() )
    1010        return false;
    1111
     
    4545
    4646    // Show "Sign Up" link if user registrations are allowed
    47     if ( bp_get_signup_allowed() ) {
     47    if ( bp_get_signup_allowed() )
    4848        echo '<li class="bp-signup no-arrow"><a href="' . bp_get_signup_page(false) . '">' . __( 'Sign Up', 'buddypress' ) . '</a></li>';
    49     }
    5049}
    5150
     
    7675
    7776            foreach( (array)$bp->bp_options_nav[$nav_item['slug']] as $subnav_item ) {
    78                 $link = $subnav_item['link'];
    79                 $name = $subnav_item['name'];
    80 
    81                 if ( isset( $bp->displayed_user->domain ) )
    82                     $link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
    83 
    84                 if ( isset( $bp->displayed_user->userdata->user_login ) )
    85                     $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
    86 
     77                $link = str_replace( $bp->displayed_user->domain, $bp->loggedin_user->domain, $subnav_item['link'] );
     78                $name = str_replace( $bp->displayed_user->userdata->user_login, $bp->loggedin_user->userdata->user_login, $subnav_item['name'] );
    8779                $alt = ( 0 == $sub_counter % 2 ) ? ' class="alt"' : '';
    8880                echo '<li' . $alt . '><a id="bp-admin-' . $subnav_item['css_id'] . '" href="' . $link . '">' . $name . '</a></li>';
     
    108100    global $bp;
    109101
    110     if ( !is_user_logged_in() || !function_exists('bp_blogs_install') )
     102    if ( !is_user_logged_in() || !bp_is_active( 'blogs' ) )
     103        return false;
     104
     105    if ( !is_multisite() )
    111106        return false;
    112107
     
    131126            echo '<li' . $alt . '>';
    132127            echo '<a href="' . $site_url . '">' . esc_html( $blog->name ) . '</a>';
    133 
    134128            echo '<ul>';
    135129            echo '<li class="alt"><a href="' . $site_url . 'wp-admin/">' . __( 'Dashboard', 'buddypress' ) . '</a></li>';
     
    161155    if ( current_user_can( 'edit_posts' ) ) {
    162156        echo '<li id="bp-adminbar-thisblog-menu"><a href="' . admin_url() . '">';
    163        
     157
    164158        _e( 'Dashboard', 'buddypress' );
    165    
     159
    166160        echo '</a>';
    167161        echo '<ul>';
    168        
     162
    169163        echo '<li class="alt"><a href="' . admin_url() . 'post-new.php">' . __( 'New Post', 'buddypress' ) . '</a></li>';
    170         echo '<li class="alt"><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
     164        echo '<li><a href="' . admin_url() . 'edit.php">' . __( 'Manage Posts', 'buddypress' ) . '</a></li>';
    171165        echo '<li class="alt"><a href="' . admin_url() . 'edit-comments.php">' . __( 'Manage Comments', 'buddypress' ) . '</a></li>';
    172        
     166
    173167        do_action( 'bp_adminbar_thisblog_items' );
    174        
     168
    175169        echo '</ul>';
    176170        echo '</li>';
     
    189183
    190184    if ( $notifications = bp_core_get_notifications_for_user( $bp->loggedin_user->id ) ) { ?>
    191         <span><?php echo count($notifications) ?></span>
     185        <span><?php echo count( $notifications ) ?></span>
    192186    <?php
    193187    }
     
    196190    echo '<ul>';
    197191
    198     if ( $notifications ) { ?>
    199         <?php $counter = 0; ?>
    200         <?php for ( $i = 0; $i < count($notifications); $i++ ) { ?>
    201             <?php $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
     192    if ( $notifications ) {
     193        $counter = 0;
     194        for ( $i = 0; $i < count($notifications); $i++ ) {
     195            $alt = ( 0 == $counter % 2 ) ? ' class="alt"' : ''; ?>
     196
    202197            <li<?php echo $alt ?>><?php echo $notifications[$i] ?></li>
    203             <?php $counter++; ?>
    204         <?php } ?>
    205     <?php } else { ?>
     198
     199            <?php $counter++;
     200        }
     201    } else { ?>
     202
    206203        <li><a href="<?php echo $bp->loggedin_user->domain ?>"><?php _e( 'No new notifications.', 'buddypress' ); ?></a></li>
     204
    207205    <?php
    208206    }
     
    216214    global $bp, $current_blog, $wpdb;
    217215
    218     if ( $current_blog->blog_id == BP_ROOT_BLOG || !function_exists( 'bp_blogs_install' ) )
     216    // Only for multisite
     217    if ( !is_multisite() )
     218        return false;
     219
     220    // Hide on root blog
     221    if ( $current_blog->blog_id == BP_ROOT_BLOG || !bp_is_active( 'blogs' ) )
    219222        return false;
    220223
    221224    $blog_prefix = $wpdb->get_blog_prefix( $current_blog->id );
    222     $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" );
     225    $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" );
    223226
    224227    if ( !empty( $authors ) ) {
    225         /* This is a blog, render a menu with links to all authors */
     228        // This is a blog, render a menu with links to all authors
    226229        echo '<li id="bp-adminbar-authors-menu"><a href="/">';
    227230        _e('Blog Authors', 'buddypress');
     
    248251function bp_adminbar_random_menu() {
    249252    global $bp; ?>
     253
    250254    <li class="align-right" id="bp-adminbar-visitrandom-menu">
    251255        <a href="#"><?php _e( 'Visit', 'buddypress' ) ?></a>
    252256        <ul class="random-list">
    253             <li><a href="<?php echo $bp->root_domain . '/' . $bp->members->slug . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
     257            <li><a href="<?php echo $bp->root_domain . '/' . BP_MEMBERS_SLUG . '/?random-member' ?>"><?php _e( 'Random Member', 'buddypress' ) ?></a></li>
    254258
    255259            <?php if ( bp_is_active( 'groups' ) ) : ?>
    256             <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
     260
     261                <li class="alt"><a href="<?php echo $bp->root_domain . '/' . $bp->groups->slug . '/?random-group' ?>"><?php _e( 'Random Group', 'buddypress' ) ?></a></li>
     262
    257263            <?php endif; ?>
    258264
    259265            <?php if ( bp_is_active( 'blogs' ) && is_multisite() ) : ?>
    260             <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
     266
     267                <li><a href="<?php echo $bp->root_domain . '/' . $bp->blogs->slug . '/?random-blog' ?>"><?php _e( 'Random Blog', 'buddypress' ) ?></a></li>
    261268
    262269            <?php endif; ?>
    263270
    264271            <?php do_action( 'bp_adminbar_random_menu' ) ?>
     272
    265273        </ul>
    266274    </li>
     275
    267276    <?php
    268277}
    269278
    270 add_action( 'bp_adminbar_logo', 'bp_adminbar_logo' );
    271 add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu', 2 );
    272 add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu', 4 );
    273 
    274 if ( is_multisite() )
    275     add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu', 6 );
    276 else
    277     add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu', 6 );
    278 
    279 add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
    280 
    281 if ( is_multisite() )
    282     add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu', 12 );
    283 
    284 add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu', 100 );
    285 
    286 add_action( 'wp_footer', 'bp_core_admin_bar', 8 );
    287 add_action( 'admin_footer', 'bp_core_admin_bar' );
     279// Actions used to build the admin bar
     280add_action( 'bp_adminbar_logo',  'bp_adminbar_logo' );
     281add_action( 'bp_adminbar_menus', 'bp_adminbar_login_menu',         2   );
     282add_action( 'bp_adminbar_menus', 'bp_adminbar_account_menu',       4   );
     283add_action( 'bp_adminbar_menus', 'bp_adminbar_blogs_menu',         6   );
     284add_action( 'bp_adminbar_menus', 'bp_adminbar_thisblog_menu',      6   );
     285add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8   );
     286add_action( 'bp_adminbar_menus', 'bp_adminbar_authors_menu',       12  );
     287add_action( 'bp_adminbar_menus', 'bp_adminbar_random_menu',        100 );
     288
     289// Actions used to append admin bar to footer
     290add_action( 'wp_footer',    'bp_core_admin_bar', 8 );
     291add_action( 'admin_footer', 'bp_core_admin_bar'    );
    288292
    289293?>
Note: See TracChangeset for help on using the changeset viewer.