- Timestamp:
- 10/19/2023 11:34:45 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-notifications/bp-notifications-adminbar.php
r13503 r13614 23 23 */ 24 24 function bp_notifications_toolbar_menu() { 25 global $wp_admin_bar;26 27 25 if ( ! is_user_logged_in() ) { 28 26 return false; … … 30 28 31 29 $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' ); 32 $count = ! empty( $notifications ) ? count( $notifications ) : 0; 33 $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert'; 34 $menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>'; 35 $menu_link = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_notifications_slug() ) ) ); 30 $menu_link = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_notifications_slug() ) ) ); 36 31 37 // Add the top-level Notifications button. 38 $wp_admin_bar->add_node( array( 39 'parent' => 'top-secondary', 40 'id' => 'bp-notifications', 41 'title' => $menu_title, 42 'href' => $menu_link, 43 ) ); 44 45 if ( ! empty( $notifications ) ) { 46 foreach ( (array) $notifications as $notification ) { 47 $wp_admin_bar->add_node( array( 48 'parent' => 'bp-notifications', 49 'id' => 'notification-' . $notification->id, 50 'title' => $notification->content, 51 'href' => $notification->href, 52 ) ); 53 } 54 } else { 55 $wp_admin_bar->add_node( array( 56 'parent' => 'bp-notifications', 57 'id' => 'no-notifications', 58 'title' => __( 'No new notifications', 'buddypress' ), 59 'href' => $menu_link, 60 ) ); 61 } 62 63 return true; 32 return bp_members_admin_bar_notifications_dropdown( $notifications, $menu_link ); 64 33 } 65 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
Note: See TracChangeset
for help on using the changeset viewer.