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.


Parameters Parameters

$parent_slug

(string) (Required) The slug of the primary navigation item.

$slug

(string) (Required) The slug of the secondary item to be removed.

$component

(string|null) (Optional) The component the navigation is attached to. Defaults to 'members'.

Default value: null


Top ↑

Return Return

(bool) Returns false on failure, True on success.


Source 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;
}


Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced the $component parameter.
1.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.