- Timestamp:
- 04/14/2023 04:11:52 AM (19 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-groups/classes/class-bp-groups-component.php
r13450 r13451 375 375 376 376 // Set default Group creation steps. 377 $group_creation_steps = bp_get_group_screens( 'create' );377 $group_creation_steps = bp_get_group_screens( 'create', true ); 378 378 379 379 // If avatar uploads are disabled, remove avatar view. … … 632 632 } 633 633 634 // Generate the displayed User navigation for the Groupe compnent. 635 parent::setup_nav( $main_nav, $sub_nav ); 636 637 // Generate the displayed Group navigation. 634 638 if ( bp_is_groups_component() && bp_is_single_item() ) { 635 639 /* … … 637 641 * It does not appear in the interface. 638 642 */ 639 bp_core_new_nav_item( array( 640 'name' => __( 'Memberships', 'buddypress' ), 641 'slug' => $this->current_group->slug, 642 'position' => -1, // Do not show into the navigation. 643 'screen_function' => 'groups_screen_group_home', 644 'default_subnav_slug' => $this->default_extension, 645 'item_css_id' => $this->id 646 ), 'groups' ); 647 643 bp_core_new_nav_item( 644 array( 645 'name' => __( 'Memberships', 'buddypress' ), 646 'slug' => $this->current_group->slug, 647 'position' => -1, // Do not show into the navigation. 648 'screen_function' => 'groups_screen_group_home', 649 'default_subnav_slug' => $this->default_extension, 650 'item_css_id' => $this->id 651 ), 652 'groups' 653 ); 654 655 // Get the "read" screens. 656 $screens = bp_get_group_screens( 'read', true ); 648 657 $group_link = bp_get_group_url( $this->current_group ); 649 650 // Add the "Home" subnav item, as this will always be present. 651 $sub_nav[] = array( 652 'name' => _x( 'Home', 'Group screen navigation title', 'buddypress' ), 653 'slug' => 'home', 654 'parent_slug' => $this->current_group->slug, 655 'screen_function' => 'groups_screen_group_home', 656 'position' => 10, 657 'item_css_id' => 'home' 658 ); 658 $sub_nav = array(); 659 659 660 660 /* 661 661 * If this is a private group, and the user is not a member and does not 662 * have an outstanding invitation, how a "Request Membership" nav item. 662 * have an outstanding invitation, only generate the request membership 663 * nav item if the user can request this membership. 663 664 */ 664 if ( bp_current_user_can( 'groups_request_membership', array( 'group_id' => $this->current_group->id ) ) ) { 665 $sub_nav[] = array( 666 'name' => _x( 'Request Membership','Group screen nav', 'buddypress' ), 667 'slug' => 'request-membership', 668 'parent_slug' => $this->current_group->slug, 669 'screen_function' => 'groups_screen_group_request_membership', 670 'position' => 30 671 ); 672 } 673 674 if ( $this->current_group->front_template || bp_is_active( 'activity' ) ) { 675 // If the theme is using a custom front, create activity subnav. 676 if ( $this->current_group->front_template && bp_is_active( 'activity' ) ) { 677 $sub_nav[] = array( 678 'name' => _x( 'Activity', 'My Group screen nav', 'buddypress' ), 679 'slug' => 'activity', 680 'parent_slug' => $this->current_group->slug, 681 'screen_function' => 'groups_screen_group_activity', 682 'position' => 11, 683 'user_has_access' => $this->current_group->user_has_access, 684 'item_css_id' => 'activity', 685 'no_access_url' => $group_link, 665 if ( ! bp_current_user_can( 'groups_request_membership', array( 'group_id' => $this->current_group->id ) ) ) { 666 unset( $screens['request-membership'] ); 667 } 668 669 // If the invitations feature is not active remove the corresponding nav item. 670 if ( ! bp_is_active( 'groups', 'invitations' ) ) { 671 unset( $screens['send-invites'] ); 672 } 673 674 /* 675 * By default activity is group's home, only keep an activity sub nab if there's 676 * a custom group's front page and the activity component is active. 677 */ 678 if ( ! $this->current_group->front_template || ! bp_is_active( 'activity' ) ) { 679 unset( $screens['activity'] ); 680 } 681 682 /* 683 * If there's a custom group's front page and the activity component is not active, 684 * The members screen is use as the group's home page. If it's not the case, remove 685 * the corresponding nav item. 686 */ 687 if ( ! $this->current_group->front_template && ! bp_is_active( 'activity' ) ) { 688 unset( $screens['members'] ); 689 } 690 691 foreach ( $screens as $screen_id => $sub_nav_item ) { 692 $sub_nav_item['parent_slug'] = $this->current_group->slug; 693 694 if ( 'members' === $screen_id ) { 695 $sub_nav_item['name'] = sprintf( 696 $sub_nav_item['name'], 697 '<span>' . number_format( $this->current_group->total_member_count ) . '</span>' 686 698 ); 687 699 } 688 700 689 // Only add the members subnav if it's not the home's nav. 690 $sub_nav[] = array( 691 'name' => sprintf( 692 /* translators: %s: total member count */ 693 _x( 'Members %s', 'My Group screen nav', 'buddypress' ), 694 '<span>' . number_format( $this->current_group->total_member_count ) . '</span>' 695 ), 696 'slug' => 'members', 697 'parent_slug' => $this->current_group->slug, 698 'screen_function' => 'groups_screen_group_members', 699 'position' => 60, 700 'user_has_access' => $this->current_group->user_has_access, 701 'item_css_id' => 'members', 702 'no_access_url' => $group_link, 703 ); 704 } 705 706 if ( bp_is_active( 'groups', 'invitations' ) ) { 707 $sub_nav[] = array( 708 'name' => _x( 'Send Invites', 'My Group screen nav', 'buddypress' ), 709 'slug' => 'send-invites', 710 'parent_slug' => $this->current_group->slug, 711 'screen_function' => 'groups_screen_group_invite', 712 'item_css_id' => 'invite', 713 'position' => 70, 714 'user_has_access' => bp_groups_user_can_send_invites(), 715 'no_access_url' => $group_link, 716 ); 701 if ( isset( $sub_nav_item['no_access_url'] ) ) { 702 $sub_nav_item['no_access_url'] = $group_link; 703 } 704 705 if ( isset( $sub_nav_item['user_has_access_callback'] ) && is_callable( $sub_nav_item['user_has_access_callback'] ) ) { 706 $sub_nav_item['user_has_access'] = call_user_func( $sub_nav_item['user_has_access_callback'] ); 707 unset( $sub_nav_item['user_has_access_callback'] ); 708 } 709 710 // Add the sub nav item. 711 $sub_nav[] = $sub_nav_item; 717 712 } 718 713 719 714 // If the user is a group admin, then show the group admin nav item. 720 715 if ( bp_is_item_admin() ) { 721 $sub_nav[] = array( 722 'name' => _x( 'Manage', 'My Group screen nav', 'buddypress' ), 723 'slug' => 'admin', 724 'parent_slug' => $this->current_group->slug, 725 'screen_function' => 'groups_screen_group_admin', 726 'position' => 1000, 727 'user_has_access' => true, 728 'item_css_id' => 'admin', 729 'no_access_url' => $group_link, 730 ); 731 732 $admin_link = bp_get_group_url( 716 // Get the "manage" screens. 717 $manage_screens = bp_get_group_screens( 'manage', true ); 718 $admin_link = bp_get_group_url( 733 719 $this->current_group, 734 720 array( … … 745 731 ); 746 732 747 $sub_nav[] = array_merge( array( 748 'name' => __( 'Details', 'buddypress' ), 749 'slug' => 'edit-details', 750 'position' => 0, 751 ), $default_params ); 752 753 $sub_nav[] = array_merge( array( 754 'name' => __( 'Settings', 'buddypress' ), 755 'slug' => 'group-settings', 756 'position' => 10, 757 ), $default_params ); 758 759 if ( ! bp_disable_group_avatar_uploads() && buddypress()->avatar->show_avatars ) { 760 $sub_nav[] = array_merge( array( 761 'name' => __( 'Photo', 'buddypress' ), 762 'slug' => 'group-avatar', 763 'position' => 20, 764 ), $default_params ); 765 } 766 767 if ( bp_group_use_cover_image_header() ) { 768 $sub_nav[] = array_merge( array( 769 'name' => __( 'Cover Image', 'buddypress' ), 770 'slug' => 'group-cover-image', 771 'position' => 25, 772 ), $default_params ); 773 } 774 775 $sub_nav[] = array_merge( array( 776 'name' => __( 'Members', 'buddypress' ), 777 'slug' => 'manage-members', 778 'position' => 30, 779 ), $default_params ); 780 781 if ( 'private' == $this->current_group->status ) { 782 $sub_nav[] = array_merge( array( 783 'name' => __( 'Requests', 'buddypress' ), 784 'slug' => 'membership-requests', 785 'position' => 40, 786 ), $default_params ); 787 } 788 789 $sub_nav[] = array_merge( array( 790 'name' => __( 'Delete', 'buddypress' ), 791 'slug' => 'delete-group', 792 'position' => 1000, 793 ), $default_params ); 794 } 795 733 // Only keep the Group's profile photo screen if avatars are enabled. 734 if ( bp_disable_group_avatar_uploads() || ! buddypress()->avatar->show_avatars ) { 735 unset( $manage_screens['group-avatar'] ); 736 } 737 738 // Only keep the Group's cover image screen if cover images are enabled. 739 if ( ! bp_group_use_cover_image_header() ) { 740 unset( $manage_screens['group-cover-image'] ); 741 } 742 743 // Only keep the membership requests screen for private groups. 744 if ( 'private' !== $this->current_group->status ) { 745 unset( $manage_screens['membership-requests'] ); 746 } 747 748 foreach ( $manage_screens as $manage_screen_id => $manage_sub_nav_item ) { 749 $sub_nav[] = array_merge( $manage_sub_nav_item, $default_params ); 750 } 751 } 752 753 // Finally generate read/manage nav items. 796 754 foreach ( $sub_nav as $nav ) { 797 755 bp_core_new_subnav_item( $nav, 'groups' ); … … 814 772 } 815 773 } 816 817 parent::setup_nav( $main_nav, $sub_nav );818 774 } 819 775
Note: See TracChangeset
for help on using the changeset viewer.