bp_nouveau_get_nav_classes()

Retrieve a space separated list of classes for the current nav item.


Return Return

(string) List of classes.


Source Source

File: bp-templates/bp-nouveau/includes/template-tags.php

	function bp_nouveau_get_nav_classes() {
		$bp_nouveau = bp_nouveau();
		$nav_item   = $bp_nouveau->current_nav_item;
		$classes    = array();

		if ( 'directory' === $bp_nouveau->displayed_nav ) {
			if ( ! empty( $nav_item->li_class ) ) {
				$classes = (array) $nav_item->li_class;
			}

			if ( bp_get_current_member_type() || ( bp_is_groups_directory() && bp_get_current_group_directory_type() ) ) {
				$classes[] = 'no-ajax';
			}
		} elseif ( 'groups' === $bp_nouveau->displayed_nav || 'personal' === $bp_nouveau->displayed_nav ) {
			$classes  = array( 'bp-' . $bp_nouveau->displayed_nav . '-tab' );
			$selected = bp_current_action();

			// User's primary nav
			if ( ! empty( $nav_item->primary ) ) {
				$selected = bp_current_component();

			// Group Admin Tabs.
			} elseif ( 'group_manage' === $bp_nouveau->object_nav ) {
				$selected = bp_action_variable( 0 );
				$classes  = array( 'bp-' . $bp_nouveau->displayed_nav . '-admin-tab' );

			// If we are here, it's the member's subnav
			} elseif ( 'personal' === $bp_nouveau->displayed_nav ) {
				$classes  = array( 'bp-' . $bp_nouveau->displayed_nav . '-sub-tab' );
			}

			if ( $nav_item->slug === $selected ) {
				$classes = array_merge( $classes, array( 'current', 'selected' ) );
			}
		}

		if ( ! empty( $classes ) ) {
			$classes = array_map( 'sanitize_html_class', $classes );
		}

		/**
		 * Filter to edit/add classes.
		 *
		 * NB: you can also directly add classes into the template parts.
		 *
		 * @since 3.0.0
		 *
		 * @param string $value    A space separated list of classes.
		 * @param array  $classes  The list of classes.
		 * @param object $nav_item The current nav item object.
		 * @param string $value    The current nav in use (eg: 'directory', 'groups', 'personal', etc..).
		 */
		$classes_list = apply_filters( 'bp_nouveau_get_classes', join( ' ', $classes ), $classes, $nav_item, $bp_nouveau->displayed_nav );
		if ( ! $classes_list ) {
			$classes_list = '';
		}

		return $classes_list;
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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