Skip to:
Content

BuddyPress.org

Ticket #8448: 8448.3-tools-tabs.patch

File 8448.3-tools-tabs.patch, 11.6 KB (added by imath, 4 years ago)
  • src/bp-core/admin/bp-core-admin-functions.php

    diff --git src/bp-core/admin/bp-core-admin-functions.php src/bp-core/admin/bp-core-admin-functions.php
    index 26f549d8f..456fdcdca 100644
    function bp_core_modify_admin_menu_highlight() { 
    8181        }
    8282
    8383        // Network Admin > Tools.
    84         if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools', 'bp-optouts' ) ) ) {
     84        if ( in_array( $plugin_page, array( 'bp-tools', 'available-tools' ) ) ) {
    8585                $submenu_file = $plugin_page;
    8686        }
     87
     88        // Keep the BuddyPress tools menu highlighted.
     89        if ( 'bp-optouts' === $plugin_page ) {
     90                $submenu_file = 'bp-tools';
     91        }
    8792}
    8893
    8994/**
    function bp_do_activation_redirect() { 
    389394 * Output the tabs in the admin area.
    390395 *
    391396 * @since 1.5.0
     397 * @since 8.0.0 Adds the `$context` parameter.
    392398 *
    393399 * @param string $active_tab Name of the tab that is active. Optional.
     400 * @param string $context    The context of use for the tabs. Defaults to 'settings'.
     401 *                           Possible values are 'settings' & 'tools'.
    394402 */
    395 function bp_core_admin_tabs( $active_tab = '' ) {
     403function bp_core_admin_tabs( $active_tab = '', $context = 'settings' ) {
    396404        $tabs_html    = '';
    397405        $idle_class   = 'nav-tab';
    398406        $active_class = 'nav-tab nav-tab-active';
    function bp_core_admin_tabs( $active_tab = '' ) { 
    404412         *
    405413         * @param array $value Array of tabs to output to the admin area.
    406414         */
    407         $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab ) );
     415        $tabs = apply_filters( 'bp_core_admin_tabs', bp_core_get_admin_tabs( $active_tab, $context ) );
    408416
    409417        // Loop through tabs and build navigation.
    410418        foreach ( array_values( $tabs ) as $tab_data ) {
    function bp_core_admin_tabs( $active_tab = '' ) { 
    419427         * Fires after the output of tabs for the admin area.
    420428         *
    421429         * @since 1.5.0
     430         * @since 8.0.0 Adds the `$context` parameter.
     431         *
     432         * @param string $context The context of use for the tabs.
    422433         */
    423         do_action( 'bp_admin_tabs' );
     434        do_action( 'bp_admin_tabs', $context );
    424435}
    425436
    426437/**
    427438 * Get the data for the tabs in the admin area.
    428439 *
    429440 * @since 2.2.0
     441 * @since 8.0.0 Adds the `$context` parameter.
    430442 *
    431443 * @param string $active_tab Name of the tab that is active. Optional.
     444 * @param string $context    The context of use for the tabs. Defaults to 'settings'.
     445 *                           Possible values are 'settings' & 'tools'.
    432446 * @return string
    433447 */
    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         );
     448function bp_core_get_admin_tabs( $active_tab = '', $context = 'settings' ) {
     449        $tabs = array();
     450
     451        if ( 'settings' === $context ) {
     452                $tabs = array(
     453                        '0' => array(
     454                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-components' ), 'admin.php' ) ),
     455                                'name' => __( 'Components', 'buddypress' ),
     456                        ),
     457                        '2' => array(
     458                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-settings' ), 'admin.php' ) ),
     459                                'name' => __( 'Options', 'buddypress' ),
     460                        ),
     461                        '1' => array(
     462                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-page-settings' ), 'admin.php' ) ),
     463                                'name' => __( 'Pages', 'buddypress' ),
     464                        ),
     465                        '3' => array(
     466                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-credits' ), 'admin.php' ) ),
     467                                'name' => __( 'Credits', 'buddypress' ),
     468                        ),
     469                );
     470        } elseif ( 'tools' === $context ) {
     471                $tools_page = 'tools.php';
     472                if ( bp_core_do_network_admin() ) {
     473                        $tools_page = 'admin.php';
     474                }
     475
     476                $tabs = array(
     477                        '0' => array(
     478                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-tools' ), $tools_page ) ),
     479                                'name' => __( 'Repair', 'buddypress' ),
     480                        ),
     481                        '1' => array(
     482                                'href' => bp_get_admin_url( add_query_arg( array( 'page' => 'bp-optouts' ), $tools_page ) ),
     483                                'name' => __( 'Manage Opt-outs', 'buddypress' ),
     484                        ),
     485                );
     486        }
    453487
    454488        /**
    455489         * Filters the tab data used in our wp-admin screens.
    456490         *
    457491         * @since 2.2.0
     492         * @since 8.0.0 Adds the `$context` parameter.
    458493         *
    459          * @param array $tabs Tab data.
     494         * @param array  $tabs    Tab data.
     495         * @param string $context The context of use for the tabs.
    460496         */
    461         return apply_filters( 'bp_core_get_admin_tabs', $tabs );
     497        return apply_filters( 'bp_core_get_admin_tabs', $tabs, $context );
    462498}
    463499
    464500/** Help **********************************************************************/
  • src/bp-core/admin/bp-core-admin-optouts.php

    diff --git src/bp-core/admin/bp-core-admin-optouts.php src/bp-core/admin/bp-core-admin-optouts.php
    index 5df6047d0..f446669b1 100644
    function bp_core_optouts_admin_index() { 
    315315        ?>
    316316
    317317        <div class="wrap">
    318                 <h1 class="wp-heading-inline"><?php _e( 'Nonmember Opt-outs', 'buddypress' ); ?></h1>
     318                <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
     319                <hr class="wp-header-end">
     320
     321                <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Opt-outs', 'buddypress' ), 'tools' ); ?></h2>
    319322
    320323                <?php
    321324                if ( $usersearch ) {
    322325                        $num_results = (int) $bp_optouts_list_table->total_items;
    323                         printf( '<span class="subtitle">' . esc_html( _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' ) ) . '</span>', esc_html( $usersearch ) );
     326                        printf( '<p><span class="subtitle">' . esc_html( _n( 'Opt-out with an email address matching &#8220;%s&#8221;', 'Opt-outs with an email address matching &#8220;%s&#8221;', $num_results, 'buddypress' ) ) . '</span></p>', esc_html( $usersearch ) );
    324327                }
    325328                ?>
    326                 <p class="description"><?php esc_html_e( 'This table shows opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to receive no further communications.', 'buddypress' ); ?></p>
    327 
    328                 <hr class="wp-header-end">
     329                <p><?php esc_html_e( 'This table shows opt-out requests from people who are not members of this site, but have been contacted via communication from this site, and wish to receive no further communications.', 'buddypress' ); ?></p>
    329330
    330331                <?php // Display each opt-out on its own row. ?>
    331332                <?php $bp_optouts_list_table->views(); ?>
    function bp_core_optouts_admin_manage( $action = '' ) { 
    379380        // Check optout IDs and set up strings.
    380381        switch ( $action ) {
    381382                case 'delete' :
    382                         $header_text = __( 'Delete optouts', 'buddypress' );
    383383                        if ( 1 == count( $optouts ) ) {
    384384                                $helper_text = __( 'You are about to delete the following opt-out request:', 'buddypress' );
    385385                        } else {
    function bp_core_optouts_admin_manage( $action = '' ) { 
    415415        ?>
    416416
    417417        <div class="wrap">
    418                 <h1 class="wp-heading-inline"><?php echo esc_html( $header_text ); ?></h1>
     418                <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress tools', 'buddypress' ); ?></h1>
    419419                <hr class="wp-header-end">
    420420
     421                <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Manage Opt-outs', 'buddypress' ), 'tools' ); ?></h2>
     422
    421423                <p><?php echo esc_html( $helper_text ); ?></p>
    422424
    423425                <ol class="bp-optouts-list">
  • src/bp-core/admin/bp-core-admin-tools.php

    diff --git src/bp-core/admin/bp-core-admin-tools.php src/bp-core/admin/bp-core-admin-tools.php
    index 0d49c0d6f..047e11b37 100644
    function bp_core_admin_tools() { 
    2222                <h1 class="wp-heading-inline"><?php esc_html_e( 'BuddyPress Tools', 'buddypress' ) ?></h1>
    2323                <hr class="wp-header-end">
    2424
     25                <h2 class="nav-tab-wrapper"><?php bp_core_admin_tabs( __( 'Repair', 'buddypress' ), 'tools' ); ?></h2>
     26
    2527                <p><?php esc_html_e( 'BuddyPress keeps track of various relationships between members, groups, and activity items.', 'buddypress' ); ?></p>
    2628                <p><?php esc_html_e( 'Occasionally these relationships become out of sync, most often after an import, update, or migration.', 'buddypress' ); ?></p>
    2729                <p><?php esc_html_e( 'Use the tools below to manually recalculate these relationships.', 'buddypress' ); ?>
    function bp_core_admin_available_tools_intro() { 
    541543        $page = bp_core_do_network_admin() ? 'admin.php' : 'tools.php' ;
    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                        <dt><?php esc_html_e( 'Manage Opt-outs', 'buddypress' ) ?></dt>
     562                        <dd>
     563                                <?php esc_html_e( 'Some introduction text to replace with something more meaningful.', 'buddypress' ); ?>
     564                                <?php
     565                                $url = add_query_arg( 'page', 'bp-optouts', bp_get_admin_url( $page ) );
     566                                printf(
     567                                        /* translators: %s: the link to the BuddyPress Nonmember Opt-outs */
     568                                        esc_html_x( 'Checkout %s to eventually do something great!', 'buddypress opt-outs intro', 'buddypress' ),
     569                                        '<a href="' . esc_url( $url ) . '">' . esc_html__( 'Nonmember Opt-outs', 'buddypress' ) . '</a>'
     570                                );
     571                                ?>
     572                        </dd>
     573                </dl>
    556574        </div>
    557575        <?php
    558576}
  • src/bp-core/admin/css/common.css

    diff --git src/bp-core/admin/css/common.css src/bp-core/admin/css/common.css
    index c0af4884c..631305fba 100644
    TABLE OF CONTENTS: 
    306306        content: "";
    307307}
    308308
     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;
     318}
     319
    309320/*
    310321 * 2.4 Tooltips
    311322 */
  • src/bp-core/classes/class-bp-admin.php

    diff --git src/bp-core/classes/class-bp-admin.php src/bp-core/classes/class-bp-admin.php
    index 2edd975c5..f71113e67 100644
    class BP_Admin { 
    544544                // About and Credits pages.
    545545                remove_submenu_page( 'index.php', 'bp-about'   );
    546546                remove_submenu_page( 'index.php', 'bp-credits' );
     547
     548                // Nonmembers Opt-outs page.
     549                remove_submenu_page( 'tools.php', 'bp-optouts' );
    547550        }
    548551
    549552        /**