/** * Get a count of unread notification items for a user. * * @since BuddyPress (1.9.0) * * @param int $user_id ID of the user whose unread notifications are being * counted. * @return int Unread notification count. */ function bp_notifications_get_unread_notification_count($user_id = 0) { $notifications = bp_notifications_get_all_notifications_for_user($user_id); $count = !empty($notifications) ? count($notifications) : 0; /** * Filters the count of unread notification items for a user. * * @since BuddyPress (1.9.0) * * @param int $count Count of unread notification items for a user. */ return apply_filters('bp_notifications_get_total_notification_count', (int) $count); }
/** * Get a count of unread notification items for a user. * * @since 1.9.0 * * @param int $user_id ID of the user whose unread notifications are being * counted. * @return int Unread notification count. */ function bp_notifications_get_unread_notification_count($user_id = 0) { $notifications = bp_notifications_get_all_notifications_for_user($user_id); $count = !empty($notifications) ? count($notifications) : 0; /** * Filters the count of unread notification items for a user. * * @since 1.9.0 * @since 2.7.0 Added user ID parameter. * * @param int $count Count of unread notification items for a user. * @param int $user_id User ID for notifications count. */ return apply_filters('bp_notifications_get_total_notification_count', (int) $count, $user_id); }
/** * Get a count of unread notification items for a user. * * @since BuddyPress (1.9.0) * * @param int $user_id ID of the user whose unread notifications are being * counted. * @return int Unread notification count. */ function bp_notifications_get_unread_notification_count($user_id = 0) { $notifications = bp_notifications_get_all_notifications_for_user($user_id); $count = !empty($notifications) ? count($notifications) : 0; return apply_filters('bp_notifications_get_total_notification_count', (int) $count); }
/** * Sending a heartbeat for notification updates * * @since Boss 1.0.0 * */ function buddyboss_notification_count_heartbeat($response, $data, $screen_id) { if (function_exists("bp_friend_get_total_requests_count")) { $friend_request_count = bp_friend_get_total_requests_count(); } if (function_exists("bp_notifications_get_all_notifications_for_user")) { $notifications = bp_notifications_get_all_notifications_for_user(get_current_user_id()); } $notification_count = count($notifications); if (function_exists("bp_notifications_get_all_notifications_for_user")) { $notifications = bp_notifications_get_notifications_for_user(get_current_user_id()); foreach ((array) $notifications as $notification) { $notification_content .= $notification; } if (empty($notification_content)) { $notification_content = '<a href="' . bp_loggedin_user_domain() . '' . BP_NOTIFICATIONS_SLUG . '/">' . __("No new notifications", "buddypress") . '</a>'; } } if (function_exists("messages_get_unread_count")) { $unread_message_count = messages_get_unread_count(); } $response['bb_notification_count'] = array('friend_request' => @intval($friend_request_count), 'notification' => @intval($notification_count), 'notification_content' => @$notification_content, 'unread_message' => @intval($unread_message_count)); return $response; }