function my_bp_adminbar_notifications_menu() { global $bp; if (!is_user_logged_in()) { return false; } echo '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">'; _e('Notifications', 'buddypress'); if ($notifications = bp_core_get_notifications_for_user($bp->loggedin_user->id)) { ?> <span><?php echo count($notifications); ?> </span> <?php } echo '</a>'; echo '<ul>'; if ($notifications) { ?> <?php $counter = 0; ?> <?php for ($i = 0; $i < count($notifications); $i++) { ?> <?php $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; ?> <?php } ?> <?php } else { ?> <li><a href="<?php echo $bp->loggedin_user->domain; ?> "><?php _e('No new notifications.', 'buddypress'); ?> </a></li> <?php } echo '</ul>'; echo '</li>'; }
/** * Notifications Menu */ function bp_adminbar_notifications_menu() { if (!is_user_logged_in()) { return false; } echo '<li id="bp-adminbar-notifications-menu"><a href="' . bp_loggedin_user_domain() . '">'; _e('Notifications', 'buddypress'); if ($notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id())) { ?> <span><?php echo count($notifications); ?> </span> <?php } echo '</a>'; echo '<ul>'; if ($notifications) { $counter = 0; for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; } } else { ?> <li><a href="<?php echo bp_loggedin_user_domain(); ?> "><?php _e('No new notifications.', 'buddypress'); ?> </a></li> <?php } echo '</ul>'; echo '</li>'; }
function bpln_get_all_notification() { global $bp; if (!is_user_logged_in()) { return false; } $html = '<li id="bp-adminbar-notifications-menu"><a href="' . $bp->loggedin_user->domain . '">'; $html .= __('Notifications', 'buddypress'); if ($notifications = bp_core_get_notifications_for_user($bp->loggedin_user->id)) { $html .= "<span>" . count($notifications) . "</span>"; } $html .= '</a><ul>'; if ($notifications) { $counter = 0; for ($i = 0; $i < count($notifications); $i++) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; $html .= "<li {$alt} >" . $notifications[$i] . "</li>"; $counter++; } } else { $html .= "<li><a href='" . $bp->loggedin_user->domain . "'>" . __('No new notifications.', 'buddypress') . "</a></li>"; } $html .= '</ul></li>'; return $html; }
/** * Build the "Notifications" dropdown * * @package Buddypress * @since BuddyPress (1.5) */ function bp_members_admin_bar_notifications_menu() { global $wp_admin_bar; if (!is_user_logged_in()) { return false; } $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object'); $count = !empty($notifications) ? count($notifications) : 0; $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert'; $menu_title = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>'; // Add the top-level Notifications button $wp_admin_bar->add_menu(array('parent' => 'top-secondary', 'id' => 'bp-notifications', 'title' => $menu_title, 'href' => bp_loggedin_user_domain())); if (!empty($notifications)) { foreach ((array) $notifications as $notification) { $wp_admin_bar->add_menu(array('parent' => 'bp-notifications', 'id' => 'notification-' . $notification->id, 'title' => $notification->content, 'href' => $notification->href)); } } else { $wp_admin_bar->add_menu(array('parent' => 'bp-notifications', 'id' => 'no-notifications', 'title' => __('No new notifications', 'buddypress'), 'href' => bp_loggedin_user_domain())); } return; }
/** * Returns an object with notifications for the current user * @return Object Notifications */ public function get_notifications() { /* Possible parameters: * none */ $oReturn = new stdClass(); $aNotifications = bp_core_get_notifications_for_user(get_current_user_id()); if (empty($aNotifications)) { return $this->error('notification'); } foreach ($aNotifications as $sNotificationMessage) { $oTemp = new stdClass(); $oTemp->msg = $sNotificationMessage; $oReturn->notifications[] = $oTemp; } return $oReturn; }
/** * Build the "Notifications" dropdown * * @package Buddypress * @since 1.5 */ function bp_members_admin_bar_notifications_menu() { global $bp, $wp_admin_bar; if (!is_user_logged_in()) { return false; } if ($notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object')) { $menu_title = sprintf(__('Notifications <span id="ab-pending-notifications" class="pending-count">%s</span>', 'buddypress'), count($notifications)); } else { $menu_title = __('Notifications', 'buddypress'); } // Add the top-level Notifications button $wp_admin_bar->add_menu(array('id' => 'bp-notifications', 'title' => $menu_title, 'href' => bp_loggedin_user_domain())); if (!empty($notifications)) { foreach ((array) $notifications as $notification) { $wp_admin_bar->add_menu(array('parent' => 'bp-notifications', 'id' => 'notification-' . $notification->id, 'title' => $notification->content, 'href' => $notification->href)); } } else { $wp_admin_bar->add_menu(array('parent' => 'bp-notifications', 'id' => 'no-notifications', 'title' => __('No new notifications', 'buddypress'), 'href' => bp_loggedin_user_domain())); } return; }
<?php if ($notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id())) { echo '<div id="notifications-header"><ul>'; if ($notifications) { $counter = 0; for ($i = 0; $i < count($notifications); $i++) { $badge = count($notifications); echo '<li>' . $notifications[$i] . '</li>'; } echo '</ul></div>'; echo '<span id="notifications-badge">' . $badge . '</span>'; } } ?> <?php do_action('bp_after_container'); ?> <?php do_action('bp_before_footer'); ?> <div id="footer"> <p><a href="" id="theme-switch">view non-mobile site</a></p> <?php do_action('bp_after_footer');
/** * Display Notifications Menu in the Header of the theme * * @since v1.0 */ function bpmagic_notifications_menu() { if (class_exists('ClearBpNotifications')) { ClearBpNotifications::add_notifications_menu(); return; } echo '<li class="top-nav-main-item top-nav-item-first top-notification-menu"><a href="' . bp_loggedin_user_domain() . '">' . __('Notifications', 'bp-magic'); if (function_exists('bp_notifications_get_notifications_for_user')) { $notifications = bp_notifications_get_notifications_for_user(bp_loggedin_user_id()); } else { $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id()); //this method is depricated in 1.9 } if ($notifications) { ?> <span><?php echo count($notifications); ?> </span> <?php } echo '</a>'; echo '<ul>'; if ($notifications) { $counter = 0; for ($i = 0, $count = count($notifications); $i < $count; ++$i) { $alt = 0 == $counter % 2 ? ' class="alt"' : ''; ?> <li<?php echo $alt; ?> ><?php echo $notifications[$i]; ?> </li> <?php $counter++; } } else { ?> <li><a href="<?php echo bp_loggedin_user_domain(); ?> "><?php _e('No new notifications.', 'bp-magic'); ?> </a></li> <?php } echo '</ul>'; echo '</li>'; }
function cg_current_user_notification_count() { $notifications = bp_core_get_notifications_for_user(bp_loggedin_user_id(), 'object'); $count = !empty($notifications) ? count($notifications) : 0; echo $count; }