BP_Settings_Component::setup_nav( array $main_nav = array(), array $sub_nav = array() )

Set up navigation.


Parameters Parameters

$main_nav

(array) (Optional) Array of main nav items.

Default value: array()

$sub_nav

(array) (Optional) Array of sub nav items.

Default value: array()


Source Source

File: bp-settings/classes/class-bp-settings-component.php

	public function setup_nav( $main_nav = array(), $sub_nav = array() ) {

		// Determine user to use.
		if ( bp_displayed_user_domain() ) {
			$user_domain = bp_displayed_user_domain();
		} elseif ( bp_loggedin_user_domain() ) {
			$user_domain = bp_loggedin_user_domain();
		} else {
			return;
		}

		$access        = bp_core_can_edit_settings();
		$slug          = bp_get_settings_slug();
		$settings_link = trailingslashit( $user_domain . $slug );

		// Add the settings navigation item.
		$main_nav = array(
			'name'                    => __( 'Settings', 'buddypress' ),
			'slug'                    => $slug,
			'position'                => 100,
			'show_for_displayed_user' => $access,
			'screen_function'         => 'bp_settings_screen_general',
			'default_subnav_slug'     => 'general'
		);

		// Add General Settings nav item.
		$sub_nav[] = array(
			'name'            => __( 'General', 'buddypress' ),
			'slug'            => 'general',
			'parent_url'      => $settings_link,
			'parent_slug'     => $slug,
			'screen_function' => 'bp_settings_screen_general',
			'position'        => 10,
			'user_has_access' => $access
		);

		// Add Email nav item. Formerly called 'Notifications', we
		// retain the old slug and function names for backward compat.
		$sub_nav[] = array(
			'name'            => __( 'Email', 'buddypress' ),
			'slug'            => 'notifications',
			'parent_url'      => $settings_link,
			'parent_slug'     => $slug,
			'screen_function' => 'bp_settings_screen_notification',
			'position'        => 20,
			'user_has_access' => $access
		);

		// Add Spam Account nav item.
		if ( bp_current_user_can( 'bp_moderate' ) ) {
			$sub_nav[] = array(
				'name'            => __( 'Capabilities', 'buddypress' ),
				'slug'            => 'capabilities',
				'parent_url'      => $settings_link,
				'parent_slug'     => $slug,
				'screen_function' => 'bp_settings_screen_capabilities',
				'position'        => 80,
				'user_has_access' => ! bp_is_my_profile()
			);
		}

		/**
		 * Filter whether the site should show the "Settings > Data" page.
		 *
		 * @since 4.0.0
		 *
		 * @param bool $show Defaults to true.
		 */
		$show_data_page = apply_filters( 'bp_settings_show_user_data_page', true );

		// Export Data - only available for WP 4.9.6+.
		if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
			$sub_nav[] = array(
				'name'            => __( 'Export Data', 'buddypress' ),
				'slug'            => 'data',
				'parent_url'      => $settings_link,
				'parent_slug'     => $slug,
				'screen_function' => 'bp_settings_screen_data',
				'position'        => 89,
				'user_has_access' => $access,
			);
		}

		// Add Delete Account nav item.
		if ( ( ! bp_disable_account_deletion() && bp_is_my_profile() ) || bp_current_user_can( 'delete_users' ) ) {
			$sub_nav[] = array(
				'name'            => __( 'Delete Account', 'buddypress' ),
				'slug'            => 'delete-account',
				'parent_url'      => $settings_link,
				'parent_slug'     => $slug,
				'screen_function' => 'bp_settings_screen_delete_account',
				'position'        => 90,
				'user_has_access' => ! is_super_admin( bp_displayed_user_id() )
			);
		}

		parent::setup_nav( $main_nav, $sub_nav );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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