bp_core_menu_highlight_nav_menu_item

Adds current page CSS classes to the parent BP page in a WP Nav Menu.

Description

(array) bp_core_menu_highlight_nav_menu_item( (array) $retval, (WP_Post) $item ); 

When is used, this function helps to highlight the current BP parent page during nav menu generation.

Returns (array)

Parameters (2)

0. $retval (array)
CSS classes for the current nav menu item in the menu.
1. $item (WP_Post)
The properties for the current nav menu item.

Usage

  1. if ( !function_exists( 'bp_core_menu_highlight_nav_menu_item' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-filters.php'; 
  3.  
  4. // CSS classes for the current nav menu item in the menu. 
  5. $retval = array(); 
  6.  
  7. // The properties for the current nav menu item. 
  8. $item = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_menu_highlight_nav_menu_item($retval, $item); 
  12.  

Defined (1)

The function is defined in the following location(s).

/bp-core/bp-core-filters.php  
  1. function bp_core_menu_highlight_nav_menu_item( $retval, $item ) { 
  2. // If we're not on a BP page or if the current nav item is not a page, stop! 
  3. if ( ! is_buddypress() || 'page' !== $item->object ) { 
  4. return $retval; 
  5.  
  6. // Get the WP page. 
  7. $page = get_post( $item->object_id ); 
  8.  
  9. // See if we should add our highlight CSS classes for the page. 
  10. $retval = bp_core_menu_highlight_parent_page( $retval, $page ); 
  11.  
  12. return $retval;