bp_core_remove_subnav_item( string $parent_slug, string $slug, string|null $component = null )
Deletes an item from the secondary navigation of the specified component.
Description
Parameters
- $parent_slug
-
(Required) The slug of the primary navigation item.
- $slug
-
(Required) The slug of the secondary item to be removed.
- $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
function bp_core_remove_subnav_item( $parent_slug, $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' => $parent_slug ) ) ) { $component = 'groups'; } } if ( ! $component ) { $component = 'members'; } if ( ! isset( $bp->{$component}->nav ) ) { return false; } $screen_functions = $bp->{$component}->nav->delete_nav( $slug, $parent_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; } $screen_function = reset( $screen_functions ); // 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.