BP_Nouveau_Customizer_Group_Nav::setup_nav()

Setup a temporary nav with only the needed parameters.


Source Source

File: bp-templates/bp-nouveau/includes/groups/classes.php

	protected function setup_nav() {
		$nav_items = array(
			'root'    => array(
				'name'                => __( 'Memberships', 'buddypress' ),
				'slug'                => $this->group->slug,
				'position'            => -1,
				/** This filter is documented in bp-groups/classes/class-bp-groups-component.php. */
				'default_subnav_slug' => apply_filters( 'bp_groups_default_extension', defined( 'BP_GROUPS_DEFAULT_EXTENSION' ) ? BP_GROUPS_DEFAULT_EXTENSION : 'home' ),
			),
			'home'    => array(
				'name'        => _x( 'Home', 'Group screen navigation title', 'buddypress' ),
				'slug'        => 'home',
				'parent_slug' => $this->group->slug,
				'position'    => 10,
			),
			'invites' => array(
				'name'        => _x( 'Invite', 'My Group screen nav', 'buddypress' ),
				'slug'        => 'send-invites',
				'parent_slug' => $this->group->slug,
				'position'    => 70,
			),
			'manage'  => array(
				'name'        => _x( 'Manage', 'My Group screen nav', 'buddypress' ),
				'slug'        => 'admin',
				'parent_slug' => $this->group->slug,
				'position'    => 1000,
			),
		);

		// Make sure only global front.php will be checked.
		add_filter( '_bp_nouveau_group_reset_front_template', array( $this, 'all_groups_fronts' ), 10, 1 );

		$front_template = bp_groups_get_front_template( $this->group );

		remove_filter( '_bp_nouveau_group_reset_front_template', array( $this, 'all_groups_fronts' ), 10, 1 );

		if ( ! $front_template ) {
			if ( bp_is_active( 'activity' ) ) {
				$nav_items['home']['name'] = _x( 'Home (Activity)', 'Group screen navigation title', 'buddypress' );
			} else {
				$nav_items['home']['name'] = _x( 'Home (Members)', 'Group screen navigation title', 'buddypress' );
			}
		} else {
			if ( bp_is_active( 'activity' ) ) {
				$nav_items['activity'] = array(
					'name'        => _x( 'Activity', 'My Group screen nav', 'buddypress' ),
					'slug'        => 'activity',
					'parent_slug' => $this->group->slug,
					'position'    => 11,
				);
			}

			// Add the members one
			$nav_items['members'] = array(
				'name'        => _x( 'Members', 'My Group screen nav', 'buddypress' ),
				'slug'        => 'members',
				'parent_slug' => $this->group->slug,
				'position'    => 60,
			);
		}

		// Required params
		$required_params = array(
			'slug'              => true,
			'name'              => true,
			'nav_item_position' => true,
		);

		// Now find nav items plugins are creating within their Group extensions!
		foreach ( get_declared_classes() as $class ) {
			if ( is_subclass_of( $class, 'BP_Group_Extension' ) ) {
				$extension = new $class;

				if ( ! empty( $extension->params ) && ! array_diff_key( $required_params, $extension->params ) ) {
					$nav_items[ $extension->params['slug'] ] = array(
						'name'        => $extension->params['name'],
						'slug'        => $extension->params['slug'],
						'parent_slug' => $this->group->slug,
						'position'    => $extension->params['nav_item_position'],
					);
				}
			}
		}

		// Now we got all, create the temporary nav.
		foreach ( $nav_items as $nav_item ) {
			$this->add_nav( $nav_item );
		}
	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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