Skip to content

Commit

Permalink
Merge branch 'temp' into 2.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
dcavins committed Dec 19, 2023
2 parents 04e15ce + 8968661 commit 56f42ff
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions includes/integration-groups.php
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ class BP_Docs_Group_Extension extends BP_Group_Extension {
* @since 1.0-beta
*/
public function __construct() {
global $bp;
$bp = buddypress();

$bp_docs_tab_name = bp_docs_get_group_tab_name();

Expand All @@ -1067,13 +1067,34 @@ public function __construct() {
$this->visibility = 'public';
$this->enable_nav_item = $this->enable_nav_item();

/**
* In BP 12, the current group is not yet known at __construct time
* because the URL parsing hasn't occurred yet. We use a callback that is
* accessed later.
*/
$this->show_tab_callback = array( $this, 'enable_nav_item' );

// Create some default settings if the create step is skipped
if ( apply_filters( 'bp_docs_force_enable_at_group_creation', false ) ) {
add_action( 'groups_created_group', array( &$this, 'enable_at_group_creation' ) );
}

// Backward compatibility for group-based Doc URLs
add_action( 'bp_actions', array( $this, 'url_backpat' ) );

$args = array(
'slug' => $this->slug,
'name' => $this->name ,
'nav_item_position' => $this->nav_item_position,
'access' => 'anyone',
'show_tab_callback' => $this->show_tab_callback,
'screens' => array(
'edit' => array(),
'create' => array(),
'admin' => array(),
),
);
parent::init( $args );
}

/**
Expand Down Expand Up @@ -1287,25 +1308,27 @@ function admin_markup() {
* @since 1.0-beta
*/
function enable_nav_item() {
global $bp;

$enable_nav_item = false;
$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 Expand Up @@ -1775,7 +1798,7 @@ function bp_docs_group_single_breadcrumb( $crumbs, $doc = null ) {
$group_crumbs = array(
sprintf(
'<a href="%s">%s</a>',
esc_url( bp_docs_get_group_docs_url() ),
esc_url( bp_docs_get_group_docs_url( $group ) ),
/* translators: group name */
sprintf( esc_html__( '%s&#8217;s Docs', 'buddypress-docs' ), esc_html( $group->name ) )
),
Expand Down

0 comments on commit 56f42ff

Please sign in to comment.