2016-10-15 7 views
-2

나는 워드 프레스 웹 사이트를 운영 중이며 buddypress에 약간의 수정을가하려고합니다. 최근 메인 메뉴의 알림 표시에 성공했지만 개수가 0보다 많으면 일부 색상을 변경하고 싶습니다.수가 0 (PHP) 이상인 경우 클래스를 변경하는 방법은 무엇입니까?

So : 값 (아마도 $ notif?)이 0보다 큰 경우 , "pending-count"클래스는 "pending-count-alert"으로 변경되어야합니다 ...

당신이 저를 도울 수 있다면 .... 미리 감사드립니다!

<?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'); 
?> 

답변

0

시도 뭔가 아래 같은 :

$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>';