BP_XProfile_Component::setup_nav( array $main_nav = array(), array $sub_nav = array() )
Set up navigation.
Description Description
Parameters Parameters
- $main_nav
-
(Optional) Array of main nav items to set up.
Default value: array()
- $sub_nav
-
(Optional) Array of sub nav items to set up.
Default value: array()
Source Source
File: bp-xprofile/classes/class-bp-xprofile-component.php
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
// 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;
}
$access = bp_core_can_edit_settings();
$slug = bp_get_profile_slug();
$profile_link = trailingslashit( $user_domain . $slug );
// Add 'Profile' to the main navigation.
$main_nav = array(
'name' => _x( 'Profile', 'Profile header menu', 'buddypress' ),
'slug' => $slug,
'position' => 20,
'screen_function' => 'xprofile_screen_display_profile',
'default_subnav_slug' => 'public',
'item_css_id' => $this->id
);
// Add the subnav items to the profile.
$sub_nav[] = array(
'name' => _x( 'View', 'Profile header sub menu', 'buddypress' ),
'slug' => 'public',
'parent_url' => $profile_link,
'parent_slug' => $slug,
'screen_function' => 'xprofile_screen_display_profile',
'position' => 10
);
// Edit Profile.
$sub_nav[] = array(
'name' => _x( 'Edit','Profile header sub menu', 'buddypress' ),
'slug' => 'edit',
'parent_url' => $profile_link,
'parent_slug' => $slug,
'screen_function' => 'xprofile_screen_edit_profile',
'position' => 20,
'user_has_access' => $access
);
// Change Avatar.
if ( buddypress()->avatar->show_avatars ) {
$sub_nav[] = array(
'name' => _x( 'Change Profile Photo', 'Profile header sub menu', 'buddypress' ),
'slug' => 'change-avatar',
'parent_url' => $profile_link,
'parent_slug' => $slug,
'screen_function' => 'xprofile_screen_change_avatar',
'position' => 30,
'user_has_access' => $access
);
}
// Change Cover image.
if ( bp_displayed_user_use_cover_image_header() ) {
$sub_nav[] = array(
'name' => _x( 'Change Cover Image', 'Profile header sub menu', 'buddypress' ),
'slug' => 'change-cover-image',
'parent_url' => $profile_link,
'parent_slug' => $slug,
'screen_function' => 'xprofile_screen_change_cover_image',
'position' => 40,
'user_has_access' => $access
);
}
// The Settings > Profile nav item can only be set up after
// the Settings component has run its own nav routine.
add_action( 'bp_settings_setup_nav', array( $this, 'setup_settings_nav' ) );
parent::setup_nav( $main_nav, $sub_nav );
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |