BBP_Forums_Component::setup_nav( $main_nav = array(), $sub_nav = array() )
Setup BuddyBar navigation
Description Description
Source Source
File: includes/extend/buddypress/loader.php
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
// Stop if there is no user displayed or logged in
if ( ! is_user_logged_in() && !bp_displayed_user_id() ) {
return;
}
// Define local variable(s)
$user_domain = '';
// Add 'Forums' to the main navigation
$main_nav = array(
'name' => esc_html__( 'Forums', 'bbpress' ),
'slug' => $this->slug,
'position' => 80,
'screen_function' => 'bbp_member_forums_screen_topics',
'default_subnav_slug' => bbp_get_topic_archive_slug(),
'item_css_id' => $this->id
);
// Determine user to use
if ( bp_displayed_user_id() ) {
$user_domain = bp_displayed_user_domain();
} elseif ( bp_loggedin_user_domain() ) {
$user_domain = bp_loggedin_user_domain();
} else {
return;
}
// User link
$forums_link = trailingslashit( $user_domain . $this->slug );
// Topics started
$sub_nav[] = array(
'name' => esc_html__( 'Topics Started', 'bbpress' ),
'slug' => bbp_get_topic_archive_slug(),
'parent_url' => $forums_link,
'parent_slug' => $this->slug,
'screen_function' => 'bbp_member_forums_screen_topics',
'position' => 20,
'item_css_id' => 'topics'
);
// Replies to topics
$sub_nav[] = array(
'name' => esc_html__( 'Replies Created', 'bbpress' ),
'slug' => bbp_get_reply_archive_slug(),
'parent_url' => $forums_link,
'parent_slug' => $this->slug,
'screen_function' => 'bbp_member_forums_screen_replies',
'position' => 40,
'item_css_id' => 'replies'
);
// Engagements
if ( bbp_is_engagements_active() ) {
$sub_nav[] = array(
'name' => esc_html__( 'Engagements', 'bbpress' ),
'slug' => bbp_get_user_engagements_slug(),
'parent_url' => $forums_link,
'parent_slug' => $this->slug,
'screen_function' => 'bbp_member_forums_screen_engagements',
'position' => 60,
'item_css_id' => 'engagements'
);
}
// Favorite topics
if ( bbp_is_favorites_active() ){
$sub_nav[] = array(
'name' => esc_html__( 'Favorites', 'bbpress' ),
'slug' => bbp_get_user_favorites_slug(),
'parent_url' => $forums_link,
'parent_slug' => $this->slug,
'screen_function' => 'bbp_member_forums_screen_favorites',
'position' => 80,
'item_css_id' => 'favorites'
);
}
// Subscribed topics (my profile only)
if ( bp_is_my_profile() && bbp_is_subscriptions_active() ) {
$sub_nav[] = array(
'name' => esc_html__( 'Subscriptions', 'bbpress' ),
'slug' => bbp_get_user_subscriptions_slug(),
'parent_url' => $forums_link,
'parent_slug' => $this->slug,
'screen_function' => 'bbp_member_forums_screen_subscriptions',
'position' => 100,
'item_css_id' => 'subscriptions'
);
}
parent::setup_nav( $main_nav, $sub_nav );
}
Changelog Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |