Ticket #6002: 6002.02.patch
File 6002.02.patch, 9.4 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-buddybar.php
diff --git src/bp-core/bp-core-buddybar.php src/bp-core/bp-core-buddybar.php index 8a67505..ba30b0c 100644
function bp_core_new_subnav_item( $args = '' ) { 260 260 global $bp; 261 261 262 262 $r = wp_parse_args( $args, array( 263 'name' => false, // Display name for the nav item 264 'slug' => false, // URL slug for the nav item 265 'parent_slug' => false, // URL slug of the parent nav item 266 'parent_url' => false, // URL of the parent item 267 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item 268 'user_has_access' => true, // Can the logged in user see this nav item? 269 'no_access_url' => '', 270 'site_admin_only' => false, // Can only site admins see this nav item? 271 'position' => 90, // Index of where this nav item should be positioned 272 'screen_function' => false, // The name of the function to run when clicked 273 'link' => '' // The link for the subnav item; optional, not usually required. 263 'name' => false, // Display name for the nav item 264 'slug' => false, // URL slug for the nav item 265 'parent_slug' => false, // URL slug of the parent nav item 266 'parent_url' => false, // URL of the parent item 267 'item_css_id' => false, // The CSS ID to apply to the HTML of the nav item 268 'user_has_access' => true, // Can the logged in user see this nav item? 269 'no_access_url' => '', 270 'site_admin_only' => false, // Can only site admins see this nav item? 271 'position' => 90, // Index of where this nav item should be positioned 272 'screen_function' => false, // The name of the function to run when clicked 273 'link' => '', // The link for the subnav item; optional, not usually required. 274 'show_in_admin_bar' => false, // Show the Manage link in the current group's "Edit" Admin Bar menu 274 275 ) ); 275 276 276 277 extract( $r, EXTR_SKIP ); … … function bp_core_new_subnav_item( $args = '' ) { 297 298 $item_css_id = $slug; 298 299 299 300 $subnav_item = array( 300 'name' => $name, 301 'link' => trailingslashit( $link ), 302 'slug' => $slug, 303 'css_id' => $item_css_id, 304 'position' => $position, 305 'user_has_access' => $user_has_access, 306 'no_access_url' => $no_access_url, 307 'screen_function' => &$screen_function 301 'name' => $name, 302 'link' => trailingslashit( $link ), 303 'slug' => $slug, 304 'css_id' => $item_css_id, 305 'position' => $position, 306 'user_has_access' => $user_has_access, 307 'no_access_url' => $no_access_url, 308 'screen_function' => &$screen_function, 309 'show_in_admin_bar' => (bool) $r['show_in_admin_bar'], 308 310 ); 311 309 312 $bp->bp_options_nav[$parent_slug][$slug] = $subnav_item; 310 313 311 314 /** -
src/bp-groups/bp-groups-adminbar.php
diff --git src/bp-groups/bp-groups-adminbar.php src/bp-groups/bp-groups-adminbar.php index 33e7679..4d1e059 100644
if ( !defined( 'ABSPATH' ) ) exit; 23 23 * access to group admin options. 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 37 40 $bp->group_admin_menu_id = 'group-admin'; … … function bp_groups_group_admin_menu() { 43 46 'href' => bp_get_group_permalink( $bp->groups->current_group ) 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 ) ); 53 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 ) ); 49 // Index of the Manage tabs parent slug 50 $nav_index = $bp->groups->current_group->slug . '_manage'; 61 51 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 ) ); 80 } 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'] ); 81 68 82 // Group Admin > Manage members 83 $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 ) ); 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 } 89 73 90 // Group Admin > Membership Requests 91 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 ) ); 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 } 98 81 } 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 ); 109 84 -
src/bp-groups/bp-groups-classes.php
diff --git src/bp-groups/bp-groups-classes.php src/bp-groups/bp-groups-classes.php index f84e2f7..5138b7f 100644
class BP_Group_Extension { 3655 3655 $current_group = groups_get_current_group(); 3656 3656 $admin_link = trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ); 3657 3657 3658 // Add the tab to the manage navigation 3659 bp_core_new_subnav_item( array( 3658 $subnav_args = array( 3660 3659 'name' => $screen['name'], 3661 3660 'slug' => $screen['slug'], 3662 3661 'parent_slug' => $current_group->slug . '_manage', … … class BP_Group_Extension { 3664 3663 'user_has_access' => bp_is_item_admin(), 3665 3664 'position' => $position, 3666 3665 'screen_function' => 'groups_screen_group_admin', 3667 ) ); 3666 ); 3667 3668 // Should we add a menu to the Group's WP Admin Bar 3669 if ( ! empty( $screen['show_in_admin_bar'] ) ) { 3670 $subnav_args['show_in_admin_bar'] = true; 3671 } 3672 3673 // Add the tab to the manage navigation 3674 bp_core_new_subnav_item( $subnav_args ); 3668 3675 3669 3676 // Catch the edit screen and forward it to the plugin template 3670 3677 if ( bp_is_groups_component() && bp_is_current_action( 'admin' ) && bp_is_action_variable( $screen['slug'], 0 ) ) { -
src/bp-groups/bp-groups-loader.php
diff --git src/bp-groups/bp-groups-loader.php src/bp-groups/bp-groups-loader.php index d3ccbcf..d12712f 100644
class BP_Groups_Component extends BP_Component { 507 507 'item_css_id' => 'admin', 508 508 'no_access_url' => $group_link, 509 509 ); 510 }511 510 512 // If viewing an admin page, create the group admin subnav items513 if ( bp_is_group_admin_page() ) {514 511 $admin_link = trailingslashit( $group_link . 'admin' ); 515 512 516 513 // Common params to all nav items 517 514 $default_params = array( 518 'parent_url' => $admin_link, 519 'parent_slug' => $this->current_group->slug . '_manage', 520 'screen_function' => 'groups_screen_group_admin', 521 'user_has_access' => bp_is_item_admin(), 515 'parent_url' => $admin_link, 516 'parent_slug' => $this->current_group->slug . '_manage', 517 'screen_function' => 'groups_screen_group_admin', 518 'user_has_access' => bp_is_item_admin(), 519 'show_in_admin_bar' => true, 522 520 ); 523 521 524 522 $sub_nav[] = array_merge( array(