Changeset 13451
- Timestamp:
- 04/14/2023 04:11:52 AM (20 months ago)
- Location:
- trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/admin/bp-core-admin-rewrites.php
r13450 r13451 200 200 <?php endif; ?> 201 201 <?php endif; ?> 202 203 <?php if ( 'groups' === $component_id ) : ?> 204 205 <?php 206 foreach ( 207 array( 208 'create' => __( 'Single Group creation steps slugs', 'buddypress' ), 209 'read' => __( 'Single Group regular screens slugs', 'buddypress' ), 210 'manage' => __( 'Single Group management screens slugs', 'buddypress' ), 211 ) as $screen_type => $screen_type_title ) : 212 ?> 213 214 <div class="health-check-accordion"> 215 <h4 class="health-check-accordion-heading"> 216 <button aria-expanded="false" class="health-check-accordion-trigger" aria-controls="health-check-accordion-block-group-<?php echo esc_attr( $screen_type ); ?>" type="button"> 217 <span class="title"><?php echo esc_html( $screen_type_title ); ?></span> 218 <span class="icon"></span> 219 </button> 220 </h4> 221 <div id="health-check-accordion-block-group-<?php echo esc_attr( $screen_type ); ?>" class="health-check-accordion-panel" hidden="hidden"> 222 <table class="form-table" role="presentation"> 223 224 <?php 225 if ( 'create' === $screen_type ) : 226 foreach ( bp_get_group_restricted_screens() as $group_create_restricted_screen ) : 227 ?> 228 <tr> 229 <th scope="row"> 230 <label style="margin-left: 2em; display: inline-block; vertical-align: middle" for="<?php echo esc_attr( sprintf( '%s-slug', sanitize_key( $group_create_restricted_screen['rewrite_id'] ) ) ); ?>"> 231 <?php echo esc_html( $group_create_restricted_screen['name'] ); ?> 232 </label> 233 </th> 234 <td> 235 <input type="text" class="code" name="<?php printf( 'components[%1$d][_bp_component_slugs][%2$s]', absint( $directory_data->id ), esc_attr( $group_create_restricted_screen['rewrite_id'] ) ); ?>" id="<?php echo esc_attr( sprintf( '%s-slug', sanitize_key( $group_create_restricted_screen['rewrite_id'] ) ) ); ?>" value="<?php echo esc_attr( bp_rewrites_get_slug( $component_id, $group_create_restricted_screen['rewrite_id'], $group_create_restricted_screen['slug'] ) ); ?>"> 236 </td> 237 </tr> 238 <?php 239 endforeach; 240 241 endif; 242 243 foreach ( bp_get_group_screens( $screen_type ) as $group_screen ) : 244 if ( ! isset( $group_screen['rewrite_id'] ) || ! $group_screen['rewrite_id'] ) { 245 continue; 246 } 247 ?> 248 <tr> 249 <th scope="row"> 250 <label style="margin-left: 2em; display: inline-block; vertical-align: middle" for="<?php echo esc_attr( sprintf( '%s-slug', sanitize_key( $group_screen['rewrite_id'] ) ) ); ?>"> 251 <?php 252 printf( 253 /* translators: %s is group view name */ 254 esc_html_x( '"%s" slug', 'group view name URL admin label', 'buddypress' ), 255 esc_html( _bp_strip_spans_from_title( $group_screen['name'] ) ) 256 ); 257 ?> 258 </label> 259 </th> 260 <td> 261 <input type="text" class="code" name="<?php printf( 'components[%1$d][_bp_component_slugs][%2$s]', absint( $directory_data->id ), esc_attr( $group_screen['rewrite_id'] ) ); ?>" id="<?php echo esc_attr( sprintf( '%s-slug', sanitize_key( $group_screen['rewrite_id'] ) ) ); ?>" value="<?php echo esc_attr( bp_rewrites_get_slug( $component_id, $group_screen['rewrite_id'], $group_screen['slug'] ) ); ?>"> 262 </td> 263 </tr> 264 <?php endforeach; ?> 265 </table> 266 </div> 267 </div> 268 <?php endforeach; ?> 269 <?php endif; ?> 202 270 </div> 203 271 <?php endforeach; ?> -
trunk/src/bp-groups/bp-groups-functions.php
r13449 r13451 1276 1276 */ 1277 1277 return apply_filters( 'groups_get_current_group', $current_group ); 1278 } 1279 1280 /** 1281 * Can the current user access to the current group? 1282 * 1283 * @since 12.0.0 1284 * 1285 * @return boolean True if the current user can access to the current group. 1286 * False otherwise. 1287 */ 1288 function bp_groups_user_can_access_current_group() { 1289 $can_access = false; 1290 1291 $current_group = groups_get_current_group(); 1292 if ( isset( $current_group->user_has_access ) ) { 1293 $can_access = $current_group->user_has_access; 1294 } 1295 1296 return $can_access; 1278 1297 } 1279 1298 … … 3791 3810 * @since 12.0.0 3792 3811 * 3793 * @param string $context The display context. Required. Defaults to `read`. 3794 * @return array The list of potential Group screens. 3795 */ 3796 function bp_get_group_screens( $context = 'read' ) { 3812 * @param string $context The display context. Required. Defaults to `read`. 3813 * @param boolean $built_in True to only get builtin screens. False otherwise. 3814 * @return array The list of potential Group screens. 3815 */ 3816 function bp_get_group_screens( $context = 'read', $built_in = false ) { 3797 3817 $screens = array( 3798 3818 'create' => array( … … 3837 3857 'item_css_id' => 'home', 3838 3858 ), 3839 'activity' => array(3840 'rewrite_id' => 'bp_group_read_activity',3841 'slug' => 'activity',3842 'name' => _x( 'Activity', 'Group read screen', 'buddypress' ),3843 'screen_function' => 'groups_screen_group_activity',3844 'position' => 11,3845 'user_has_access' => false,3846 'no_access_url' => '',3847 'item_css_id' => 'activity',3848 ),3849 3859 'request-membership' => array( 3850 3860 'rewrite_id' => 'bp_group_read_request_membership', … … 3854 3864 'position' => 30, 3855 3865 ), 3866 'activity' => array( 3867 'rewrite_id' => 'bp_group_read_activity', 3868 'slug' => 'activity', 3869 'name' => _x( 'Activity', 'Group read screen', 'buddypress' ), 3870 'screen_function' => 'groups_screen_group_activity', 3871 'position' => 11, 3872 'user_has_access' => false, 3873 'user_has_access_callback' => 'bp_groups_user_can_access_current_group', 3874 'no_access_url' => '', 3875 'item_css_id' => 'activity', 3876 ), 3856 3877 'members' => array( 3857 'rewrite_id' => 'bp_group_read_members',3858 'slug' => 'members',3878 'rewrite_id' => 'bp_group_read_members', 3879 'slug' => 'members', 3859 3880 /* translators: %s: total member count */ 3860 'name' => _x( 'Members %s', 'Group read screen', 'buddypress' ), 3861 'screen_function' => 'groups_screen_group_members', 3862 'position' => 60, 3863 'user_has_access' => false, 3864 'no_access_url' => '', 3865 'item_css_id' => 'members', 3881 'name' => _x( 'Members %s', 'Group read screen', 'buddypress' ), 3882 'screen_function' => 'groups_screen_group_members', 3883 'position' => 60, 3884 'user_has_access' => false, 3885 'user_has_access_callback' => 'bp_groups_user_can_access_current_group', 3886 'no_access_url' => '', 3887 'item_css_id' => 'members', 3866 3888 ), 3867 3889 'send-invites' => array( 3868 'rewrite_id' => 'bp_group_read_send_invites', 3869 'slug' => 'send-invites', 3870 'name' => _x( 'Send Invites', 'Group read screen', 'buddypress' ), 3871 'screen_function' => 'groups_screen_group_invite', 3872 'position' => 70, 3873 'user_has_access' => false, 3874 'no_access_url' => '', 3875 'item_css_id' => 'invite', 3890 'rewrite_id' => 'bp_group_read_send_invites', 3891 'slug' => 'send-invites', 3892 'name' => _x( 'Send Invites', 'Group read screen', 'buddypress' ), 3893 'screen_function' => 'groups_screen_group_invite', 3894 'position' => 70, 3895 'user_has_access' => false, 3896 'user_has_access_callback' => 'bp_groups_user_can_send_invites', 3897 'no_access_url' => '', 3898 'item_css_id' => 'invite', 3876 3899 ), 3877 3900 'admin' => array( 3878 'rewrite_id' => 'bp_group_read_admin', 3879 'slug' => 'admin', 3880 'name' => _x( 'Manage', 'Group read screen', 'buddypress' ), 3881 'screen_function' => 'groups_screen_group_admin', 3882 'position' => 1000, 3883 'user_has_access' => false, 3884 'no_access_url' => '', 3885 'item_css_id' => 'admin', 3901 'rewrite_id' => 'bp_group_read_admin', 3902 'slug' => 'admin', 3903 'name' => _x( 'Manage', 'Group read screen', 'buddypress' ), 3904 'screen_function' => 'groups_screen_group_admin', 3905 'position' => 1000, 3906 'user_has_access' => false, 3907 'user_has_access_callback' => 'bp_is_item_admin', 3908 'no_access_url' => '', 3909 'item_css_id' => 'admin', 3886 3910 ), 3887 3911 ), … … 3957 3981 } 3958 3982 3983 // We only need built-in screens, do not get custom ones. 3984 if ( $built_in ) { 3985 return $screens[ $context ]; 3986 } 3987 3959 3988 $context_screens = array(); 3960 3989 $custom_screens = apply_filters( 'bp_get_group_custom_' . $context . '_screens', $context_screens ); … … 3967 3996 if ( $custom_screens && ! wp_is_numeric_array( $custom_screens ) ) { 3968 3997 // The screen key (used as default slug) and `rewrite_id` prop need to be unique. 3969 $valid_custom_screens 3998 $valid_custom_screens = array_diff_key( $custom_screens, $screens[ $context ] ); 3970 3999 $existing_rewrite_ids = array_column( $screens[ $context ], 'rewrite_id' ); 3971 4000 $existing_rewrite_ids = array_merge( -
trunk/src/bp-groups/bp-groups-template.php
r13449 r13451 3243 3243 } 3244 3244 3245 $ views = bp_get_group_screens( 'read' );3246 if ( isset( $ views[ $page ]['rewrite_id'] ) ) {3247 $page = bp_rewrites_get_slug( 'groups', $ views[ $page ]['rewrite_id'], $page );3245 $screens = bp_get_group_screens( 'read' ); 3246 if ( isset( $screens[ $page ]['rewrite_id'] ) ) { 3247 $page = bp_rewrites_get_slug( 'groups', $screens[ $page ]['rewrite_id'], $page ); 3248 3248 } 3249 3249 … … 3303 3303 } 3304 3304 3305 $ views = bp_get_group_screens( 'manage' );3306 if ( isset( $ views[ $page ]['rewrite_id'] ) ) {3307 $page = bp_rewrites_get_slug( 'groups', $ views[ $page ]['rewrite_id'], $page );3305 $screens = bp_get_group_screens( 'manage' ); 3306 if ( isset( $screens[ $page ]['rewrite_id'] ) ) { 3307 $page = bp_rewrites_get_slug( 'groups', $screens[ $page ]['rewrite_id'], $page ); 3308 3308 } 3309 3309 -
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.