Skip to:
Content

BuddyPress.org

Changeset 12897


Ignore:
Timestamp:
04/20/2021 04:02:22 PM (4 years ago)
Author:
dcavins
Message:

BP Admin Tools: Add tab interface to support additional screens.

Expand the BP Tools screen to use a tabbed interface
so that multiple tools screens can be grouped in a
single Tools > BuddyPress menu item.

Props imath.

See #8448.

Location:
trunk/src/bp-core/admin
Files:
3 edited

Legend:

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

    r12886 r12897  
    390390 *
    391391 * @since 1.5.0
     392 * @since 8.0.0 Adds the `$context` parameter.
    392393 *
    393394 * @param string $active_tab Name of the tab that is active. Optional.
    394  */
    395 function bp_core_admin_tabs( $active_tab = '' ) {
     395 * @param string $context    The context of use for the tabs. Defaults to 'settings'.
     396 *                           Possible values are 'settings' & 'tools'.
     397 */
     398function bp_core_admin_tabs( $active_tab = '', $context = 'settings' ) {
    396399    $tabs_html    = '';
    397400    $idle_class   = 'nav-tab';
     
    405408     * @param array $value Array of tabs to output to the admin area.
    406409     */
    407     $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
     410    $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab, $context ) );
    408411
    409412    // Loop through tabs and build navigation.
     
    420423     *
    421424     * @since 1.5.0
     425     * @since 8.0.0 Adds the `$context` parameter.
     426     *
     427     * @param string $context The context of use for the tabs.
    422428     */
    423     do_action( 'bp_admin_tabs' );
     429    do_action( 'bp_admin_tabs', $context );
    424430}
    425431
     
    428434 *
    429435 * @since 2.2.0
     436 * @since 8.0.0 Adds the `$context` parameter.
    430437 *
    431438 * @param string $active_tab Name of the tab that is active. Optional.
     439 * @param string $context    The context of use for the tabs. Defaults to 'settings'.
     440 *                           Possible values are 'settings' & 'tools'.
    432441 * @return string
    433442 */
    434 function bp_core_get_admin_tabs( $active_tab = '' ) {
    435     $tabs = array(
    436         '0' => array(
    437             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
    438             'name' => __( 'Components', 'buddypress' ),
    439         ),
    440         '2' => array(
    441             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
    442             'name' => __( 'Options', 'buddypress' ),
    443         ),
    444         '1' => array(
    445             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),
    446             'name' => __( 'Pages', 'buddypress' ),
    447         ),
    448         '3' => array(
    449             'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
    450             'name' => __( 'Credits', 'buddypress' ),
    451         ),
    452     );
     443function bp_core_get_admin_tabs( $active_tab = '', $context = 'settings' ) {
     444    $tabs = array();
     445
     446    if ( 'settings' === $context ) {
     447        $tabs = array(
     448            '0' => array(
     449                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
     450                'name' => __( 'Components', 'buddypress' ),
     451            ),
     452            '2' => array(
     453                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
     454                'name' => __( 'Options', 'buddypress' ),
     455            ),
     456            '1' => array(
     457                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),
     458                'name' => __( 'Pages', 'buddypress' ),
     459            ),
     460            '3' => array(
     461                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
     462                'name' => __( 'Credits', 'buddypress' ),
     463            ),
     464        );
     465    } elseif ( 'tools' === $context ) {
     466        $tools_page = 'tools.php';
     467        if ( bp_core_do_network_admin() ) {
     468            $tools_page = 'admin.php';
     469        }
     470
     471        $tabs = array(
     472            '0' => array(
     473                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-tools' ), $tools_page ) ),
     474                'name' => __( 'Repair', 'buddypress' ),
     475            ),
     476        );
     477    }
    453478
    454479    /**
     
    456481     *
    457482     * @since 2.2.0
     483     * @since 8.0.0 Adds the `$context` parameter.
    458484     *
    459      * @param array $tabs Tab data.
     485     * @param array  $tabs    Tab data.
     486     * @param string $context The context of use for the tabs.
    460487     */
    461     return apply_filters( 'bp_core_get_admin_tabs', $tabs );
     488    return apply_filters( 'bp_core_get_admin_tabs', $tabs, $context );
    462489}
    463490
  • trunk/src/bp-core/admin/bp-core-admin-tools.php

    r12826 r12897  
    2222        <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h1>
    2323        <hr class="wp-header-end">
     24
     25        <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Repair', 'buddypress' ), 'tools' ); ?></h2>
    2426
    2527        <p><?php esc_html_e( 'BuddyPress keeps track of various relationships between members, groups, and activity items.', 'buddypress' ); ?></p>
     
    542544    $url  = add_query_arg( $query_arg, bp_get_admin_url( $page ) );
    543545    ?>
    544     <div class="card tool-box">
     546    <div class="card tool-box bp-tools">
    545547        <h2><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h2>
    546         <p>
    547             <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
    548             <?php
    549             printf(
    550                 /* translators: %s: the link to the BuddyPress repair tools */
    551                 esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ),
    552                 '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Tools', 'buddypress' ) . '</a>'
    553             );
    554             ?>
    555         </p>
     548
     549        <dl>
     550            <dt><?php esc_html_e( 'Repair Tools', 'buddypress' ) ?></dt>
     551            <dd>
     552                <?php esc_html_e( 'BuddyPress keeps track of various relationships between users, groups, and activity items. Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?>
     553                <?php
     554                printf(
     555                    /* translators: %s: the link to the BuddyPress repair tools */
     556                    esc_html_x( 'Use the %s to repair these relationships.', 'buddypress tools intro', 'buddypress' ),
     557                    '<a href="' . esc_url( $url ) . '">' . esc_html__( 'BuddyPress Repair Tools', 'buddypress' ) . '</a>'
     558                );
     559                ?>
     560            </dd>
     561        </dl>
    556562    </div>
    557563    <?php
  • trunk/src/bp-core/admin/css/common.css

    r12739 r12897  
    305305#adminmenu .toplevel_page_network-tools div.wp-menu-image:before {
    306306    content: "";
     307}
     308
     309body.tools-php .bp-tools dt {
     310    font-size: 1.1em;
     311    color: #646970;
     312    font-weight: 600;
     313    margin: 1em 0 0.5em 0;
     314}
     315
     316body.tools-php .bp-tools dd {
     317    margin: 0;
    307318}
    308319
Note: See TracChangeset for help on using the changeset viewer.