bp_core_remove_nav_item

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

Description

bp_core_remove_nav_item( (string) $slug, (null) $component = null ); 

Parameters (2)

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

Usage

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

Defined (1)

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

/bp-core/bp-core-buddybar.php  
  1. function bp_core_remove_nav_item( $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' => $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 ); 
  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. foreach ( $screen_functions as $screen_function ) { 
  25. // Remove our screen hook if screen function is callable. 
  26. if ( is_callable( $screen_function ) ) { 
  27. remove_action( 'bp_screens', $screen_function, 3 ); 
  28.  
  29. return true;