BP_Settings_Component::setup_admin_bar( array $wp_admin_nav = array() )

Set up the Toolbar.


Parameters Parameters

$wp_admin_nav

(array) (Optional) Array of Admin Bar items.

Default value: array()


Source Source

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

	public function setup_admin_bar( $wp_admin_nav = array() ) {

		// Menus for logged in user.
		if ( is_user_logged_in() ) {

			// Setup the logged in user variables.
			$settings_link = trailingslashit( bp_loggedin_user_domain() . bp_get_settings_slug() );

			// Add main Settings menu.
			$wp_admin_nav[] = array(
				'parent' => buddypress()->my_account_menu_id,
				'id'     => 'my-account-' . $this->id,
				'title'  => __( 'Settings', 'buddypress' ),
				'href'   => $settings_link
			);

			// General Account.
			$wp_admin_nav[] = array(
				'parent'   => 'my-account-' . $this->id,
				'id'       => 'my-account-' . $this->id . '-general',
				'title'    => __( 'General', 'buddypress' ),
				'href'     => $settings_link,
				'position' => 10
			);

			// Notifications - only add the tab when there is something to display there.
			if ( has_action( 'bp_notification_settings' ) ) {
				$wp_admin_nav[] = array(
					'parent'   => 'my-account-' . $this->id,
					'id'       => 'my-account-' . $this->id . '-notifications',
					'title'    => __( 'Email', 'buddypress' ),
					'href'     => trailingslashit( $settings_link . 'notifications' ),
					'position' => 20
				);
			}

			/** This filter is documented in bp-settings/classes/class-bp-settings-component.php */
			$show_data_page = apply_filters( 'bp_settings_show_user_data_page', true );

			// Export Data.
			if ( true === $show_data_page && bp_is_running_wp( '4.9.6' ) ) {
				$wp_admin_nav[] = array(
					'parent'   => 'my-account-' . $this->id,
					'id'       => 'my-account-' . $this->id . '-data',
					'title'    => __( 'Export Data', 'buddypress' ),
					'href'     => trailingslashit( $settings_link . 'data' ),
					'position' => 89,
				);
			}

			// Delete Account
			if ( !bp_current_user_can( 'bp_moderate' ) && ! bp_core_get_root_option( 'bp-disable-account-deletion' ) ) {
				$wp_admin_nav[] = array(
					'parent'   => 'my-account-' . $this->id,
					'id'       => 'my-account-' . $this->id . '-delete-account',
					'title'    => __( 'Delete Account', 'buddypress' ),
					'href'     => trailingslashit( $settings_link . 'delete-account' ),
					'position' => 90
				);
			}
		}

		parent::setup_admin_bar( $wp_admin_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.