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-classes.php

    r9082 r9127  
    36383638     */
    36393639    protected function setup_edit_hooks() {
     3640        // Bail if not in a group
     3641        if ( ! bp_is_group() ) {
     3642            return;
     3643        }
    36403644
    36413645        // Bail if not an edit screen
     
    36473651
    36483652        $position = isset( $screen['position'] ) ? (int) $screen['position'] : 10;
    3649 
    3650         // Add the tab
    3651         // @todo BP should be using bp_core_new_subnav_item()
    3652         add_action( 'groups_admin_tabs', create_function( '$current, $group_slug',
    3653             '$selected = "";
    3654             if ( "' . esc_attr( $screen['slug'] ) . '" == $current )
    3655                 $selected = " class=\"current\"";
    3656             echo "<li{$selected}><a href=\"' . trailingslashit( bp_get_root_domain() . '/' . bp_get_groups_root_slug() . '/{$group_slug}/admin/' . esc_attr( $screen['slug'] ) ) . '\">' . esc_attr( $screen['name'] ) . '</a></li>";'
    3657         ), $position, 2 );
     3653        $position += 40;
     3654
     3655        $current_group = groups_get_current_group();
     3656        $admin_link = trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' );
     3657
     3658        // Add the tab to the manage navigation
     3659        bp_core_new_subnav_item( array(
     3660            'name'            => $screen['name'],
     3661            'slug'            => $screen['slug'],
     3662            'parent_slug'     => $current_group->slug . '_manage',
     3663            'parent_url'      => trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ),
     3664            'user_has_access' => bp_is_item_admin(),
     3665            'position'        => $position,
     3666            'screen_function' => 'groups_screen_group_admin',
     3667        ) );
    36583668
    36593669        // Catch the edit screen and forward it to the plugin template
Note: See TracChangeset for help on using the changeset viewer.