LLMS_Integration_Buddypress::add_profile_nav_items()

Add LLMS navigation items to the BuddyPress User Profile.


Return Return

(void)


Top ↑

Source Source

File: includes/integrations/class.llms.integration.buddypress.php

	public function add_profile_nav_items() {

		$profile_endpoints = $this->get_profile_endpoints();

		if ( empty( $profile_endpoints ) ) {
			return;
		}

		$bp_is_my_profile = bp_is_my_profile();
		$user_domain      = bp_loggedin_user_domain();
		$first_endpoint   = reset( $profile_endpoints );
		/**
		 * Filters the LifterLMS main nav item slug in the BuddyPress  profile menu.
		 *
		 * @since 6.3.0
		 *
		 * @param string $slug The LifterLMS main nav item slug in the BuddyPress profile menu.
		 */
		$main_nav_slug = apply_filters( 'llms_buddypress_main_nav_item_slug', _x( 'courses', 'BuddyPress profile main nav item slug', 'lifterlms' ) );
		$parent_url    = $user_domain . $main_nav_slug . '/';

		// Add the main nav menu.
		bp_core_new_nav_item(
			array(
				/**
				 * Filters the LifterLMS main nav item label in the BuddyPress profile menu.
				 *
				 * @since 6.3.0
				 *
				 * @param string $label The LifterLMS main nav item label in the BuddyPress profile menu.
				 */
				'name'                    => apply_filters( 'llms_buddypress_main_nav_item_label', _x( 'Courses', 'BuddyPress profile main nav item label', 'lifterlms' ) ),
				'slug'                    => $main_nav_slug,
				/**
				 * Filters the LifterLMS main nav item position in the BuddyPress profile menu.
				 *
				 * @since 6.3.0
				 *
				 * @param string $position The LifterLMS main nav item position in the BuddyPress profile menu.
				 */
				'position'                => apply_filters( 'llms_buddypress_main_nav_item_position', 20 ),
				'default_subnav_slug'     => $first_endpoint['endpoint'],
				'show_for_displayed_user' => false,
			)
		);

		foreach ( $profile_endpoints as $ep_key => $profile_endpoint ) {
			// Add sub nav item.
			bp_core_new_subnav_item(
				array(
					'name'            => $profile_endpoint['title'],
					'slug'            => $profile_endpoint['endpoint'],
					'parent_slug'     => $main_nav_slug,
					'parent_url'      => $parent_url,
					'screen_function' => function() use ( $ep_key, $profile_endpoint ) {
						$this->endpoint_content( $ep_key, $profile_endpoint['content'] );
					},
					'user_has_access' => $bp_is_my_profile,
				)
			);
		}

	}


Top ↑

Changelog Changelog

Changelog
Version Description
6.8.0 Revert adding nav items only on bp my profile. @link <a href="https://github.com/gocodebox/lifterlms/issues/2142">https://github.com/gocodebox/lifterlms/issues/2142</a>.
6.3.0 Display all registered dashboard tabs (enabled in the settings) automatically. Use bp_loggedin_user_domain() to determine the current user domain to be used in the profile nav item's links, in favor of relying on the global $bp.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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