Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2013 05:15:51 PM (13 years ago)
Author:
johnjamesjacoby
Message:

First pass at bp-notifications component. Includes:

  • 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-adminbar.php

    r7418 r7521  
    140140 */
    141141function bp_members_admin_bar_notifications_menu() {
    142     global $wp_admin_bar;
    143142
    144     if ( !is_user_logged_in() )
     143    // Bail if notifications is not active
     144    if ( ! bp_is_active( 'notifications' ) ) {
    145145        return false;
    146 
    147     $notifications = bp_core_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
    148     $count         = !empty( $notifications ) ? count( $notifications ) : 0;
    149     $alert_class   = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
    150     $menu_title    = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . $count . '</span>';
    151 
    152     // Add the top-level Notifications button
    153     $wp_admin_bar->add_menu( array(
    154         'parent'    => 'top-secondary',
    155         'id'        => 'bp-notifications',
    156         'title'     => $menu_title,
    157         'href'      => bp_loggedin_user_domain(),
    158     ) );
    159 
    160     if ( !empty( $notifications ) ) {
    161         foreach ( (array) $notifications as $notification ) {
    162             $wp_admin_bar->add_menu( array(
    163                 'parent' => 'bp-notifications',
    164                 'id'     => 'notification-' . $notification->id,
    165                 'title'  => $notification->content,
    166                 'href'   => $notification->href
    167             ) );
    168         }
    169     } else {
    170         $wp_admin_bar->add_menu( array(
    171             'parent' => 'bp-notifications',
    172             'id'     => 'no-notifications',
    173             'title'  => __( 'No new notifications', 'buddypress' ),
    174             'href'   => bp_loggedin_user_domain()
    175         ) );
    176146    }
    177147
    178     return;
     148    bp_notifications_toolbar_menu();
    179149}
    180150add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
Note: See TracChangeset for help on using the changeset viewer.