BP_Members_Component::setup_nav( array $main_nav = array(), array $sub_nav = array() )
Set up fall-back component navigation if XProfile is inactive.
Description
See also
- BP_Component::setup_nav(): for a description of arguments.
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-members/classes/class-bp-members-component.php
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 | public function setup_nav( $main_nav = array (), $sub_nav = array () ) { // Don't set up navigation if there's no member. if ( ! is_user_logged_in() && ! bp_is_user() ) { return ; } $is_xprofile_active = bp_is_active( 'xprofile' ); // Bail if XProfile component is active and there's no custom front page for the user. if ( ! bp_displayed_user_has_front_template() && $is_xprofile_active ) { return ; } // 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 ; } // Set slug to profile in case the xProfile component is not active $slug = bp_get_profile_slug(); // Defaults to empty navs $this ->main_nav = array (); $this ->sub_nav = array (); if ( ! $is_xprofile_active ) { $this ->main_nav = array ( 'name' => __( 'Profile' , 'buddyboss' ), 'slug' => $slug , 'position' => 10, 'screen_function' => 'bp_members_screen_display_profile' , 'default_subnav_slug' => 'public' , 'item_css_id' => buddypress()->profile->id ); } /** * Setup the subnav items for the member profile. * * This is required in case there's a custom front or in case the xprofile component * is not active. */ $this ->sub_nav = array ( 'name' => __( 'View' , 'buddyboss' ), 'slug' => 'public' , 'parent_url' => trailingslashit( $user_domain . $slug ), 'parent_slug' => $slug , 'screen_function' => 'bp_members_screen_display_profile' , 'position' => 10 ); /** * If there's a front template the members component nav * will be there to display the user's front page. */ if ( bp_displayed_user_has_front_template() ) { $main_nav = array ( 'name' => __( 'Dashboard' , 'buddyboss' ), 'slug' => 'front' , 'position' => 5, 'screen_function' => 'bp_members_screen_display_profile' , 'default_subnav_slug' => 'public' , ); // We need a dummy subnav for the front page to load. $front_subnav = $this ->sub_nav; $front_subnav [ 'parent_slug' ] = 'front' ; // In case the subnav is displayed in the front template $front_subnav [ 'parent_url' ] = trailingslashit( $user_domain . 'front' ); // Set the subnav $sub_nav [] = $front_subnav ; /** * If the profile component is not active, we need to create a new * nav to display the WordPress profile. */ if ( ! $is_xprofile_active ) { add_action( 'bp_members_setup_nav' , array ( $this , 'setup_profile_nav' ) ); } /** * If there's no front template and xProfile is not active, the members * component nav will be there to display the WordPress profile */ } else { $main_nav = $this ->main_nav; $sub_nav [] = $this ->sub_nav; } parent::setup_nav( $main_nav , $sub_nav ); } |
Changelog
Version | Description |
---|---|
BuddyPress 1.5.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.