Skip to content

Commit

Permalink
Groups integration: Use groups_get_current_group().
Browse files Browse the repository at this point in the history
Use `groups_get_current_group()` instead of directly accessing the `$bp` global.
  • Loading branch information
dcavins committed Dec 19, 2023
1 parent fb278dd commit a2dd61d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions includes/integration-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1308,27 +1308,27 @@ function admin_markup() {
* @since 1.0-beta
*/
function enable_nav_item() {
global $bp;

$enable_nav_item = false;
$this->settings = bp_docs_get_group_settings( $this->group_id );
$this->group_enable = ! empty( $this->settings['group-enable'] ) ? true : false;
$current_group = groups_get_current_group();

// The nav item should only be enabled when BP Docs is enabled for the group
if ( $this->group_enable ) {
if ( !empty( $bp->groups->current_group->status ) && $status = $bp->groups->current_group->status ) {
if ( ! empty( $current_group->status ) && $status = $current_group->status ) {
// Docs in public groups are publicly viewable.
if ( 'public' == $status ) {
$enable_nav_item = true;
} else if ( groups_is_user_member( bp_loggedin_user_id(), $bp->groups->current_group->id ) ) {
} else if ( groups_is_user_member( bp_loggedin_user_id(), $current_group->id ) ) {
// Docs in private or hidden groups visible only to members
$enable_nav_item = true;
}
}

// Super admin override
if ( is_super_admin() )
if ( is_super_admin() ) {
$enable_nav_item = true;
}
}

return apply_filters( 'bp_docs_groups_enable_nav_item', $enable_nav_item );
Expand Down

0 comments on commit a2dd61d

Please sign in to comment.