Ticket #5994: 5994.patch
File 5994.patch, 9.9 KB (added by , 10 years ago) |
---|
-
src/bp-core/bp-core-template.php
diff --git src/bp-core/bp-core-template.php src/bp-core/bp-core-template.php index c945432..5b631d2 100644
if ( !defined( 'ABSPATH' ) ) exit; 26 26 * @uses bp_get_user_nav() Renders the navigation for a profile of a currently 27 27 * viewed user. 28 28 */ 29 function bp_get_options_nav( ) {29 function bp_get_options_nav( $parent_slug = '' ) { 30 30 $bp = buddypress(); 31 31 32 32 // If we are looking at a member profile, then the we can use the current 33 33 // component as an index. Otherwise we need to use the component's root_slug 34 34 $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() ); 35 $selected_item = bp_current_action(); 35 36 36 37 if ( ! bp_is_single_item() ) { 37 38 if ( !isset( $bp->bp_options_nav[$component_index] ) || count( $bp->bp_options_nav[$component_index] ) < 1 ) { … … function bp_get_options_nav() { 40 41 $the_index = $component_index; 41 42 } 42 43 } else { 43 if ( !isset( $bp->bp_options_nav[bp_current_item()] ) || count( $bp->bp_options_nav[bp_current_item()] ) < 1 ) { 44 $current_item = bp_current_item(); 45 46 if ( ! empty( $parent_slug ) ) { 47 $current_item = $parent_slug; 48 $selected_item = bp_action_variable( 0 ); 49 } 50 51 if ( !isset( $bp->bp_options_nav[$current_item] ) || count( $bp->bp_options_nav[$current_item] ) < 1 ) { 44 52 return false; 45 53 } else { 46 $the_index = bp_current_item();54 $the_index = $current_item; 47 55 } 48 56 } 49 57 … … function bp_get_options_nav() { 54 62 } 55 63 56 64 // If the current action or an action variable matches the nav item id, then add a highlight CSS class. 57 if ( $subnav_item['slug'] == bp_current_action()) {65 if ( $subnav_item['slug'] == $selected_item ) { 58 66 $selected = ' class="current selected"'; 59 67 } else { 60 68 $selected = ''; … … function bp_get_options_nav() { 64 72 $list_type = bp_is_group() ? 'groups' : 'personal'; 65 73 66 74 // echo out the final list item 67 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item );75 echo apply_filters( 'bp_get_options_nav_' . $subnav_item['css_id'], '<li id="' . $subnav_item['css_id'] . '-' . $list_type . '-li" ' . $selected . '><a id="' . $subnav_item['css_id'] . '" href="' . $subnav_item['link'] . '">' . $subnav_item['name'] . '</a></li>', $subnav_item, $selected_item ); 68 76 } 69 77 } 70 78 … … function bp_is_group() { 1917 1925 if ( ! empty( $retval ) ) { 1918 1926 $retval = bp_is_groups_component() && groups_get_current_group(); 1919 1927 } 1920 1928 1921 1929 return (bool) $retval; 1922 1930 } 1923 1931 -
src/bp-groups/bp-groups-classes.php
diff --git src/bp-groups/bp-groups-classes.php src/bp-groups/bp-groups-classes.php index 9428b8f..eae8fb6 100644
class BP_Group_Extension { 3646 3646 $screen = $this->screens['edit']; 3647 3647 3648 3648 $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 ); 3649 $position += 40; 3650 3651 $current_group = groups_get_current_group(); 3652 $admin_link = trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ); 3653 3654 // Add the tab to the manage navigation 3655 bp_core_new_subnav_item( array( 3656 'name' => $screen['name'], 3657 'slug' => $screen['slug'], 3658 'parent_slug' => $current_group->slug . '_manage', 3659 'parent_url' => trailingslashit( bp_get_group_permalink( $current_group ) . 'admin' ), 3660 'user_has_access' => bp_is_item_admin(), 3661 'position' => $position, 3662 'screen_function' => 'groups_screen_group_admin', 3663 ) ); 3658 3664 3659 3665 // Catch the edit screen and forward it to the plugin template 3660 3666 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 e07dd26..d3ccbcf 100644
class BP_Groups_Component extends BP_Component { 509 509 ); 510 510 } 511 511 512 // If viewing an admin page, create the group admin subnav items 513 if ( bp_is_group_admin_page() ) { 514 $admin_link = trailingslashit( $group_link . 'admin' ); 515 516 // Common params to all nav items 517 $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(), 522 ); 523 524 $sub_nav[] = array_merge( array( 525 'name' => __( 'Details', 'buddypress' ), 526 'slug' => 'edit-details', 527 'position' => 0, 528 ), $default_params ); 529 530 $sub_nav[] = array_merge( array( 531 'name' => __( 'Settings', 'buddypress' ), 532 'slug' => 'group-settings', 533 'position' => 10, 534 ), $default_params ); 535 536 if ( ! (int) bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) { 537 $sub_nav[] = array_merge( array( 538 'name' => __( 'Photo', 'buddypress' ), 539 'slug' => 'group-avatar', 540 'position' => 20, 541 ), $default_params ); 542 } 543 544 $sub_nav[] = array_merge( array( 545 'name' => __( 'Members', 'buddypress' ), 546 'slug' => 'manage-members', 547 'position' => 30, 548 ), $default_params ); 549 550 if ( 'private' == $this->current_group->status ) { 551 $sub_nav[] = array_merge( array( 552 'name' => __( 'Requests', 'buddypress' ), 553 'slug' => 'membership-requests', 554 'position' => 40, 555 ), $default_params ); 556 } 557 558 $sub_nav[] = array_merge( array( 559 'name' => __( 'Delete', 'buddypress' ), 560 'slug' => 'delete-group', 561 'position' => 1000, 562 ), $default_params ); 563 } 564 512 565 parent::setup_nav( $main_nav, $sub_nav ); 513 566 } 514 567 -
src/bp-groups/bp-groups-template.php
diff --git src/bp-groups/bp-groups-template.php src/bp-groups/bp-groups-template.php index d487aeb..e0d17b1 100644
function bp_group_admin_tabs( $group = false ) { 2299 2299 $group = ( $groups_template->group ) ? $groups_template->group : groups_get_current_group(); 2300 2300 } 2301 2301 2302 $c urrent_tab = bp_get_group_current_admin_tab();2302 $css_id = 'manage-members'; 2303 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> 2304 if ( 'private' == $group->status ) { 2305 $css_id = 'membership-requests'; 2306 } 2314 2307 2315 <?php if ( !(int)bp_get_option( 'bp-disable-avatar-uploads' ) && buddypress()->avatar->show_avatars ) : ?>2308 add_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 ); 2316 2309 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>2310 bp_get_options_nav( $group->slug . '_manage' ); 2318 2311 2319 <?php endif; ?> 2312 remove_filter( "bp_get_options_nav_{$css_id}", 'bp_group_admin_tabs_backcompat', 10, 3 ); 2313 } 2320 2314 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> 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 */ 2324 function bp_group_admin_tabs_backcompat( $subnav_output = '', $subnav_item = '', $selected_item = '' ) { 2325 if ( ! has_action( 'groups_admin_tabs' ) ) { 2326 return $subnav_output; 2327 } 2322 2328 2323 <?php if ( $groups_template->group->status == 'private' ) : ?>2329 $group = groups_get_current_group(); 2324 2330 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>2331 ob_start(); 2326 2332 2327 <?php endif; ?>2333 do_action( 'groups_admin_tabs', $selected_item, $group->slug ); 2328 2334 2329 <?php do_action( 'groups_admin_tabs', $current_tab, $group->slug ) ?> 2335 $admin_tabs_backcompat = trim( ob_get_contents() ); 2336 ob_end_clean(); 2330 2337 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> 2338 if ( ! empty( $admin_tabs_backcompat ) ) { 2339 $subnav_output .= $admin_tabs_backcompat; 2340 } 2332 2341 2333 <?php 2342 return $subnav_output; 2334 2343 } 2335 2344 2336 2345 /**