BP_Core_Nav::add_nav( array $args )

Adds a new nav item.

Description

Parameters

$args

(Required) The nav item's arguments.

Return

(BP_Core_Nav_Item)

Source

File: bp-core/classes/class-bp-core-nav.php

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
public function add_nav( $args ) {
    if ( empty( $args['slug'] ) ) {
        return false;
    }
 
    // We have a child and the parent exists.
    if ( ! empty( $args['parent_slug'] ) ) {
        $slug              = $args['parent_slug'] . '/' . $args['slug'];
        $args['secondary'] = true;
 
    // This is a parent.
    } else {
        $slug            = $args['slug'];
        $args['primary'] = true;
    }
 
    // Add to the nav.
    $this->nav[ $this->object_id ][ $slug ] = new BP_Core_Nav_Item( $args );
 
    return $this->nav[ $this->object_id ][ $slug ];
}

Changelog

Changelog
Version Description
BuddyPress 2.6.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.