Changeset 7521 for trunk/bp-members/bp-members-adminbar.php
- Timestamp:
- 11/07/2013 05:15:51 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/bp-members/bp-members-adminbar.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-members/bp-members-adminbar.php
r7418 r7521 140 140 */ 141 141 function bp_members_admin_bar_notifications_menu() { 142 global $wp_admin_bar;143 142 144 if ( !is_user_logged_in() ) 143 // Bail if notifications is not active 144 if ( ! bp_is_active( 'notifications' ) ) { 145 145 return false; 146 147 $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' );148 $count = !empty( $notifications ) ? count( $notifications ) : 0;149 $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';150 $menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>';151 152 // Add the top-level Notifications button153 $wp_admin_bar->add_menu( array(154 'parent' => 'top-secondary',155 'id' => 'bp-notifications',156 'title' => $menu_title,157 'href' => bp_loggedin_user_domain(),158 ) );159 160 if ( !empty( $notifications ) ) {161 foreach ( (array) $notifications as $notification ) {162 $wp_admin_bar->add_menu( array(163 'parent' => 'bp-notifications',164 'id' => 'notification-' . $notification->id,165 'title' => $notification->content,166 'href' => $notification->href167 ) );168 }169 } else {170 $wp_admin_bar->add_menu( array(171 'parent' => 'bp-notifications',172 'id' => 'no-notifications',173 'title' => __( 'No new notifications', 'buddypress' ),174 'href' => bp_loggedin_user_domain()175 ) );176 146 } 177 147 178 return;148 bp_notifications_toolbar_menu(); 179 149 } 180 150 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
Note: See TracChangeset
for help on using the changeset viewer.