- Timestamp:
- 03/23/2023 07:35:38 PM (18 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-groups-component.php
r13437 r13441 315 315 316 316 // Initialize the nav for the groups component. 317 $this->nav = new BP_Core_Nav( $this->current_group->id );317 $this->nav = new BP_Core_Nav( $this->current_group->id, $this->id ); 318 318 319 319 // Set current_group to 0 to prevent debug errors. … … 566 566 public function setup_nav( $main_nav = array(), $sub_nav = array() ) { 567 567 568 // Determine user to use. 569 if ( bp_displayed_user_domain() ) { 570 $user_domain = bp_displayed_user_domain(); 571 } elseif ( bp_loggedin_user_domain() ) { 572 $user_domain = bp_loggedin_user_domain(); 573 } else { 574 $user_domain = false; 575 } 576 577 // Only grab count if we're on a user page. 578 if ( bp_is_user() ) { 579 $class = ( 0 === groups_total_groups_for_user( bp_displayed_user_id() ) ) ? 'no-count' : 'count'; 580 581 $nav_name = sprintf( 582 /* translators: %s: Group count for the current user */ 583 _x( 'Groups %s', 'Group screen nav with counter', 'buddypress' ), 584 sprintf( 585 '<span class="%s">%s</span>', 586 esc_attr( $class ), 587 bp_get_total_group_count_for_user() 588 ) 568 if ( is_user_logged_in() || bp_displayed_user_id() ) { 569 // Only grab count if we're on a user page. 570 if ( bp_is_user() ) { 571 $class = ( 0 === groups_total_groups_for_user( bp_displayed_user_id() ) ) ? 'no-count' : 'count'; 572 573 $nav_name = sprintf( 574 /* translators: %s: Group count for the current user */ 575 _x( 'Groups %s', 'Group screen nav with counter', 'buddypress' ), 576 sprintf( 577 '<span class="%s">%s</span>', 578 esc_attr( $class ), 579 bp_get_total_group_count_for_user() 580 ) 581 ); 582 } else { 583 $nav_name = _x( 'Groups', 'Group screen nav without counter', 'buddypress' ); 584 } 585 586 $slug = bp_get_groups_slug(); 587 $access = bp_core_can_edit_settings(); 588 589 // Add 'Groups' to the main navigation. 590 $main_nav = array( 591 'name' => $nav_name, 592 'slug' => $slug, 593 'position' => 70, 594 'screen_function' => 'groups_screen_my_groups', 595 'default_subnav_slug' => 'my-groups', 596 'item_css_id' => $this->id 589 597 ); 590 } else {591 $nav_name = _x( 'Groups', 'Group screen nav without counter', 'buddypress' );592 }593 594 $slug = bp_get_groups_slug();595 596 // Add 'Groups' to the main navigation.597 $main_nav = array(598 'name' => $nav_name,599 'slug' => $slug,600 'position' => 70,601 'screen_function' => 'groups_screen_my_groups',602 'default_subnav_slug' => 'my-groups',603 'item_css_id' => $this->id604 );605 606 if ( ! empty( $user_domain ) ) {607 $access = bp_core_can_edit_settings();608 $groups_link = trailingslashit( $user_domain . $slug );609 598 610 599 // Add the My Groups nav item. … … 612 601 'name' => __( 'Memberships', 'buddypress' ), 613 602 'slug' => 'my-groups', 614 'parent_url' => $groups_link,615 603 'parent_slug' => $slug, 616 604 'screen_function' => 'groups_screen_my_groups', … … 624 612 'name' => __( 'Invitations', 'buddypress' ), 625 613 'slug' => 'invites', 626 'parent_url' => $groups_link,627 614 'parent_slug' => $slug, 628 615 'screen_function' => 'groups_screen_group_invites', … … 659 646 'name' => _x( 'Home', 'Group screen navigation title', 'buddypress' ), 660 647 'slug' => 'home', 661 'parent_url' => $group_link,662 648 'parent_slug' => $this->current_group->slug, 663 649 'screen_function' => 'groups_screen_group_home', … … 674 660 'name' => _x( 'Request Membership','Group screen nav', 'buddypress' ), 675 661 'slug' => 'request-membership', 676 'parent_url' => $group_link,677 662 'parent_slug' => $this->current_group->slug, 678 663 'screen_function' => 'groups_screen_group_request_membership', … … 689 674 'name' => _x( 'Activity', 'My Group screen nav', 'buddypress' ), 690 675 'slug' => 'activity', 691 'parent_url' => $group_link,692 676 'parent_slug' => $this->current_group->slug, 693 677 'screen_function' => 'groups_screen_group_activity', … … 709 693 ), 710 694 'slug' => 'members', 711 'parent_url' => $group_link,712 695 'parent_slug' => $this->current_group->slug, 713 696 'screen_function' => 'groups_screen_group_members', … … 723 706 'name' => _x( 'Send Invites', 'My Group screen nav', 'buddypress' ), 724 707 'slug' => 'send-invites', 725 'parent_url' => $group_link,726 708 'parent_slug' => $this->current_group->slug, 727 709 'screen_function' => 'groups_screen_group_invite', … … 738 720 'name' => _x( 'Manage', 'My Group screen nav', 'buddypress' ), 739 721 'slug' => 'admin', 740 'parent_url' => $group_link,741 722 'parent_slug' => $this->current_group->slug, 742 723 'screen_function' => 'groups_screen_group_admin', … … 747 728 ); 748 729 749 $admin_link = trailingslashit( $group_link . 'admin' ); 730 $admin_link = bp_get_group_url( 731 $this->current_group, 732 array( 733 'single_item_action' => bp_rewrites_get_slug( 'groups', 'bp_group_read_admin', 'admin' ), 734 ) 735 ); 750 736 751 737 // Common params to all nav items. 752 738 $default_params = array( 753 'parent_url' => $admin_link,754 739 'parent_slug' => $this->current_group->slug . '_manage', 755 740 'screen_function' => 'groups_screen_group_admin', … … 845 830 846 831 // Setup the logged in user variables. 847 $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); 832 $groups_slug = bp_get_groups_slug(); 833 $custom_groups_slug = bp_rewrites_get_slug( 'members', 'member_' . $groups_slug, $groups_slug ); 848 834 849 835 $title = _x( 'Groups', 'My Account Groups', 'buddypress' ); … … 873 859 'id' => 'my-account-' . $this->id, 874 860 'title' => $title, 875 'href' => $groups_link 861 'href' => bp_loggedin_user_url( 862 array( 863 'single_item_component' => $custom_groups_slug, 864 ) 865 ), 876 866 ); 877 867 … … 881 871 'id' => 'my-account-' . $this->id . '-memberships', 882 872 'title' => _x( 'Memberships', 'My Account Groups sub nav', 'buddypress' ), 883 'href' => trailingslashit( $groups_link . 'my-groups' ), 884 'position' => 10 873 'href' => bp_loggedin_user_url( 874 array( 875 'single_item_component' => $custom_groups_slug, 876 'single_item_action' => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_my_groups', 'my-groups' ), 877 ) 878 ), 879 'position' => 10, 885 880 ); 886 881 … … 891 886 'id' => 'my-account-' . $this->id . '-invites', 892 887 'title' => $pending, 893 'href' => trailingslashit( $groups_link . 'invites' ), 894 'position' => 30 888 'href' => bp_loggedin_user_url( 889 array( 890 'single_item_component' => $custom_groups_slug, 891 'single_item_action' => bp_rewrites_get_slug( 'members', 'member_' . $groups_slug . '_invites', 'invites' ), 892 ) 893 ), 894 'position' => 30, 895 895 ); 896 896 }
Note: See TracChangeset
for help on using the changeset viewer.