mirror of
https://gh.wpcy.net/https://github.com/buddypress/buddypress.git
synced 2026-06-01 06:04:04 +08:00
* Backwards compatibility for old core functions. * Screens, functions, classes, and actions for Notifications. * Improved class methods for getting, updating, and deleting notifications. * Template parts in bp-legacy for theme compatibility. * A few basic unit tests. @todo's: * Improve template output with dedicated functions, markup, classes, et all. * More unit tests. * Pagination links. * Auto-activate on update, so existing installations do not lose previously core functionality. See #5148. Props johnjamesjacoby, boonebgorges, r-a-y. git-svn-id: https://buddypress.svn.wordpress.org/trunk@7521 cdf35c40-ae34-48e0-9cc9-0c9da1808c22
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
|
|
/**
|
|
* BuddyPress Notifications Navigational Functions.
|
|
*
|
|
* Sets up navigation elements, including BuddyBar functionality, for the
|
|
* Notifications component.
|
|
*
|
|
* @package BuddyPress
|
|
* @subpackage NotificationsBuddyBar
|
|
*/
|
|
|
|
// Exit if accessed directly
|
|
if ( !defined( 'ABSPATH' ) ) exit;
|
|
|
|
/**
|
|
* Create the Notifications menu for the BuddyBar.
|
|
*
|
|
* @since BuddyPress (1.9.0)
|
|
*/
|
|
function bp_notifications_buddybar_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
|
|
endif;
|
|
|
|
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>';
|
|
}
|
|
add_action( 'bp_adminbar_menus', 'bp_adminbar_notifications_menu', 8 );
|