diff --git src/bp-groups/classes/class-bp-groups-component.php src/bp-groups/classes/class-bp-groups-component.php
index 8f771c7d0..fd0d96bed 100644
|
|
|
class BP_Groups_Component extends BP_Component { |
| 110 | 110 | * @since 1.5.0 |
| 111 | 111 | */ |
| 112 | 112 | public function __construct() { |
| | 113 | $features = array(); |
| | 114 | if ( bp_is_active( 'friends' ) ) { |
| | 115 | $features[] = 'invitations'; |
| | 116 | } |
| | 117 | |
| 113 | 118 | parent::start( |
| 114 | 119 | 'groups', |
| 115 | 120 | _x( 'User Groups', 'Group screen page <title>', 'buddypress' ), |
| 116 | 121 | buddypress()->plugin_dir, |
| 117 | 122 | array( |
| 118 | 123 | 'adminbar_myaccount_order' => 70, |
| 119 | | 'search_query_arg' => 'groups_search', |
| | 124 | 'search_query_arg' => 'groups_search', |
| | 125 | 'features' => $features, |
| 120 | 126 | ) |
| 121 | 127 | ); |
| 122 | 128 | } |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 392 | 398 | ); |
| 393 | 399 | } |
| 394 | 400 | |
| 395 | | // If friends component is active, add invitations. |
| 396 | | if ( bp_is_active( 'friends' ) ) { |
| | 401 | // If invitations are enabled, add invitations. |
| | 402 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| 397 | 403 | $this->group_creation_steps['group-invites'] = array( |
| 398 | 404 | 'name' => _x( 'Invites', 'Group screen nav', 'buddypress' ), |
| 399 | 405 | 'position' => 30 |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 557 | 563 | // Determine user to use. |
| 558 | 564 | if ( bp_displayed_user_domain() ) { |
| 559 | 565 | $user_domain = bp_displayed_user_domain(); |
| | 566 | $user_id = bp_displayed_user_id(); |
| 560 | 567 | } elseif ( bp_loggedin_user_domain() ) { |
| 561 | 568 | $user_domain = bp_loggedin_user_domain(); |
| | 569 | $user_id = bp_loggedin_user_id(); |
| 562 | 570 | } else { |
| 563 | 571 | $user_domain = false; |
| | 572 | $user_id = 0; |
| 564 | 573 | } |
| 565 | 574 | |
| 566 | 575 | // Only grab count if we're on a user page. |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 607 | 616 | 'item_css_id' => 'groups-my-groups' |
| 608 | 617 | ); |
| 609 | 618 | |
| 610 | | // Add the Group Invites nav item. |
| 611 | | $sub_nav[] = array( |
| 612 | | 'name' => __( 'Invitations', 'buddypress' ), |
| 613 | | 'slug' => 'invites', |
| 614 | | 'parent_url' => $groups_link, |
| 615 | | 'parent_slug' => $slug, |
| 616 | | 'screen_function' => 'groups_screen_group_invites', |
| 617 | | 'user_has_access' => $access, |
| 618 | | 'position' => 30 |
| 619 | | ); |
| | 619 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| | 620 | // Add the Group Invites nav item. |
| | 621 | $sub_nav[] = array( |
| | 622 | 'name' => __( 'Invitations', 'buddypress' ), |
| | 623 | 'slug' => 'invites', |
| | 624 | 'parent_url' => $groups_link, |
| | 625 | 'parent_slug' => $slug, |
| | 626 | 'screen_function' => 'groups_screen_group_invites', |
| | 627 | 'user_has_access' => $access, |
| | 628 | 'position' => 30 |
| | 629 | ); |
| | 630 | } |
| 620 | 631 | |
| 621 | 632 | parent::setup_nav( $main_nav, $sub_nav ); |
| 622 | 633 | } |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 705 | 716 | ); |
| 706 | 717 | } |
| 707 | 718 | |
| 708 | | if ( bp_is_active( 'friends' ) && bp_groups_user_can_send_invites() ) { |
| | 719 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| 709 | 720 | $sub_nav[] = array( |
| 710 | 721 | 'name' => _x( 'Send Invites', 'My Group screen nav', 'buddypress' ), |
| 711 | 722 | 'slug' => 'send-invites', |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 833 | 844 | // Setup the logged in user variables. |
| 834 | 845 | $groups_link = trailingslashit( bp_loggedin_user_domain() . bp_get_groups_slug() ); |
| 835 | 846 | |
| 836 | | // Pending group invites. |
| 837 | | $count = groups_get_invite_count_for_user(); |
| 838 | 847 | $title = _x( 'Groups', 'My Account Groups', 'buddypress' ); |
| 839 | 848 | $pending = _x( 'No Pending Invites', 'My Account Groups sub nav', 'buddypress' ); |
| 840 | 849 | |
| 841 | | if ( $count ) { |
| 842 | | $title = sprintf( |
| 843 | | /* translators: %s: Group invitation count for the current user */ |
| 844 | | _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ), |
| 845 | | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| 846 | | ); |
| | 850 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| | 851 | // Pending group invites. |
| | 852 | $count = groups_get_invite_count_for_user(); |
| | 853 | if ( $count ) { |
| | 854 | $title = sprintf( |
| | 855 | /* translators: %s: Group invitation count for the current user */ |
| | 856 | _x( 'Groups %s', 'My Account Groups nav', 'buddypress' ), |
| | 857 | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| | 858 | ); |
| 847 | 859 | |
| 848 | | $pending = sprintf( |
| 849 | | /* translators: %s: Group invitation count for the current user */ |
| 850 | | _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ), |
| 851 | | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| 852 | | ); |
| | 860 | $pending = sprintf( |
| | 861 | /* translators: %s: Group invitation count for the current user */ |
| | 862 | _x( 'Pending Invites %s', 'My Account Groups sub nav', 'buddypress' ), |
| | 863 | '<span class="count">' . bp_core_number_format( $count ) . '</span>' |
| | 864 | ); |
| | 865 | } |
| 853 | 866 | } |
| 854 | 867 | |
| 855 | 868 | // Add the "My Account" sub menus. |
| … |
… |
class BP_Groups_Component extends BP_Component { |
| 870 | 883 | ); |
| 871 | 884 | |
| 872 | 885 | // Invitations. |
| 873 | | $wp_admin_nav[] = array( |
| 874 | | 'parent' => 'my-account-' . $this->id, |
| 875 | | 'id' => 'my-account-' . $this->id . '-invites', |
| 876 | | 'title' => $pending, |
| 877 | | 'href' => trailingslashit( $groups_link . 'invites' ), |
| 878 | | 'position' => 30 |
| 879 | | ); |
| | 886 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| | 887 | $wp_admin_nav[] = array( |
| | 888 | 'parent' => 'my-account-' . $this->id, |
| | 889 | 'id' => 'my-account-' . $this->id . '-invites', |
| | 890 | 'title' => $pending, |
| | 891 | 'href' => trailingslashit( $groups_link . 'invites' ), |
| | 892 | 'position' => 30 |
| | 893 | ); |
| | 894 | } |
| 880 | 895 | |
| 881 | 896 | // Create a Group. |
| 882 | 897 | if ( bp_user_can_create_groups() ) { |
diff --git src/bp-templates/bp-legacy/buddypress/groups/create.php src/bp-templates/bp-legacy/buddypress/groups/create.php
index cb85eeb71..e5dec51d0 100644
|
|
|
do_action( 'bp_before_create_group_page' ); ?> |
| 172 | 172 | |
| 173 | 173 | <?php endif; ?> |
| 174 | 174 | |
| 175 | | <fieldset class="group-create-invitations"> |
| | 175 | <?php if ( bp_is_active( 'groups', 'invitations' ) ): ?> |
| 176 | 176 | |
| 177 | | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| | 177 | <fieldset class="group-create-invitations"> |
| 178 | 178 | |
| 179 | | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| | 179 | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| 180 | 180 | |
| 181 | | <div class="radio"> |
| | 181 | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| 182 | 182 | |
| 183 | | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| | 183 | <div class="radio"> |
| 184 | 184 | |
| 185 | | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| | 185 | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| 186 | 186 | |
| 187 | | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| | 187 | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| 188 | 188 | |
| 189 | | </div> |
| | 189 | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| 190 | 190 | |
| 191 | | </fieldset> |
| | 191 | </div> |
| | 192 | |
| | 193 | </fieldset> |
| | 194 | |
| | 195 | <?php endif; ?> |
| 192 | 196 | |
| 193 | 197 | <?php |
| 194 | 198 | |
diff --git src/bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php src/bp-templates/bp-legacy/buddypress/groups/single/admin/group-settings.php
index 0961da5e8..024d6e614 100644
|
|
|
do_action( 'bp_before_group_settings_admin' ); ?> |
| 78 | 78 | |
| 79 | 79 | </fieldset> |
| 80 | 80 | |
| 81 | | <?php endif; ?> |
| | 81 | <?php endif ; ?> |
| 82 | 82 | |
| 83 | | <fieldset class="group-create-invitations"> |
| 84 | 83 | |
| 85 | | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| | 84 | <?php if ( bp_is_active( 'groups', 'invitations' ) ): ?> |
| 86 | 85 | |
| 87 | | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| | 86 | <fieldset class="group-create-invitations"> |
| 88 | 87 | |
| 89 | | <div class="radio"> |
| | 88 | <legend><?php _e( 'Group Invitations', 'buddypress' ); ?></legend> |
| 90 | 89 | |
| 91 | | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| | 90 | <p><?php _e( 'Which members of this group are allowed to invite others?', 'buddypress' ); ?></p> |
| 92 | 91 | |
| 93 | | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| | 92 | <div class="radio"> |
| 94 | 93 | |
| 95 | | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| | 94 | <label for="group-invite-status-members"><input type="radio" name="group-invite-status" id="group-invite-status-members" value="members"<?php bp_group_show_invite_status_setting( 'members' ); ?> /> <?php _e( 'All group members', 'buddypress' ); ?></label> |
| 96 | 95 | |
| 97 | | </div> |
| | 96 | <label for="group-invite-status-mods"><input type="radio" name="group-invite-status" id="group-invite-status-mods" value="mods"<?php bp_group_show_invite_status_setting( 'mods' ); ?> /> <?php _e( 'Group admins and mods only', 'buddypress' ); ?></label> |
| 98 | 97 | |
| 99 | | </fieldset> |
| | 98 | <label for="group-invite-status-admins"><input type="radio" name="group-invite-status" id="group-invite-status-admins" value="admins"<?php bp_group_show_invite_status_setting( 'admins' ); ?> /> <?php _e( 'Group admins only', 'buddypress' ); ?></label> |
| | 99 | |
| | 100 | </div> |
| | 101 | |
| | 102 | </fieldset> |
| | 103 | |
| | 104 | <?php endif; ?> |
| 100 | 105 | |
| 101 | 106 | <?php |
| 102 | 107 | |
diff --git src/bp-templates/bp-legacy/buddypress/groups/single/send-invites.php src/bp-templates/bp-legacy/buddypress/groups/single/send-invites.php
index 94a4854f3..f71d783aa 100644
|
|
|
|
| 14 | 14 | */ |
| 15 | 15 | do_action( 'bp_before_group_send_invites_content' ); ?> |
| 16 | 16 | |
| | 17 | <?php if ( ! bp_is_active( 'friends' ) ) : ?> |
| | 18 | <div id="message" class="info"> |
| | 19 | <p class="notice"><?php esc_html_e( 'Group invitations can only be extended to friends.', 'buddypress' ); ?></p> |
| | 20 | </div> |
| 17 | 21 | <?php |
| 18 | 22 | /* Does the user have friends that could be invited to the group? */ |
| 19 | | if ( bp_get_new_group_invite_friend_list() ) : ?> |
| | 23 | elseif ( bp_get_new_group_invite_friend_list() ) : ?> |
| 20 | 24 | |
| 21 | 25 | <h2 class="bp-screen-reader-text"><?php _e( 'Send invites', 'buddypress' ); ?></h2> |
| 22 | 26 | |
diff --git src/bp-templates/bp-nouveau/buddypress/groups/single/admin/group-settings.php src/bp-templates/bp-nouveau/buddypress/groups/single/admin/group-settings.php
index 6d24eafd3..d21e07573 100644
|
|
|
if ( $group_types ) : ?> |
| 86 | 86 | |
| 87 | 87 | <?php endif; ?> |
| 88 | 88 | |
| | 89 | <?php if ( bp_is_active( 'groups', 'invitations' ) ): ?> |
| | 90 | |
| 89 | 91 | <fieldset class="radio group-invitations"> |
| 90 | 92 | <legend><?php esc_html_e( 'Group Invitations', 'buddypress' ); ?></legend> |
| 91 | 93 | |
| … |
… |
if ( $group_types ) : ?> |
| 108 | 110 | |
| 109 | 111 | </fieldset> |
| 110 | 112 | |
| | 113 | <?php endif; ?> |
| | 114 | |
| 111 | 115 | </div><!-- // .group-settings-selections --> |
diff --git src/bp-templates/bp-nouveau/includes/groups/classes.php src/bp-templates/bp-nouveau/includes/groups/classes.php
index 2155bd86e..d5abe1177 100644
|
|
|
class BP_Nouveau_Customizer_Group_Nav extends BP_Core_Nav { |
| 259 | 259 | 'parent_slug' => $this->group->slug, |
| 260 | 260 | 'position' => 10, |
| 261 | 261 | ), |
| 262 | | 'invites' => array( |
| 263 | | 'name' => _x( 'Invite', 'My Group screen nav', 'buddypress' ), |
| 264 | | 'slug' => 'send-invites', |
| 265 | | 'parent_slug' => $this->group->slug, |
| 266 | | 'position' => 70, |
| 267 | | ), |
| 268 | 262 | 'manage' => array( |
| 269 | 263 | 'name' => _x( 'Manage', 'My Group screen nav', 'buddypress' ), |
| 270 | 264 | 'slug' => 'admin', |
| … |
… |
class BP_Nouveau_Customizer_Group_Nav extends BP_Core_Nav { |
| 273 | 267 | ), |
| 274 | 268 | ); |
| 275 | 269 | |
| | 270 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| | 271 | $nav_items['invites'] = array( |
| | 272 | 'name' => _x( 'Invite', 'My Group screen nav', 'buddypress' ), |
| | 273 | 'slug' => 'send-invites', |
| | 274 | 'parent_slug' => $this->group->slug, |
| | 275 | 'position' => 70, |
| | 276 | ); |
| | 277 | } |
| | 278 | |
| 276 | 279 | // Make sure only global front.php will be checked. |
| 277 | 280 | add_filter( '_bp_nouveau_group_reset_front_template', array( $this, 'all_groups_fronts' ), 10, 1 ); |
| 278 | 281 | |
diff --git src/bp-templates/bp-nouveau/includes/groups/functions.php src/bp-templates/bp-nouveau/includes/groups/functions.php
index e1589069e..8c7867433 100644
|
|
|
function bp_nouveau_groups_disallow_all_members_invites( $default = false ) { |
| 102 | 102 | return apply_filters( 'bp_nouveau_groups_disallow_all_members_invites', $default ); |
| 103 | 103 | } |
| 104 | 104 | |
| | 105 | /** |
| | 106 | * Activate the Groups invitations feature if any member can be invited. |
| | 107 | * |
| | 108 | * @since 10.0.0 |
| | 109 | * |
| | 110 | * @param bool True if any member can be invited. False otherwise. |
| | 111 | */ |
| | 112 | function bp_nouveau_is_groups_invitations_active() { |
| | 113 | return ! bp_nouveau_groups_disallow_all_members_invites(); |
| | 114 | } |
| | 115 | add_filter( 'bp_is_groups_invitations_active', 'bp_nouveau_is_groups_invitations_active' ); |
| | 116 | |
| 105 | 117 | /** |
| 106 | 118 | * Localize the strings needed for the Group's Invite UI |
| 107 | 119 | * |
| … |
… |
function bp_nouveau_get_group_potential_invites( $args = array() ) { |
| 310 | 322 | } |
| 311 | 323 | |
| 312 | 324 | /** |
| | 325 | * Rename the Group invite step. |
| | 326 | * |
| 313 | 327 | * @since 3.0.0 |
| | 328 | * @since 10.0.0 The function is no more creating a Group invite step. |
| | 329 | * |
| | 330 | * @param array $steps The Group create steps. |
| | 331 | * @return array The Group create steps. |
| 314 | 332 | */ |
| 315 | 333 | function bp_nouveau_group_invites_create_steps( $steps = array() ) { |
| 316 | | if ( bp_is_active( 'friends' ) && isset( $steps['group-invites'] ) ) { |
| 317 | | // Simply change the name |
| | 334 | if ( isset( $steps['group-invites'] ) ) { |
| 318 | 335 | $steps['group-invites']['name'] = _x( 'Invite', 'Group invitations menu title', 'buddypress' ); |
| 319 | | return $steps; |
| 320 | 336 | } |
| 321 | 337 | |
| 322 | | // Add the create step if friends component is not active |
| 323 | | $steps['group-invites'] = array( |
| 324 | | 'name' => _x( 'Invite', 'Group invitations menu title', 'buddypress' ), |
| 325 | | 'position' => 30, |
| 326 | | ); |
| 327 | | |
| 328 | 338 | return $steps; |
| 329 | 339 | } |
| 330 | 340 | |
| 331 | 341 | /** |
| | 342 | * Rename of the Group Invites nav. |
| | 343 | * |
| 332 | 344 | * @since 3.0.0 |
| | 345 | * @since 10.0.0 The function is no more creating a Group invite nav. |
| 333 | 346 | */ |
| 334 | 347 | function bp_nouveau_group_setup_nav() { |
| 335 | 348 | if ( ! bp_is_group() || ! bp_groups_user_can_send_invites() ) { |
| 336 | 349 | return; |
| 337 | 350 | } |
| 338 | 351 | |
| 339 | | // Simply change the name |
| 340 | | if ( bp_is_active( 'friends' ) ) { |
| | 352 | // |
| | 353 | if ( bp_is_active( 'groups', 'invitations' ) ) { |
| 341 | 354 | $bp = buddypress(); |
| 342 | 355 | |
| 343 | 356 | $bp->groups->nav->edit_nav( |
| … |
… |
function bp_nouveau_group_setup_nav() { |
| 345 | 358 | 'send-invites', |
| 346 | 359 | bp_get_current_group_slug() |
| 347 | 360 | ); |
| 348 | | |
| 349 | | // Create the Subnav item for the group |
| 350 | | } else { |
| 351 | | $current_group = groups_get_current_group(); |
| 352 | | $group_link = bp_get_group_permalink( $current_group ); |
| 353 | | |
| 354 | | bp_core_new_subnav_item( array( |
| 355 | | 'name' => _x( 'Invite', 'Group invitations menu title', 'buddypress' ), |
| 356 | | 'slug' => 'send-invites', |
| 357 | | 'parent_url' => $group_link, |
| 358 | | 'parent_slug' => $current_group->slug, |
| 359 | | 'screen_function' => 'groups_screen_group_invite', |
| 360 | | 'item_css_id' => 'invite', |
| 361 | | 'position' => 70, |
| 362 | | 'user_has_access' => $current_group->user_has_access, |
| 363 | | 'no_access_url' => $group_link, |
| 364 | | ) ); |
| 365 | 361 | } |
| 366 | 362 | } |
| 367 | 363 | |