Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/07/2014 11:31:26 PM (10 years ago)
Author:
imath
Message:

Improve the way Group's Manage tabs are generated

In BP_Group_Extension->setup_edit_hooks() method, we are now using the bp_core_new_subnav_item() function to generate the Group's manage tab sub navigation.
The action 'groups_admin_tabs' is no more used. However for back compatibility reasons, we will keep on catching this hook inviting the user using a _doing_it_wrong message to now use the BuddyPress Group Extension API instead.

props boonebgorges

Fixes #5994

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-groups/bp-groups-template.php

    r9057 r9127  
    23002300    }
    23012301
    2302     $current_tab = bp_get_group_current_admin_tab();
    2303 
    2304     if ( bp_is_item_admin() ) : ?>
    2305 
    2306         <li<?php if ( 'edit-details' == $current_tab || empty( $current_tab ) ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/edit-details' ) ?>"><?php _e( 'Details', 'buddypress' ); ?></a></li>
    2307 
    2308     <?php endif; ?>
    2309 
    2310     <?php if ( ! bp_is_item_admin() )
    2311             return false; ?>
    2312 
    2313     <li<?php if ( 'group-settings' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-settings' ) ?>"><?php _e( 'Settings', 'buddypress' ); ?></a></li>
    2314 
    2315     <?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) : ?>
    2316 
    2317         <li<?php if ( 'group-avatar'   == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/group-avatar' ) ?>"><?php _e( 'Photo', 'buddypress' ); ?></a></li>
    2318 
    2319     <?php endif; ?>
    2320 
    2321     <li<?php if ( 'manage-members' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/manage-members' ) ?>"><?php _e( 'Members', 'buddypress' ); ?></a></li>
    2322 
    2323     <?php if ( $groups_template->group->status == 'private' ) : ?>
    2324 
    2325         <li<?php if ( 'membership-requests' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/membership-requests' ) ?>"><?php _e( 'Requests', 'buddypress' ); ?></a></li>
    2326 
    2327     <?php endif; ?>
    2328 
    2329     <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?>
    2330 
    2331     <li<?php if ( 'delete-group' == $current_tab ) : ?> class="current"<?php endif; ?>><a href="<?php echo trailingslashit( bp_get_group_permalink( $group ) . 'admin/delete-group' ) ?>"><?php _e( 'Delete', 'buddypress' ); ?></a></li>
    2332 
    2333 <?php
     2302    $css_id = 'manage-members';
     2303
     2304    if ( 'private' == $group->status ) {
     2305        $css_id = 'membership-requests';
     2306    }
     2307
     2308    add_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 );
     2309
     2310    bp_get_options_nav( $group->slug . '_manage' );
     2311
     2312    remove_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 );
     2313}
     2314
     2315/**
     2316 * BackCompat for plugins/themes directly hooking groups_admin_tabs
     2317 * without using the Groups Extension API
     2318 *
     2319 * @param  string $subnav_output subnav item output
     2320 * @param  string $subnav_item   subnav item params
     2321 * @param  string $selected_item current selected tab
     2322 * @return string HTML output
     2323 */
     2324function bp_group_admin_tabs_backcompat( $subnav_output = '', $subnav_item = '', $selected_item = '' ) {
     2325    if ( ! has_action( 'groups_admin_tabs' ) ) {
     2326        return $subnav_output;
     2327    }
     2328
     2329    $group = groups_get_current_group();
     2330
     2331    ob_start();
     2332
     2333    do_action( 'groups_admin_tabs', $selected_item, $group->slug );
     2334
     2335    $admin_tabs_backcompat = trim( ob_get_contents() );
     2336    ob_end_clean();
     2337
     2338    if ( ! empty( $admin_tabs_backcompat ) ) {
     2339        _doing_it_wrong( "do_action( 'groups_admin_tabs' )", __( 'This action should not be used directly. Please use the BuddyPress Group Extension API to generate Manage tabs.', 'buddypress' ), '2.2.0' );
     2340        $subnav_output .= $admin_tabs_backcompat;
     2341    }
     2342
     2343    return $subnav_output;
    23342344}
    23352345
Note: See TracChangeset for help on using the changeset viewer.