Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
11/25/2021 12:30:33 AM (22 months ago)
Author:
dcavins
Message:

Declare invitations as feature of groups component.

Centralize the logic which determines whether
group invitations are active by declaring
invitations as a feature of the groups
component. This also makes it easy for
developers to filter that value using the
bp_is_groups_invitations_active filter hook.

Props imath.

Fixes #8550.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-nouveau/includes/groups/functions.php

    r13108 r13156  
    102102    return apply_filters( 'bp_nouveau_groups_disallow_all_members_invites', $default );
    103103}
     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 */
     112function bp_nouveau_is_groups_invitations_active() {
     113    return ! bp_nouveau_groups_disallow_all_members_invites();
     114}
     115add_filter( 'bp_is_groups_invitations_active', 'bp_nouveau_is_groups_invitations_active' );
    104116
    105117/**
     
    311323
    312324/**
    313  * @since 3.0.0
     325 * Rename the Group invite step.
     326 *
     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.
    314332 */
    315333function 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'] ) ) {
    318335        $steps['group-invites']['name'] = _x( 'Invite', 'Group invitations menu title', 'buddypress' );
    319         return $steps;
    320     }
    321 
    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     );
     336    }
    327337
    328338    return $steps;
     
    330340
    331341/**
    332  * @since 3.0.0
     342 * Rename the Group Invites nav.
     343 *
     344 * @since 3.0.0
     345 * @since 10.0.0 The function is no longer creating a Group invite nav.
    333346 */
    334347function bp_nouveau_group_setup_nav() {
     
    337350    }
    338351
    339     // Simply change the name
    340     if ( bp_is_active( 'friends' ) ) {
     352    if ( bp_is_active( 'groups', 'invitations' ) ) {
    341353        $bp = buddypress();
    342354
     
    346358            bp_get_current_group_slug()
    347359        );
    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         ) );
    365360    }
    366361}
Note: See TracChangeset for help on using the changeset viewer.