Skip to:
Content

BuddyPress.org

Changeset 13614


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)

Location:
trunk/src
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/admin/bp-core-admin-functions.php

    r13586 r13614  
    505505            'name' => __( 'Options', 'buddypress' ),
    506506        ),
    507         '3' => array(
     507        '4' => array(
    508508            'id'   => 'bp-credits',
    509509            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
     
    517517            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-rewrites' ), 'admin.php' ) ),
    518518            'name' => __( 'URLs', 'buddypress' ),
     519        );
     520    }
     521
     522    if ( bp_core_get_unread_admin_notifications() || ( isset( $_GET['page'] ) && 'bp-admin-notifications' === $_GET['page'] ) ) {
     523        $settings_tabs['3'] = array(
     524            'id'   => 'bp-admin-notifications',
     525            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-admin-notifications' ), 'admin.php' ) ),
     526            'name' => __( 'Notifications', 'buddypress' ),
    519527        );
    520528    }
     
    14501458 */
    14511459function bp_core_admin_notice_dismiss_callback() {
    1452     if ( ! current_user_can( 'install_plugins' ) ) {
     1460    if ( ! current_user_can( 'manage_options' ) ) {
    14531461        wp_send_json_error();
    14541462    }
     
    14771485    }
    14781486
    1479     bp_update_option( "bp-dismissed-notice-{$notice_id}", true );
     1487    bp_core_dismiss_admin_notification( $notice_id );
    14801488
    14811489    wp_send_json_success();
     
    15551563}
    15561564add_action( 'bp_init', 'bp_block_init_category_filter' );
     1565
     1566/**
     1567 * Outputs an Admin Notification.
     1568 *
     1569 * @since 11.4.0
     1570 *
     1571 * @param object $notification An Admin Notification object.
     1572 */
     1573function bp_core_admin_format_notifications( $notification = null ) {
     1574    if ( ! isset( $notification->id ) ) {
     1575        return '';
     1576    }
     1577    ?>
     1578    <div class="bp-welcome-panel bp-notice-container">
     1579        <a class="bp-welcome-panel-close bp-is-dismissible" href="#" data-notice_id="<?php echo esc_attr( $notification->id ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the notification', 'buddypress' ); ?>"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a>
     1580        <div class="bp-welcome-panel-content">
     1581            <h2><span class="bp-version"><?php echo number_format_i18n( $notification->version, 1 ); ?></span> <?php echo esc_html( $notification->title ); ?></h2>
     1582            <p class="about-description">
     1583                <?php echo wp_kses( $notification->content, array( 'a' => array( 'href' => true ), 'br' => array(), 'strong' => array() ) ); ?>
     1584            </p>
     1585            <div class="bp-admin-notification-action"><a href="<?php echo esc_url( $notification->href ); ?>" class="button button-primary"><?php echo esc_html( $notification->text ); ?></a></div>
     1586        </div>
     1587    </div>
     1588    <?php
     1589}
  • trunk/src/bp-core/admin/css/common-rtl.css

    r13368 r13614  
    4141.bp-badge:before {
    4242    content: "\f448";
     43}
     44
     45.bp-version {
     46    color: #fff;
     47    background: #d84800;
     48    padding: 2px 5px;
    4349}
    4450
     
    614620
    615621.buddypress .bp-welcome-panel-content p {
    616     padding-bottom: 23px;
    617622    font-size: 14px;
     623}
     624
     625.buddypress .bp-welcome-panel-content .bp-admin-notification-action {
     626    margin: 23px 0;
    618627}
    619628
     
    698707}
    699708
     709.buddypress-body .form-table.hide {
     710    display: none;
     711}
     712
    700713/* Media queries */
    701714@media screen and (max-width: 782px) {
  • trunk/src/bp-core/admin/css/common.css

    r13368 r13614  
    4141.bp-badge:before {
    4242    content: "\f448";
     43}
     44
     45.bp-version {
     46    color: #fff;
     47    background: #d84800;
     48    padding: 2px 5px;
    4349}
    4450
     
    614620
    615621.buddypress .bp-welcome-panel-content p {
    616     padding-bottom: 23px;
    617622    font-size: 14px;
     623}
     624
     625.buddypress .bp-welcome-panel-content .bp-admin-notification-action {
     626    margin: 23px 0;
    618627}
    619628
     
    698707}
    699708
     709.buddypress-body .form-table.hide {
     710    display: none;
     711}
     712
    700713/* Media queries */
    701714@media screen and (max-width: 782px) {
  • trunk/src/bp-core/admin/js/dismissible-admin-notices.js

    r13463 r13614  
    1 !function(){window.bp=window.bp||{},bp.DismissibleAdminNotices=class{constructor(t){this.settings=t||{}}start(){const{url:t,nonce:e}=this.settings;t&&e&&document.querySelectorAll(".bp-is-dismissible").forEach((s=>{s.addEventListener("click",(s=>{s.preventDefault();const n=s.target;if(n.classList.contains("loading"))return;n.classList.add("loading");const{notice_id:i}=n.dataset,o=n.closest(".bp-notice-container"),c=new Headers({"X-BP-Nonce":e}),d=new FormData;d.append("action","bp_dismiss_notice"),d.append("notice_id",i),fetch(t,{method:"POST",headers:c,body:d}).then((t=>t.json())).then((t=>{const{success:e}=t;e?o.remove():n.classList.remove("loading")}))}))}))}};const t=window.bpDismissibleAdminNoticesSettings||{},e=new bp.DismissibleAdminNotices(t);"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e.start()):e.start()}();
     1!function(){window.bp=window.bp||{},bp.DismissibleAdminNotices=class{constructor(e){this.settings=e||{}}start(){const{url:e,nonce:t}=this.settings;e&&t&&document.querySelectorAll(".bp-is-dismissible").forEach((n=>{n.addEventListener("click",(n=>{n.preventDefault();const s=n.target;if(s.classList.contains("loading"))return;s.classList.add("loading");const{notice_id:i}=s.dataset,o=s.closest(".bp-notice-container"),c=new Headers({"X-BP-Nonce":t}),d=new FormData;d.append("action","bp_dismiss_notice"),d.append("notice_id",i),fetch(e,{method:"POST",headers:c,body:d}).then((e=>e.json())).then((e=>{const{success:t}=e;t?(o.remove(),0===document.querySelectorAll(".bp-notice-container").length&&document.querySelector("#no-admin-notifications").classList.remove("hide")):s.classList.remove("loading")}))}))}))}};const e=window.bpDismissibleAdminNoticesSettings||{},t=new bp.DismissibleAdminNotices(e);"loading"===document.readyState?document.addEventListener("DOMContentLoaded",t.start()):t.start()}();
  • trunk/src/bp-core/bp-core-functions.php

    r13547 r13614  
    50495049    return apply_filters( 'bp_get_community_visibility', $retval, $component );
    50505050}
     5051
     5052/**
     5053 * Returns the list of unread Admin Notification IDs.
     5054 *
     5055 * @since 11.4.0
     5056 *
     5057 * @return array The list of unread Admin Notification IDs.
     5058 */
     5059function bp_core_get_unread_admin_notifications() {
     5060    return (array) bp_get_option( 'bp_unread_admin_notifications', array() );
     5061}
     5062
     5063/**
     5064 * Dismisses an Admin Notification.
     5065 *
     5066 * @since 11.4.0
     5067 *
     5068 * @param string $notification_id The Admin Notification to dismiss.
     5069 */
     5070function bp_core_dismiss_admin_notification( $notification_id = '' ) {
     5071    $unread    = bp_core_get_unread_admin_notifications();
     5072    $remaining = array_diff( $unread, array( $notification_id ) );
     5073    bp_update_option( 'bp_unread_admin_notifications', $remaining );
     5074}
     5075
     5076/**
     5077 * @since 11.4.0
     5078 *
     5079 * @return array The list of Admin notifications.
     5080 */
     5081function bp_core_get_admin_notifications() {
     5082    $unreads = bp_core_get_unread_admin_notifications();
     5083    if ( ! $unreads ) {
     5084        return array();
     5085    }
     5086
     5087    $admin_notifications = array(
     5088        'bp100-welcome-addons' => (object) array(
     5089            'id'      => 'bp100-welcome-addons',
     5090            'href'    => add_query_arg(
     5091                array(
     5092                    'tab' => 'bp-add-ons',
     5093                    'n'   => 'bp100-welcome-addons',
     5094                ),
     5095                bp_get_admin_url( 'plugin-install.php' )
     5096            ),
     5097            'text'    => __( 'Discover BuddyPress Add-ons', 'buddypress' ),
     5098            'title'   => __( 'Hello BuddyPress Add-ons!', 'buddypress' ),
     5099            'content' => __( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ) .
     5100                         __( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ),
     5101            'version' => 10.0,
     5102        ),
     5103        'bp114-prepare-for-rewrites' => (object) array(
     5104            'id'      => 'bp114-prepare-for-rewrites',
     5105            'href'    => add_query_arg(
     5106                array(
     5107                    'tab'  => 'bp-add-ons',
     5108                    'show' => 'bp-classic',
     5109                    'n'    => 'bp114-prepare-for-rewrites'
     5110                ),
     5111                bp_get_admin_url( 'plugin-install.php' )
     5112            ),
     5113            'text'    => __( 'Get The BP Classic Add-on', 'buddypress' ),
     5114            'title'   => __( 'Get ready for the brand-new BP Rewrites API!', 'buddypress' ),
     5115            'content' => __( 'Our next major version (12.0.0) will introduce several large changes that could be incompatible with your site\'s configuration. To prevent problems, we\'ve built the BP Classic Add-on, which you may want to proactively install if any of the following cases:', 'buddypress' ) . '<br><br>' .
     5116                '<strong>' . __( 'Some of your BuddyPress plugins have not been updated lately.', 'buddypress' ) . '</strong><br>' .
     5117                __( 'BuddyPress 12.0.0 introduces the BP Rewrites API, which completely changes the way BuddyPress URLs are built and routed. This fundamental change requires most BuddyPress plugins to update how they deal with BuddyPress URLs. If your BuddyPress plugins have not been updated in the last few months, they are probably not ready for BuddyPress 12.0.0.', 'buddypress' ) . '<br><br>' .
     5118                '<strong>' . __( 'You are still using the BP Default theme.', 'buddypress' ) . '</strong><br><br>' .
     5119                '<strong>' . __( 'You still use a BP Legacy Widget.', 'buddypress' ) . '</strong><br><br>' .
     5120                __( 'If any of the above items are true, we strongly advise you to install and activate the Classic Add-on before updating to BuddyPress 12.0.0.', 'buddypress' ),
     5121                'version' => 11.4,
     5122        )
     5123    );
     5124
     5125    // Only keep unread notifications.
     5126    foreach ( array_keys( $admin_notifications ) as $notification_id ) {
     5127        if ( ! in_array( $notification_id, $unreads, true ) ) {
     5128            unset( $admin_notifications[ $notification_id ] );
     5129        }
     5130    }
     5131
     5132    return $admin_notifications;
     5133}
  • trunk/src/bp-core/bp-core-update.php

    r13536 r13614  
    288288
    289289        // Version 11.0.0.
    290         if ( $raw_db_version < 13271 ){
     290        if ( $raw_db_version < 13271 ) {
    291291            bp_update_to_11_0();
    292292        }
    293293
     294        // Version 11.4.0.
     295        if ( $raw_db_version < 13408 ) {
     296            bp_update_to_11_4();
     297        }
     298
    294299        // Version 12.0.0.
    295         if ( $raw_db_version < 13422 ){
     300        if ( $raw_db_version < 13422 ) {
    296301            bp_update_to_12_0();
    297302        }
     
    796801
    797802    return $new_emails;
     803}
     804
     805/**
     806 * 11.4.0 update routine.
     807 *
     808 * @since 11.4.0
     809 */
     810function bp_update_to_11_4() {
     811    $unread = array( 'bp114-prepare-for-rewrites' );
     812
     813    // Check if 10.0 notice was dismissed.
     814    $old_dismissed = (bool) bp_get_option( 'bp-dismissed-notice-bp100-welcome-addons', false );
     815    if ( ! $old_dismissed ) {
     816        $unread[] = 'bp100-welcome-addons';
     817    }
     818
     819    // Remove the dismissible option.
     820    bp_delete_option( 'bp-dismissed-notice-bp100-welcome-addons' );
     821
     822    // Create unread Admin notifications.
     823    bp_update_option( 'bp_unread_admin_notifications', $unread );
    798824}
    799825
  • trunk/src/bp-core/classes/class-bp-admin.php

    r13595 r13614  
    304304        $this->submenu_pages['settings']['bp-settings'] = $bp_settings_page;
    305305        $hooks[]                                        = $bp_settings_page;
     306
     307        // Admin notifications.
     308        $bp_admin_notifications = add_submenu_page(
     309            $this->settings_page,
     310            __( 'BuddyPress Admin Notifications', 'buddypress' ),
     311            __( 'BuddyPress Admin Notifications', 'buddypress' ),
     312            $this->capability,
     313            'bp-admin-notifications',
     314            array( $this, 'admin_notifications' )
     315        );
     316
     317        $this->submenu_pages['settings']['bp-admin-notifications'] = $bp_admin_notifications;
     318        $hooks[]                                                   = $bp_admin_notifications;
    306319
    307320        // Credits.
     
    642655
    643656        // Settings pages.
    644         remove_submenu_page( $this->settings_page, 'bp-rewrites' );
    645         remove_submenu_page( $this->settings_page, 'bp-settings' );
    646         remove_submenu_page( $this->settings_page, 'bp-credits'  );
     657        remove_submenu_page( $this->settings_page, 'bp-rewrites'            );
     658        remove_submenu_page( $this->settings_page, 'bp-settings'            );
     659        remove_submenu_page( $this->settings_page, 'bp-credits'             );
     660        remove_submenu_page( $this->settings_page, 'bp-admin-notifications' );
    647661
    648662        // Network Admin Tools.
     
    15561570     */
    15571571    public function display_addons_table() {
    1558         $notice_id = 'bp100-welcome-addons';
    1559         $dismissed = bp_get_option( "bp-dismissed-notice-{$notice_id}", false );
    1560 
    1561         if ( ! $dismissed ) {
    1562             // Enqueue the Script to Ajax Dismiss an Admin notice.
    1563             wp_enqueue_script( 'bp-dismissible-admin-notices' );
    1564 
    1565             ?>
    1566             <div class="bp-welcome-panel bp-notice-container">
    1567                 <a class="bp-welcome-panel-close bp-is-dismissible" href="#" data-notice_id="<?php echo esc_attr( $notice_id ); ?>" aria-label="<?php esc_attr_e( 'Dismiss the welcome panel', 'buddypress' ); ?>"><?php esc_html_e( 'Dismiss', 'buddypress' ); ?></a>
    1568                 <div class="bp-welcome-panel-content">
    1569                     <h2><span class="bp-badge"></span> <?php esc_html_e( 'Hello BuddyPress Add-ons!', 'buddypress' ); ?></h2>
    1570                     <p class="about-description">
    1571                         <?php esc_html_e( 'Add-ons are features as Plugins or Blocks maintained by the BuddyPress development team & hosted on the WordPress.org plugins directory.', 'buddypress' ); ?>
    1572                         <?php esc_html_e( 'Thanks to this new tab inside your Dashboard screen to add plugins, you’ll be able to find them faster and eventually contribute to beta features early to give the BuddyPress development team your feedbacks.', 'buddypress' ); ?>
    1573                     </p>
    1574                 </div>
    1575             </div>
    1576             <?php
    1577         }
    1578 
    15791572        if ( isset( $_GET['show'] ) && 'bp-classic' === $_GET['show'] ) {
    15801573            wp_add_inline_script(
     
    15921585        }
    15931586
     1587        if ( isset( $_GET['n'] ) && $_GET['n'] ) {
     1588            $notification_id = sanitize_text_field( wp_unslash( $_GET['n'] ) );
     1589            bp_core_dismiss_admin_notification( $notification_id );
     1590        }
     1591
    15941592        // Display the "buddypress" favorites.
    15951593        display_plugins_table();
    15961594    }
     1595
     1596    /**
     1597     * Display the Admin Notifications screen.
     1598     *
     1599     * @since 11.4.0
     1600     */
     1601    public function admin_notifications() {
     1602        bp_core_admin_tabbed_screen_header( __( 'BuddyPress Settings', 'buddypress' ), __( 'Notifications', 'buddypress' ) );
     1603        $notifications = bp_core_get_admin_notifications();
     1604        $class         = '';
     1605
     1606        if ( $notifications ) {
     1607            wp_enqueue_script( 'bp-dismissible-admin-notices' );
     1608            $notifications = array_reverse( bp_sort_by_key( $notifications, 'version', 'num' ) );
     1609            $class         = 'hide';
     1610        }
     1611        ?>
     1612        <div class="buddypress-body admin-notifications">
     1613            <table id="no-admin-notifications" class="form-table <?php echo sanitize_html_class( $class ); ?>" role="presentation">
     1614                <tbody>
     1615                    <tr><td><?php esc_html_e( 'No new Admin Notfications', 'buddypress' ); ?></td><tr>
     1616                </tbody>
     1617            </table>
     1618
     1619            <?php if ( $notifications ) : foreach ( $notifications as $notification ) : ?>
     1620                <?php bp_core_admin_format_notifications( $notification ); ?>
     1621            <?php endforeach; endif; ?>
     1622        </div>
     1623        <?php
     1624    }
    15971625}
    15981626endif; // End class_exists check.
  • trunk/src/bp-core/css/admin-bar-rtl.css

    r12877 r13614  
    4747}
    4848
     49#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert.admin-type {
     50    background-color: #d84800;
     51}
     52
    4953#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a {
    5054    padding: 0 0.5em;
  • trunk/src/bp-core/css/admin-bar.css

    r12877 r13614  
    4747}
    4848
     49#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications #ab-pending-notifications.alert.admin-type {
     50    background-color: #d84800;
     51}
     52
    4953#wpadminbar .quicklinks li#wp-admin-bar-bp-notifications > a {
    5054    padding: 0 0.5em;
  • trunk/src/bp-members/bp-members-adminbar.php

    r13503 r13614  
    168168 * Build the "Notifications" dropdown.
    169169 *
     170 * @since 11.4.0
     171 */
     172function bp_members_admin_bar_notifications_dropdown( $notifications = array(), $menu_link = '', $type = 'members' ) {
     173    if ( ! $menu_link || ( 'admin' === $type && empty( $notifications ) ) ) {
     174        return false;
     175    }
     176
     177    global $wp_admin_bar;
     178
     179    $count       = 0;
     180    $alert_class = array( 'count', 'no-alert' );
     181
     182    if ( ! empty( $notifications ) ) {
     183        $count       = number_format_i18n( count( $notifications ) );
     184        $alert_class = array( 'pending-count', 'alert' );
     185
     186        if ( 'admin' === $type ) {
     187            $count = '!';
     188        }
     189    };
     190
     191    $alert_class[] = $type . '-type';
     192    $menu_title    = sprintf(
     193        '<span id="ab-pending-notifications" class="%1$s">%2$s</span>',
     194        implode( ' ', array_map( 'sanitize_html_class', $alert_class ) ),
     195        $count
     196    );
     197
     198    // Add the top-level Notifications button.
     199    $wp_admin_bar->add_node( array(
     200        'parent' => 'top-secondary',
     201        'id'     => 'bp-notifications',
     202        'title'  => $menu_title,
     203        'href'   => $menu_link,
     204    ) );
     205
     206    if ( ! empty( $notifications ) ) {
     207        foreach ( (array) $notifications as $notification ) {
     208            $wp_admin_bar->add_node( array(
     209                'parent' => 'bp-notifications',
     210                'id'     => 'notification-' . $notification->id,
     211                'title'  => $notification->content,
     212                'href'   => $notification->href,
     213            ) );
     214        }
     215    } else {
     216        $wp_admin_bar->add_node( array(
     217            'parent' => 'bp-notifications',
     218            'id'     => 'no-notifications',
     219            'title'  => __( 'No new notifications', 'buddypress' ),
     220            'href'   => $menu_link,
     221        ) );
     222    }
     223
     224    return true;
     225}
     226
     227/**
     228 * Build the Admin or Members "Notifications" dropdown.
     229 *
    170230 * @since 1.5.0
    171231 *
     
    173233 */
    174234function bp_members_admin_bar_notifications_menu() {
    175 
    176     // Bail if notifications is not active.
    177     if ( ! bp_is_active( 'notifications' ) ) {
    178         return false;
    179     }
    180 
    181     bp_notifications_toolbar_menu();
     235    $admins_notifications = array();
     236    $capability           = 'manage_options';
     237
     238    if ( bp_core_do_network_admin() ) {
     239        $capability = 'manage_network_options';
     240    }
     241
     242    if ( bp_current_user_can( $capability ) ) {
     243        $notifications = bp_core_get_admin_notifications();
     244
     245        if ( $notifications ) {
     246            $menu_link = esc_url( bp_get_admin_url( add_query_arg( 'page', 'bp-admin-notifications', 'admin.php' ) ) );
     247            $count     = count( $notifications );
     248
     249            $notifications = array(
     250                (object) array(
     251                    'id'      => 'bp-admin-notifications',
     252                    'href'    => $menu_link,
     253                    'content' => sprintf(
     254                        /* translators: %s: the number of admin notifications */
     255                        _n( 'You have %s new important admin notification.', 'You have %s new important admin notifications.', $count, 'buddypress' ),
     256                        number_format_i18n( $count )
     257                    ),
     258                ),
     259            );
     260
     261            return bp_members_admin_bar_notifications_dropdown( $notifications, $menu_link, 'admin' );
     262        }
     263    }
     264
     265    // Use Members notifications if the component is active.
     266    if ( bp_is_active( 'notifications' ) ) {
     267        return bp_notifications_toolbar_menu();
     268    }
    182269}
    183270add_action( 'admin_bar_menu', 'bp_members_admin_bar_notifications_menu', 90 );
  • 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 );
  • trunk/src/js/admin/bp-core/dismissible-admin-notices.js

    r13463 r13614  
    5656                    if ( success ) {
    5757                        noticeContainer.remove();
     58
     59                        if ( 0 === document.querySelectorAll( '.bp-notice-container' ).length ) {
     60                            document.querySelector( '#no-admin-notifications' ).classList.remove( 'hide' );
     61                        }
    5862                    } else {
    5963                        noticeLink.classList.remove( 'loading' );
Note: See TracChangeset for help on using the changeset viewer.