BP_Forums_Component::setup_nav( $main_nav = array(),  $sub_nav = array() )

Setup BuddyBar navigation

Description

Source

File: bp-forums/classes/class-bp-forums-component.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'                => __( 'Forums', 'buddyboss' ),
            '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'            => __( 'My Discussions', 'buddyboss' ),
            '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'            => __( 'My Replies', 'buddyboss' ),
            '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'
        );

        // Favorite topics
        $sub_nav[] = array(
            'name'            => __( 'My Favorites', 'buddyboss' ),
            'slug'            => bbp_get_user_favorites_slug(),
            'parent_url'      => $forums_link,
            'parent_slug'     => $this->slug,
            'screen_function' => 'bbp_member_forums_screen_favorites',
            'position'        => 60,
            'item_css_id'     => 'favorites'
        );

        // Subscribed topics (my profile only)
        if ( bp_is_my_profile() ) {
            $sub_nav[] = array(
                'name'            => __( 'Subscriptions', 'buddyboss' ),
                'slug'            => bbp_get_user_subscriptions_slug(),
                'parent_url'      => $forums_link,
                'parent_slug'     => $this->slug,
                'screen_function' => 'bbp_member_forums_screen_subscriptions',
                'position'        => 60,
                'item_css_id'     => 'subscriptions'
            );
        }

        parent::setup_nav( $main_nav, $sub_nav );
    }

Changelog

Changelog
Version Description
bbPress (r3552) 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.