bp_core_remove_nav_item( string $slug, string|null $component = null )
Deletes an item from the primary navigation of the specified component.
Description
Parameters
- $slug
-
(Required) The slug of the primary navigation item.
- $component
-
(Optional) The component the navigation is attached to. Defaults to 'members'.
Default value: null
Return
(bool) Returns false on failure, True on success.
Source
File: bp-core/bp-core-buddybar.php
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 | function bp_core_remove_nav_item( $slug , $component = null ) { $bp = buddypress(); // Backward compatibility for removing group nav items using the group slug as `$parent_slug`. if ( ! $component && bp_is_active( 'groups' ) && isset( $bp ->groups->nav ) ) { if ( $bp ->groups->nav->get_primary( array ( 'slug' => $slug ) ) ) { $component = 'groups' ; } } if ( ! $component ) { $component = 'members' ; } if ( ! isset( $bp ->{ $component }->nav ) ) { return false; } $screen_functions = $bp ->{ $component }->nav->delete_nav( $slug ); // Reset backcompat nav items so that subsequent references will be correct. $bp ->bp_nav->reset(); $bp ->bp_options_nav->reset(); if ( ! is_array ( $screen_functions ) ) { return false; } foreach ( $screen_functions as $screen_function ) { // Remove our screen hook if screen function is callable. if ( is_callable ( $screen_function ) ) { remove_action( 'bp_screens' , $screen_function , 3 ); } } return true; } |
Changelog
Version | Description |
---|---|
BuddyPress 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.