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

(Optional)

Default value: array()

$item

(Optional)

Default value: false

Return

(array)

Source

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

236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
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.