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

Set up component navigation.

Description

See also

Parameters

$main_nav

(Optional) See BP_Component::setup_nav() for description.

Default value: array()

$sub_nav

(Optional) See BP_Component::setup_nav() for description.

Default value: array()

Source

File: bp-media/classes/class-bp-media-component.php

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
 
    if ( bp_is_profile_media_support_enabled() ) {
 
        // Determine user to use.
        if ( bp_displayed_user_domain() ) {
            $user_domain = bp_displayed_user_domain();
        } elseif ( bp_loggedin_user_domain() ) {
            $user_domain = bp_loggedin_user_domain();
        } else {
            return;
        }
 
        $slug       = bp_get_media_slug();
        $media_link = trailingslashit( $user_domain . $slug );
 
        // Only grab count if we're on a user page and current user has access.
        if ( bp_is_user() ) {
            $count    = bp_media_get_total_media_count( bp_displayed_user_id() );
            $class    = ( 0 === $count ) ? 'no-count' : 'count';
            $nav_name = sprintf(
            /* translators: %s: total media count for the current user */
                __( 'Photos %s', 'buddyboss' ),
                sprintf(
                    '<span class="%s">%s</span>',
                    esc_attr( $class ),
                    bp_core_number_format( $count )
                )
            );
        } else {
            $nav_name = __( 'Photos', 'buddyboss' );
        }
 
        // Add 'Photos' to the main navigation.
        $main_nav = array(
            'name'                => $nav_name,
            'slug'                => $slug,
            'position'            => 80,
            'screen_function'     => 'media_screen',
            'default_subnav_slug' => 'my-media',
            'item_css_id'         => $this->id
        );
 
        // Add the subnav items to the profile.
        $sub_nav[] = array(
            'name'            => $nav_name,
            'slug'            => 'my-media',
            'parent_url'      => $media_link,
            'parent_slug'     => $slug,
            'screen_function' => 'media_screen',
            'position'        => 10,
            'item_css_id'     => 'media-my-media'
        );
 
        if ( bp_is_profile_albums_support_enabled() ) {
 
            // Add the subnav items to the profile.
            $sub_nav[] = array(
                'name'            => __( 'Albums', 'buddyboss' ),
                'slug'            => 'albums',
                'parent_url'      => $media_link,
                'parent_slug'     => $slug,
                'screen_function' => 'media_screen',
                'position'        => 10,
            );
        }
 
    }
 
    parent::setup_nav( $main_nav, $sub_nav );
 
}

Changelog

Changelog
Version Description
BuddyBoss 1.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.