Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/06/2021 08:40:08 AM (4 years ago)
Author:
imath
Message:

Use WordPress "site-health" style tabs for BP Admin tabs

The BuddyPress settings and tools screens admin tabs are now using the "site-health" style. As aside from the "site-health" screens, the Privacy screens are also using this tabs' style, we think using this style will improve the way BuddyPress Admin screens integrate inside the WordPress Administration.

We've put a back compatibility process for plugins extending the BuddyPress settings or/and tools screens adding their custom tabs, so that they are automatically converted into these new tabs. Plugin developers are encouraged to progressively update the way they are adding these tabs.

  • bp_core_admin_tabbed_screen_header() has been introduced to generate the BuddyPress Admin screens headers using tabs.
  • bp_core_get_admin_settings_tabs() has been introduced to return the settings tabs, using the 'bp_core_get_admin_settings_tabs' filter, plugin developers can add their custom tab to the BuddyPress settings screens.
  • bp_core_get_admin_settings_tabs() has been introduced to return the settings tabs. Using the 'bp_core_get_admin_settings_tabs' filter, plugin developers can add their custom tabs to the BuddyPress settings screens.
  • bp_core_get_admin_tools_tabs() has been introduced to return the tools tabs. Using the 'bp_core_get_admin_tools_tabs' filter, plugin developers can add their custom tabs to the BuddyPress tools screens.
  • To make sure BuddyPress generate the inline style to custom tabs, plugin developers need to hook the 'bp_admin_submenu_pages' action which passes by reference an associative array keyed according to the screens to style (settings or tools) and containing the plugin page hookname of their custom screens.

Props oztaser

Fixes #8588

File:
1 edited

Legend:

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

    r13131 r13137  
    150150            $this->capability = 'manage_network_users';
    151151        }
     152
     153        /*
     154         * For consistency with non-Multisite, we add a Tools menu in
     155         * the Network Admin as a home for our Tools panel.
     156         */
     157        if ( is_multisite() && bp_core_do_network_admin() ) {
     158            $this->tools_parent = 'network-tools';
     159        } else {
     160            $this->tools_parent = 'tools.php';
     161        }
    152162    }
    153163
     
    255265            add_filter( 'pre_get_users', array( $this, 'users_table_filter_by_type' ) );
    256266        }
     267
     268        // Add the Members invitations submenu page to the tools submenu pages.
     269        add_action( 'bp_admin_submenu_pages', array( $this, 'set_submenu_page' ), 10, 1 );
    257270    }
    258271
     
    512525        }
    513526
    514         // For consistency with non-Multisite, we add a Tools menu in
    515         // the Network Admin as a home for our Tools panel.
    516         if ( is_multisite() && bp_core_do_network_admin() ) {
    517             $tools_parent = 'network-tools';
    518         } else {
    519             $tools_parent = 'tools.php';
    520         }
    521 
    522527        $hooks['members_invitations'] = $this->members_invites_page = add_submenu_page(
    523             $tools_parent,
     528            $this->tools_parent,
    524529            __( 'Manage Invitations',  'buddypress' ),
    525530            __( 'Manage Invitations',  'buddypress' ),
     
    571576        // Highlight the BuddyPress tools submenu when managing invitations.
    572577        add_action( "admin_head-{$this->members_invites_page}", 'bp_core_modify_admin_menu_highlight' );
     578    }
     579
     580    /**
     581     * Include the Members Invitations tab to the Admin tabs needing specific inline styles.
     582     *
     583     * @since 10.0.0
     584     *
     585     * @param array $submenu_pages The BP_Admin submenu pages passed by reference.
     586     */
     587    public function set_submenu_page( &$submenu_pages ) {
     588        if ( isset( $submenu_pages['tools'] ) ) {
     589            $submenu_pages['tools']['bp-members-invitations'] = get_plugin_page_hookname( 'bp-members-invitations', $this->tools_parent );
     590        }
    573591    }
    574592
     
    30043022        );
    30053023
     3024        bp_core_admin_tabbed_screen_header( __( 'BuddyPress tools', 'buddypress' ), __( 'Manage Invitations', 'buddypress' ), 'tools' );
    30063025        ?>
    30073026
    3008         <div class="wrap">
    3009             <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
    3010             <hr class="wp-header-end">
    3011 
    3012             <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Invitations', 'buddypress' ), 'tools' ); ?></h2>
    3013 
     3027        <div class="buddypress-body">
    30143028            <?php
    30153029            if ( $usersearch ) {
     
    31253139        );
    31263140
     3141        bp_core_admin_tabbed_screen_header( __( 'BuddyPress tools', 'buddypress' ), __( 'Manage Invitations', 'buddypress' ), 'tools' );
    31273142        ?>
    31283143
    3129         <div class="wrap">
    3130             <h1 class="wp-heading-inline"><?php echo esc_html( $header_text ); ?></h1>
    3131             <hr class="wp-header-end">
     3144        <div class="buddypress-body">
     3145            <h2><?php echo esc_html( $header_text ); ?></h2>
    31323146
    31333147            <p><?php echo esc_html( $helper_text ); ?></p>
Note: See TracChangeset for help on using the changeset viewer.