I've a WordPress website, and I try to implement some modifications to buddypress. I've recently succeed to displays notifications in my main menu, but I want to change some colors, if the count is more than 0.
So: If the the value (maybe $notif ? ) is higher than 0, the class "pending-count" have to change into "pending-count-alert"...
If you can help me.... Thanks in advance!
<?php
function my_nav_menu_notif_counter($menu) {
if (!is_user_logged_in())
return $menu;
else
$notif = '<li ><a class="ab-item" href="' . bp_core_get_user_domain(bp_loggedin_user_id() ) . 'notifications/">'. __('').'<span id="ab-pending-notifications" class="pending-count alert">'. __(''). bp_notifications_get_unread_notification_count( bp_loggedin_user_id() ) .'</span> </a></li>';
$menu = $menu . $notif;
return $menu;
}
add_filter( 'wp_nav_menu_items', 'my_nav_menu_notif_counter' );
add_filter( 'show_admin_bar', '__return_false' );
?>
Try something like below:
$unreadNotificationCount = bp_notifications_get_unread_notification_count( bp_loggedin_user_id() );
$notif = '<li ><a class="ab-item" href="' . bp_core_get_user_domain(bp_loggedin_user_id() ) . 'notifications/">'. __('').'<span id="ab-pending-notifications" class="' . ( $unreadNotificationCount > 0 ? 'pending-count-alert' : 'pending-count' ) .' alert">'. __(''). $unreadNotificationCount .'</span> </a></li>';