Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/06/2011 06:52:09 AM (13 years ago)
Author:
johnjamesjacoby
Message:

First pass at updating the admin/toolbar for WordPress 3.3. See #3596.

File:
1 edited

Legend:

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

    r5282 r5289  
    3939        // Backward-compatibility will be deprecated at some point.
    4040        if ( version_compare( (float)$wp_version, '3.3', '>=' ) ) {
     41
    4142            // Stored in the global so we can add menus easily later on
    42             $bp->my_account_menu_id = 'my-account';
     43            $bp->my_account_menu_id = 'my-account-buddypress';
    4344
    4445            $title = bp_get_loggedin_user_fullname() . $avatar;
     
    182183        return false;
    183184
    184     if ( $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' ) ) {
    185         $menu_title = sprintf( __( 'Notifications <span id="ab-pending-notifications" class="pending-count">%s</span>', 'buddypress' ), count( $notifications ) );
    186     } else {
    187         $menu_title = __( 'Notifications', 'buddypress' );
    188     }
     185    $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
     186    $count         = !empty( $notifications ) ? count( $notifications ) : '0';
     187    $alert_class   = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
     188    $menu_title    = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>';
    189189
    190190    // Add the top-level Notifications button
     
    192192        'id'    => 'bp-notifications',
    193193        'title' => $menu_title,
    194         'href'  => bp_loggedin_user_domain()
     194        'href'  => bp_loggedin_user_domain(),
     195        'meta'  => array(
     196            'class' => 'opposite',
     197        )
    195198    ) );
    196199
     
    217220add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
    218221
    219 /**
    220  * Make sure the logout link is at the bottom of the "My Account" menu
    221  *
    222  * @since BuddyPress (r4151)
    223  *
    224  * @global obj $bp
    225  * @global obj $wp_admin_bar
    226  */
    227 function bp_members_admin_bar_my_account_logout() {
    228     global $bp, $wp_admin_bar;
    229 
    230     // Bail if this is an ajax request
    231     if ( defined( 'DOING_AJAX' ) )
    232         return;
    233 
    234     if ( is_user_logged_in() ) {
    235         // Log out
    236         $wp_admin_bar->add_menu( array(
    237             'parent' => $bp->my_account_menu_id,
    238             'id'     => $bp->my_account_menu_id . '-logout',
    239             'title'  => __( 'Log Out', 'buddypress' ),
    240             'href'   => wp_logout_url()
    241         ) );
    242     }
    243 }
    244 add_action( 'admin_bar_menu', 'bp_members_admin_bar_my_account_logout', 9999 );
    245 
    246222?>
Note: See TracChangeset for help on using the changeset viewer.