bp_core_reset_subnav_items

Clear all subnav items from a specific nav item.

Description

bp_core_reset_subnav_items( (string) $parent_slug, (string) $component = 'members' ); 

Parameters (2)

0. $parent_slug (string)
The slug of the parent navigation item.
1. $component — Optional. (string) => 'members'
The component the navigation is attached to. Defaults to members..

Usage

  1. if ( !function_exists( 'bp_core_reset_subnav_items' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-core/bp-core-buddybar.php'; 
  3.  
  4. // The slug of the parent navigation item. 
  5. $parent_slug = ''; 
  6.  
  7. // The component the navigation is attached to. Defaults to 'members'. 
  8. $component = 'members'; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = bp_core_reset_subnav_items($parent_slug, $component); 
  12.  

Defined (1)

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

/bp-core/bp-core-buddybar.php  
  1. function bp_core_reset_subnav_items( $parent_slug, $component = 'members' ) { 
  2. $bp =buddypress); 
  3.  
  4. if ( ! isset( $bp->{$component}->nav ) ) { 
  5. return; 
  6.  
  7. $subnav_items = $bp->{$component}->nav->get_secondary( array( 'parent_slug' => $parent_slug ), false ); 
  8.  
  9. if ( ! $subnav_items ) { 
  10. return; 
  11.  
  12. foreach( $subnav_items as $subnav_item ) { 
  13. $bp->{$component}->nav->delete_nav( $subnav_item->slug, $parent_slug );