BP_Core_BP_Options_Nav_BackCompat::offsetGet( mixed $offset )

Get a value of the nav array at the specified offset.

Description

Parameters

$offset

(mixed) (Required) Array offset.

Return

(BP_Core_BP_Nav_BackCompat)

Source

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

	public function offsetGet( $offset ) {
		_doing_it_wrong(
			'bp_nav',
			__( 'These globals should not be used directly and are deprecated. Please use the BuddyPress nav functions instead.', 'buddyboss' ),
			'2.6.0'
		);

		if ( empty( $this->backcompat_nav[ $offset ] ) ) {
			$nav = $this->get_nav( $offset );
			if ( $nav ) {
				$subnavs = $this->get_component_nav( $offset )->get_secondary( array( 'parent_slug' => $offset ) );
				$subnav_keyed = array();
				if ( $subnavs ) {
					foreach ( $subnavs as $subnav ) {
						$subnav_keyed[ $subnav->slug ] = (array) $subnav;
					}
				}

				$subnav_object = new self( $subnav_keyed );
				$subnav_object->set_component( $this->get_component() );
				$subnav_object->set_parent_slug( $offset );

				$this->backcompat_nav[ $offset ] = $subnav_object;
			}
		}

		if ( isset( $this->backcompat_nav[ $offset ] ) ) {
			return $this->backcompat_nav[ $offset ];
		}

		return false;
	}

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.