Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
10/19/2023 11:52:53 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
  • 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/classes/class-bp-admin.php

    r13613 r13615  
    298298                $this->submenu_pages['settings']['bp-settings'] = $bp_settings_page;
    299299                $hooks[]                                        = $bp_settings_page;
     300
     301                // Admin notifications.
     302                $bp_admin_notifications = add_submenu_page(
     303                        $this->settings_page,
     304                        __( 'BuddyPress Admin Notifications', 'buddypress' ),
     305                        __( 'BuddyPress Admin Notifications', 'buddypress' ),
     306                        $this->capability,
     307                        'bp-admin-notifications',
     308                        array( $this, 'admin_notifications' )
     309                );
     310
     311                $this->submenu_pages['settings']['bp-admin-notifications'] = $bp_admin_notifications;
     312                $hooks[]                                                   = $bp_admin_notifications;
    300313
    301314                // Credits.
     
    626639
    627640                // Settings pages.
    628                 remove_submenu_page( $this->settings_page, 'bp-page-settings' );
    629                 remove_submenu_page( $this->settings_page, 'bp-settings'      );
    630                 remove_submenu_page( $this->settings_page, 'bp-credits'       );
     641                remove_submenu_page( $this->settings_page, 'bp-page-settings'       );
     642                remove_submenu_page( $this->settings_page, 'bp-settings'            );
     643                remove_submenu_page( $this->settings_page, 'bp-credits'             );
     644                remove_submenu_page( $this->settings_page, 'bp-admin-notifications' );
    631645
    632646                // Network Admin Tools.
     
    15411555         */
    15421556        public function display_addons_table() {
    1543                 $notice_id = 'bp100-welcome-addons';
    1544                 $dismissed = bp_get_option( "bp-dismissed-notice-{$notice_id}", false );
    1545 
    1546                 if ( ! $dismissed ) {
    1547                         // Enqueue the Script to Ajax Dismiss an Admin notice.
    1548                         wp_enqueue_script( 'bp-dismissible-admin-notices' );
    1549 
    1550                         ?>
    1551                         <div class="bp-welcome-panel bp-notice-container">
    1552                                 <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>
    1553                                 <div class="bp-welcome-panel-content">
    1554                                         <h2><span class="bp-badge"></span> <?php esc_html_e( 'Hello BuddyPress Add-ons!', 'buddypress' ); ?></h2>
    1555                                         <p class="about-description">
    1556                                                 <?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' ); ?>
    1557                                                 <?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' ); ?>
    1558                                         </p>
    1559                                 </div>
    1560                         </div>
    1561                         <?php
    1562                 }
    1563 
    15641557                if ( isset( $_GET['show'] ) && 'bp-classic' === $_GET['show'] ) {
    15651558                        wp_add_inline_script(
     
    15771570                }
    15781571
     1572                if ( isset( $_GET['n'] ) && $_GET['n'] ) {
     1573                        $notification_id = sanitize_text_field( wp_unslash( $_GET['n'] ) );
     1574                        bp_core_dismiss_admin_notification( $notification_id );
     1575                }
     1576
    15791577                // Display the "buddypress" favorites.
    15801578                display_plugins_table();
    15811579        }
     1580
     1581        /**
     1582         * Display the Admin Notifications screen.
     1583         *
     1584         * @since 11.4.0
     1585         */
     1586        public function admin_notifications() {
     1587                bp_core_admin_tabbed_screen_header( __( 'BuddyPress Settings', 'buddypress' ), __( 'Notifications', 'buddypress' ) );
     1588                $notifications = bp_core_get_admin_notifications();
     1589                $class         = '';
     1590
     1591                if ( $notifications ) {
     1592                        wp_enqueue_script( 'bp-dismissible-admin-notices' );
     1593                        $notifications = array_reverse( bp_sort_by_key( $notifications, 'version', 'num' ) );
     1594                        $class         = 'hide';
     1595                }
     1596                ?>
     1597                <div class="buddypress-body admin-notifications">
     1598                        <table id="no-admin-notifications" class="form-table <?php echo sanitize_html_class( $class ); ?>" role="presentation">
     1599                                <tbody>
     1600                                        <tr><td><?php esc_html_e( 'No new Admin Notfications', 'buddypress' ); ?></td><tr>
     1601                                </tbody>
     1602                        </table>
     1603
     1604                        <?php if ( $notifications ) : foreach ( $notifications as $notification ) : ?>
     1605                                <?php bp_core_admin_format_notifications( $notification ); ?>
     1606                        <?php endforeach; endif; ?>
     1607                </div>
     1608                <?php
     1609        }
    15821610}
    15831611endif; // End class_exists check.
Note: See TracChangeset for help on using the changeset viewer.