BP_Friends_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-friends/classes/class-bp-friends-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_friends_slug();
		$friends_link = trailingslashit( $user_domain . $slug );

		// Add 'Connections' to the main navigation.
		$count = friends_get_total_friend_count();
		$class = ( 0 === $count ) ? 'no-count' : 'count';

		$main_nav_name = sprintf(
			/* translators: %s: Connection count for the current user */
			__( 'Connections %s', 'buddyboss' ),
			sprintf(
				'<span class="%s">%s</span>',
				esc_attr( $class ),
				bp_core_number_format( $count )
			)
		);

		$main_nav = array(
			'name'                => $main_nav_name,
			'slug'                => $slug,
			'position'            => 60,
			'screen_function'     => 'friends_screen_my_friends',
			'default_subnav_slug' => 'my-friends',
			'item_css_id'         => $this->id
		);

		// Add the subnav items to the friends nav item.
		$sub_nav[] = array(
			'name'            => ! bp_is_my_profile() ? __( 'All Connections', 'buddyboss' ) : __( 'My Connections', 'buddyboss' ),
			'slug'            => 'my-friends',
			'parent_url'      => $friends_link,
			'parent_slug'     => $slug,
			'screen_function' => 'friends_screen_my_friends',
			'position'        => 10,
			'item_css_id'     => 'friends-my-friends'
		);

		if ( bp_get_mutual_friendships() ) {
			$sub_nav[] = array(
				'name'            => __( 'Mutual Connections', 'buddyboss' ),
				'slug'            => 'mutual',
				'parent_url'      => $friends_link,
				'parent_slug'     => $slug,
				'screen_function' => 'friends_screen_mutual_friends',
				'position'        => 20,
				'user_has_access' => ! bp_is_my_profile() && bp_loggedin_user_id()
			);
		}

		$sub_nav[] = array(
			'name'            => __( 'Requests', 'buddyboss' ),
			'slug'            => 'requests',
			'parent_url'      => $friends_link,
			'parent_slug'     => $slug,
			'screen_function' => 'friends_screen_requests',
			'position'        => 30,
			'user_has_access' => $access
		);

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

Changelog

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.