BBP_Forums_Component::setup_admin_bar( $wp_admin_nav = array() )

Set up the admin bar


Description Description


Source Source

File: includes/extend/buddypress/loader.php

	public function setup_admin_bar( $wp_admin_nav = array() ) {

		// Menus for logged in user
		if ( is_user_logged_in() ) {

			// If BuddyPress is network activated and bbPress is
			// not activated on a the root blog but on any child one
			if ( ! bp_is_root_blog() ) {
				$user_id               = bbp_get_current_user_id();
				$my_account_link       = bbp_get_user_profile_url( $user_id );
				$my_topics_link        = bbp_get_user_topics_created_url( $user_id );
				$my_replies_link       = bbp_get_user_replies_created_url( $user_id );
				$my_engagements_link   = bbp_get_user_engagements_url( $user_id );
				$my_favorites_link     = bbp_get_favorites_permalink( $user_id );
				$my_subscriptions_link = bbp_get_subscriptions_permalink( $user_id );
			} else {

				// Setup the logged in user variables
				$user_domain = bp_loggedin_user_domain();
				$forums_link = trailingslashit( $user_domain . $this->slug );

				$my_account_link       = trailingslashit( $forums_link );
				$my_topics_link        = trailingslashit( $forums_link . bbp_get_topic_archive_slug() );
				$my_replies_link       = trailingslashit( $forums_link . bbp_get_reply_archive_slug() );
				$my_engagements_link   = trailingslashit( $forums_link . bbp_get_user_engagements_slug() );
				$my_favorites_link     = trailingslashit( $forums_link . bbp_get_user_favorites_slug() );
				$my_subscriptions_link = trailingslashit( $forums_link . bbp_get_user_subscriptions_slug() );
			}

			// Add the "My Account" sub menus
			$wp_admin_nav[] = array(
				'parent' => buddypress()->my_account_menu_id,
				'id'     => 'my-account-' . $this->id,
				'title'  => esc_html__( 'Forums', 'bbpress' ),
				'href'   => $my_account_link
			);

			// Topics
			$wp_admin_nav[] = array(
				'parent' => 'my-account-' . $this->id,
				'id'     => 'my-account-' . $this->id . '-topics',
				'title'  => esc_html__( 'Topics Started', 'bbpress' ),
				'href'   => $my_topics_link
			);

			// Replies
			$wp_admin_nav[] = array(
				'parent' => 'my-account-' . $this->id,
				'id'     => 'my-account-' . $this->id . '-replies',
				'title'  => esc_html__( 'Replies Created', 'bbpress' ),
				'href'   => $my_replies_link
			);

			// Engagements
			if ( bbp_is_engagements_active() ) {
				$wp_admin_nav[] = array(
					'parent' => 'my-account-' . $this->id,
					'id'     => 'my-account-' . $this->id . '-engagements',
					'title'  => esc_html__( 'Engagements', 'bbpress' ),
					'href'   => $my_engagements_link
				);
			}

			// Favorites
			if ( bbp_is_favorites_active() ) {
				$wp_admin_nav[] = array(
					'parent' => 'my-account-' . $this->id,
					'id'     => 'my-account-' . $this->id . '-favorites',
					'title'  => esc_html__( 'Favorite Topics', 'bbpress' ),
					'href'   => $my_favorites_link
				);
			}

			// Subscriptions
			if ( bbp_is_subscriptions_active() ) {
				$wp_admin_nav[] = array(
					'parent' => 'my-account-' . $this->id,
					'id'     => 'my-account-' . $this->id . '-subscriptions',
					'title'  => esc_html__( 'Subscribed Topics', 'bbpress' ),
					'href'   => $my_subscriptions_link
				);
			}
		}

		parent::setup_admin_bar( $wp_admin_nav );
	}

Top ↑

Changelog Changelog

Changelog
Version Description
2.1.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.