BP_Nouveau_Customizer_Group_Nav::setup_nav()
Setup a temporary nav with only the needed parameters.
Description
Source
File: bp-templates/bp-nouveau/includes/groups/classes.php
protected function setup_nav() {
$nav_items = array(
'root' => array(
'name' => __( 'My Groups', 'buddyboss' ),
'slug' => $this->group->slug,
'position' => -1,
/** This filter is documented in bp-groups/classes/class-bp-groups-component.php. */
'default_subnav_slug' => apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ),
),
'members' => array(
'name' => __( 'Members', 'buddyboss' ),
'slug' => 'members',
'parent_slug' => $this->group->slug,
'position' => 10,
),
'invites' => array(
'name' => __( 'Send Invites', 'buddyboss' ),
'slug' => 'send-invites',
'parent_slug' => $this->group->slug,
'position' => 70,
),
'manage' => array(
'name' => __( 'Manage', 'buddyboss' ),
'slug' => 'admin',
'parent_slug' => $this->group->slug,
'position' => 1000,
),
);
if ( bp_is_active( 'forums' ) && function_exists( 'bbp_is_group_forums_active' ) ) {
if ( bbp_is_group_forums_active() ) {
$nav_items['forum'] = array(
'name' => __( 'Discussions', 'buddyboss' ),
'slug' => get_option( '_bbp_forum_slug', 'forum' ),
'parent_slug' => $this->group->slug,
'position' => 30,
);
}
}
if ( bp_enable_group_hierarchies() ) {
$nav_items['subgroups'] = array(
'name' => __( 'Subgroups', 'buddyboss' ),
'slug' => 'subgroups',
'parent_slug' => $this->group->slug,
'position' => 30,
);
}
if ( function_exists( 'bp_ld_sync' ) ) {
$va = bp_ld_sync( 'settings' )->get( 'buddypress.enabled', true );
if ( '1' === $va ) {
$nav_items['courses'] = array(
'name' => __( 'Courses', 'buddyboss' ),
'slug' => 'courses',
'parent_slug' => $this->group->slug,
'position' => 40,
);
}
}
if ( function_exists( 'bp_ld_sync' ) ) {
$va = bp_ld_sync( 'settings' )->get( 'reports.enabled', true );
if ( '1' === $va ) {
$nav_items['reports'] = array(
'name' => __( 'Reports', 'buddyboss' ),
'slug' => 'reports',
'parent_slug' => $this->group->slug,
'position' => 40,
);
}
}
if ( bp_is_active( 'activity' ) ) {
$nav_items['activity'] = array(
'name' => __( 'Feed', 'buddyboss' ),
'slug' => 'activity',
'parent_slug' => $this->group->slug,
'position' => 20,
);
}
// Required params
$required_params = array(
'slug' => true,
'name' => true,
'nav_item_position' => true,
);
// Now find nav items plugins are creating within their Group extensions!
foreach ( get_declared_classes() as $class ) {
if ( is_subclass_of( $class, 'BP_Group_Extension' ) ) {
$extension = new $class;
if ( ! empty( $extension->params ) && ! array_diff_key( $required_params, $extension->params ) ) {
$nav_items[ $extension->params['slug'] ] = array(
'name' => $extension->params['name'],
'slug' => $extension->params['slug'],
'parent_slug' => $this->group->slug,
'position' => $extension->params['nav_item_position'],
);
}
}
}
// Now we got all, create the temporary nav.
foreach ( $nav_items as $nav_item ) {
$this->add_nav( $nav_item );
}
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 3.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.