BP_Nouveau::bbp_set_forum_selected_menu_class( array $classes = array(), bool $item = false )

Set the Forums to selected in menu items

Description

Parameters

$classes

(array) (Optional)

Default value: array()

$item

(bool) (Optional)

Default value: false

Return

(array)

Source

File: bp-templates/bp-nouveau/buddypress-functions.php

	public function bbp_set_forum_selected_menu_class( $classes = array(), $item = false ) {

		// Protocol
		$url = ( isset( $_SERVER['HTTPS'] ) && $_SERVER['HTTPS'] === 'on' ? 'https' : 'http') . '://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];

		// Get current URL
		$current_url = trailingslashit( $url );

		// Get homepage URL
		$homepage_url = trailingslashit( get_bloginfo( 'url' ) );

		// Exclude 404 and homepage
		if( is_404() or $item->url == $homepage_url )
			return $classes;

		if ( 'forum' === get_post_type() || 'topic' === get_post_type() )
		{
			unset($classes[array_search('current_page_parent',$classes)]);
			if ( isset($item->url) )
				if ( strstr( $current_url, $item->url) )
					$classes[] = 'current-menu-item';
		}

		return $classes;
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.