Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/19/2023 11:34:45 PM (3 years ago)
Author:
imath
Message:

Introduce Admin Notifications to warn Admin about important BP changes

  • Add a new Administration screen to list Admin notifications.
  • Put the logic in place to dismiss an Admin notification.
  • Add a 11.4 update task to add unread Admin notifications.
  • Create a 11.4 Admin Notification to inform Admin users about whether they need to install BP Classic to be ready for BuddyPress 12.0.0

Props dcavins

Closes https://github.com/buddypress/buddypress/pull/176
See #9007 (trunk)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-notifications/bp-notifications-adminbar.php

    r13503 r13614  
    2323 */
    2424function bp_notifications_toolbar_menu() {
    25         global $wp_admin_bar;
    26 
    2725        if ( ! is_user_logged_in() ) {
    2826                return false;
     
    3028
    3129        $notifications = bp_notifications_get_notifications_for_user( bp_loggedin_user_id(), 'object' );
    32         $count       = ! empty( $notifications ) ? count( $notifications ) : 0;
    33         $alert_class = (int) $count > 0 ? 'pending-count alert' : 'count no-alert';
    34         $menu_title  = '<span id="ab-pending-notifications" class="' . $alert_class . '">' . number_format_i18n( $count ) . '</span>';
    35         $menu_link   = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_notifications_slug() ) ) );
     30        $menu_link     = bp_loggedin_user_url( bp_members_get_path_chunks( array( bp_get_notifications_slug() ) ) );
    3631
    37         // Add the top-level Notifications button.
    38         $wp_admin_bar->add_node( array(
    39                 'parent' => 'top-secondary',
    40                 'id'     => 'bp-notifications',
    41                 'title'  => $menu_title,
    42                 'href'   => $menu_link,
    43         ) );
    44 
    45         if ( ! empty( $notifications ) ) {
    46                 foreach ( (array) $notifications as $notification ) {
    47                         $wp_admin_bar->add_node( array(
    48                                 'parent' => 'bp-notifications',
    49                                 'id'     => 'notification-' . $notification->id,
    50                                 'title'  => $notification->content,
    51                                 'href'   => $notification->href,
    52                         ) );
    53                 }
    54         } else {
    55                 $wp_admin_bar->add_node( array(
    56                         'parent' => 'bp-notifications',
    57                         'id'     => 'no-notifications',
    58                         'title'  => __( 'No new notifications', 'buddypress' ),
    59                         'href'   => $menu_link,
    60                 ) );
    61         }
    62 
    63         return true;
     32        return bp_members_admin_bar_notifications_dropdown( $notifications, $menu_link );
    6433}
    65 add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
Note: See TracChangeset for help on using the changeset viewer.