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

177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
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.