Skip to:
Content

BuddyPress.org

Changeset 13139


Ignore:
Timestamp:
11/07/2021 12:46:35 PM (2 years ago)
Author:
imath
Message:

When settings are updated, display a notice in Network Admin

Introduces the BP_Admin::admin_load() method to check if settings were updated from the components, options or pages screens. This method is only called inside the Network Admin, when BuddyPress is network activated.

Fixes #8599

File:
1 edited

Legend:

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

    r13138 r13139  
    389389        do_action_ref_array( 'bp_admin_submenu_pages', array( &$this->submenu_pages ) );
    390390
    391         foreach( $this->submenu_pages as $subpage_hooks ) {
     391        foreach( $this->submenu_pages as $subpage_type => $subpage_hooks ) {
    392392            foreach ( $subpage_hooks as $subpage_hook ) {
    393393                add_action( "admin_print_styles-{$subpage_hook}", array( $this, 'add_inline_styles' ), 20 );
     394
     395                // When BuddyPress is activated on the network, the settings screens need an admin notice when settings have been updated.
     396                if ( is_network_admin() && bp_is_network_activated() && 'settings' === $subpage_type && 'settings_page_bp-credits' !== $subpage_hook ) {
     397                    add_action( "load-{$subpage_hook}", array( $this, 'admin_load' ) );
     398                }
    394399            }
    395400        }
     
    580585            'about'    => '<a href="' . esc_url( bp_get_admin_url( '?hello=buddypress' ) ) . '">' . esc_html_x( 'Hello, BuddyPress!', 'Colloquial alternative to "learn about BuddyPress"', 'buddypress' ) . '</a>'
    581586        ) );
     587    }
     588
     589    /**
     590     * Displays an admin notice to inform settings have been saved.
     591     *
     592     * The notice is only displayed inside the Network Admin when
     593     * BuddyPress is network activated.
     594     *
     595     * @since 10.0.0
     596     */
     597    public function admin_load() {
     598        if ( ! isset( $_GET['updated'] ) ) {
     599            return;
     600        }
     601
     602        bp_core_add_admin_notice( __( 'Settings saved.', 'buddypress' ), 'updated' );
    582603    }
    583604
Note: See TracChangeset for help on using the changeset viewer.