Changeset 9131 for trunk/src/bp-groups/bp-groups-adminbar.php
- Timestamp:
- 11/10/2014 07:13:04 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/bp-groups-adminbar.php
r9026 r9131 24 24 */ 25 25 function bp_groups_group_admin_menu() { 26 global $wp_admin_bar, $bp; 26 global $wp_admin_bar; 27 $bp = buddypress(); 27 28 28 29 // Only show if viewing a group 29 if ( ! bp_is_group() )30 if ( ! bp_is_group() || bp_is_group_create() ) { 30 31 return false; 32 } 31 33 32 34 // Only show this menu to group admins and super admins 33 if ( ! bp_current_user_can( 'bp_moderate' ) && !bp_group_is_admin() )35 if ( ! bp_current_user_can( 'bp_moderate' ) && ! bp_group_is_admin() ) { 34 36 return false; 37 } 35 38 36 39 // Unique ID for the 'Edit Group' menu … … 44 47 ) ); 45 48 46 // Group Admin > Edit details 47 $wp_admin_bar->add_menu( array( 48 'parent' => $bp->group_admin_menu_id, 49 'id' => 'edit-details', 50 'title' => __( 'Edit Details', 'buddypress' ), 51 'href' => bp_get_groups_action_link( 'admin/edit-details' ) 52 ) ); 49 // Index of the Manage tabs parent slug 50 $nav_index = $bp->groups->current_group->slug . '_manage'; 53 51 54 // Group Admin > Group settings 55 $wp_admin_bar->add_menu( array( 56 'parent' => $bp->group_admin_menu_id, 57 'id' => 'group-settings', 58 'title' => __( 'Edit Settings', 'buddypress' ), 59 'href' => bp_get_groups_action_link( 'admin/group-settings' ) 60 ) ); 61 62 // Group Admin > Group avatar 63 if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && $bp->avatar->show_avatars ) { 64 $wp_admin_bar->add_menu( array( 65 'parent' => $bp->group_admin_menu_id, 66 'id' => 'group-avatar', 67 'title' => __( 'Edit Profile Photo', 'buddypress' ), 68 'href' => bp_get_groups_action_link( 'admin/group-avatar' ) 69 ) ); 52 // Check if current group has Manage tabs 53 if ( empty( $bp->bp_options_nav[ $nav_index ] ) ) { 54 return; 70 55 } 71 56 72 // Group Admin > Manage invitations 73 if ( bp_is_active( 'friends' ) ) { 74 $wp_admin_bar->add_menu( array( 75 'parent' => $bp->group_admin_menu_id, 76 'id' => 'manage-invitations', 77 'title' => __( 'Manage Invitations', 'buddypress' ), 78 'href' => bp_get_groups_action_link( 'send-invites' ) 79 ) ); 57 // Build the Group Admin menus 58 foreach ( $bp->bp_options_nav[ $nav_index ] as $menu ) { 59 /** 60 * Should we add the current manage link in the Group's "Edit" Admin Bar menu ? 61 * 62 * All core items will be added, plugins can use a new parameter in the BP Group Extension API 63 * to also add the link to the "edit screen" of their group component. To do so, set the 64 * the 'show_in_admin_bar' argument of your edit screen to true 65 */ 66 if ( $menu['show_in_admin_bar'] ) { 67 $title = sprintf( _x( 'Edit Group %s', 'Group WP Admin Bar manage links', 'buddypress' ), $menu['name'] ); 68 69 // Title is specific for delete 70 if ( 'delete-group' == $menu['slug'] ) { 71 $title = sprintf( _x( '%s Group', 'Group WP Admin Bar delete link', 'buddypress' ), $menu['name'] ); 72 } 73 74 $wp_admin_bar->add_menu( array( 75 'parent' => $bp->group_admin_menu_id, 76 'id' => $menu['slug'], 77 'title' => $title, 78 'href' => bp_get_groups_action_link( 'admin/' . $menu['slug'] ) 79 ) ); 80 } 80 81 } 81 82 // Group Admin > Manage members83 $wp_admin_bar->add_menu( array(84 'parent' => $bp->group_admin_menu_id,85 'id' => 'manage-members',86 'title' => __( 'Manage Members', 'buddypress' ),87 'href' => bp_get_groups_action_link( 'admin/manage-members' )88 ) );89 90 // Group Admin > Membership Requests91 if ( bp_get_group_status( $bp->groups->current_group ) == 'private' ) {92 $wp_admin_bar->add_menu( array(93 'parent' => $bp->group_admin_menu_id,94 'id' => 'membership-requests',95 'title' => __( 'Membership Requests', 'buddypress' ),96 'href' => bp_get_groups_action_link( 'admin/membership-requests' )97 ) );98 }99 100 // Delete Group101 $wp_admin_bar->add_menu( array(102 'parent' => $bp->group_admin_menu_id,103 'id' => 'delete-group',104 'title' => __( 'Delete Group', 'buddypress' ),105 'href' => bp_get_groups_action_link( 'admin/delete-group' )106 ) );107 82 } 108 83 add_action( 'admin_bar_menu', 'bp_groups_group_admin_menu', 99 );
Note: See TracChangeset
for help on using the changeset viewer.