Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/19/2023 11:52:53 PM (20 months 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
  • Bump Raw DB version to 13408

Props dcavins

Fixes #9007 (Branch 11.0)

File:
1 edited

Legend:

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

    r13550 r13615  
    512512            'name' => __( 'Pages', 'buddypress' ),
    513513        ),
    514         '3' => array(
     514        '4' => array(
    515515            'id'   => 'bp-credits',
    516516            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
     
    518518        ),
    519519    );
     520
     521    if ( bp_core_get_unread_admin_notifications() || ( isset( $_GET['page'] ) && 'bp-admin-notifications' === $_GET['page'] ) ) {
     522        $settings_tabs['3'] = array(
     523            'id'   => 'bp-admin-notifications',
     524            'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-admin-notifications' ), 'admin.php' ) ),
     525            'name' => __( 'Notifications', 'buddypress' ),
     526        );
     527    }
    520528
    521529    if ( ! $apply_filters ) {
     
    14131421 */
    14141422function bp_core_admin_notice_dismiss_callback() {
    1415     if ( ! current_user_can( 'install_plugins' ) ) {
     1423    if ( ! current_user_can( 'manage_options' ) ) {
    14161424        wp_send_json_error();
    14171425    }
     
    14401448    }
    14411449
    1442     bp_update_option( "bp-dismissed-notice-{$notice_id}", true );
     1450    bp_core_dismiss_admin_notification( $notice_id );
    14431451
    14441452    wp_send_json_success();
     
    15121520}
    15131521add_action( 'bp_init', 'bp_block_init_category_filter' );
     1522
     1523/**
     1524 * Outputs an Admin Notification.
     1525 *
     1526 * @since 11.4.0
     1527 *
     1528 * @param object $notification An Admin Notification object.
     1529 */
     1530function bp_core_admin_format_notifications( $notification = null ) {
     1531    if ( ! isset( $notification->id ) ) {
     1532        return '';
     1533    }
     1534    ?>
     1535    <div class="bp-welcome-panel bp-notice-container">
     1536        <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>
     1537        <div class="bp-welcome-panel-content">
     1538            <h2><span class="bp-version"><?php echo number_format_i18n( $notification->version, 1 ); ?></span> <?php echo esc_html( $notification->title ); ?></h2>
     1539            <p class="about-description">
     1540                <?php echo wp_kses( $notification->content, array( 'a' => array( 'href' => true ), 'br' => array(), 'strong' => array() ) ); ?>
     1541            </p>
     1542            <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>
     1543        </div>
     1544    </div>
     1545    <?php
     1546}
Note: See TracChangeset for help on using the changeset viewer.