bp_core_remove_subnav_item

Deletes an item from the secondary navigation of the specified component.

Description

bp_core_remove_subnav_item( (string) $parent_slug, (string) $slug, (null) $component = null ); 

Parameters (3)

0. $parent_slug (string)
The slug of the primary navigation item.
1. $slug (string)
The slug of the secondary item to be removed.
2. $component — Optional. (null) => null
The component the navigation is attached to. Defaults to members..

Usage

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

Defined (1)

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

/bp-core/bp-core-buddybar.php  
  1. function bp_core_remove_subnav_item( $parent_slug, $slug, $component = null ) { 
  2. $bp =buddypress); 
  3.  
  4. // Backward compatibility for removing group nav items using the group slug as `$parent_slug`. 
  5. if ( ! $component && bp_is_active( 'groups' ) && isset( $bp->groups->nav ) ) { 
  6. if ( $bp->groups->nav->get_primary( array( 'slug' => $parent_slug ) ) ) { 
  7. $component = 'groups'; 
  8.  
  9. if ( ! $component ) { 
  10. $component = 'members'; 
  11.  
  12. if ( ! isset( $bp->{$component}->nav ) ) { 
  13. return false; 
  14.  
  15. $screen_functions = $bp->{$component}->nav->delete_nav( $slug, $parent_slug ); 
  16.  
  17. // Reset backcompat nav items so that subsequent references will be correct. 
  18. $bp->bp_nav->reset(); 
  19. $bp->bp_options_nav->reset(); 
  20.  
  21. if ( ! is_array( $screen_functions ) ) { 
  22. return false; 
  23.  
  24. $screen_function = reset( $screen_functions ); 
  25.  
  26. // Remove our screen hook if screen function is callable. 
  27. if ( is_callable( $screen_function ) ) { 
  28. remove_action( 'bp_screens', $screen_function, 3 ); 
  29.  
  30. return true;