BP_Component::setup_nav( array $main_nav = array(), array $sub_nav = array() )
Set up component navigation.
Description Description
See also See also
- bp_core_new_nav_item(): For a description of the $main_nav parameter formatting.
- bp_core_new_subnav_item(): For a description of how each item in the $sub_nav parameter array should be formatted.
Parameters Parameters
- $main_nav
-
(Optional) Passed directly to bp_core_new_nav_item(). See that function for a description.
Default value: array()
- $sub_nav
-
(Optional) Multidimensional array, each item in which is passed to bp_core_new_subnav_item(). See that function for a description.
Default value: array()
Source Source
File: bp-core/classes/class-bp-component.php
public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
// No sub nav items without a main nav item.
if ( !empty( $main_nav ) ) {
// Always set the component ID.
$main_nav['component_id'] = $this->id;
bp_core_new_nav_item( $main_nav, 'members' );
// Sub nav items are not required.
if ( !empty( $sub_nav ) ) {
foreach( (array) $sub_nav as $nav ) {
bp_core_new_subnav_item( $nav, 'members' );
}
}
}
/**
* Fires at the end of the setup_nav method inside BP_Component.
*
* This is a dynamic hook that is based on the component string ID.
*
* @since 1.5.0
*/
do_action( 'bp_' . $this->id . '_setup_nav' );
}
Changelog Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |