Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/19/2023 11:34:45 PM (16 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

Props dcavins

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

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.