BP_Admin::admin_menus()

Register site- or network-admin nav menu elements.

Description

Contextually hooked to site or network-admin depending on current configuration.

Source

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

	public function admin_menus() {

		global $menu;

		// Bail if user cannot moderate.
		if ( ! bp_current_user_can( 'manage_options' ) ) {
			return;
		}

		// Add BuddyBoss Menu separator above the BuddyBoss and below the BuddyBoss
		if ( bp_current_user_can( 'manage_options' ) ) {
			$menu[] = array( '', 'read', 'separator-buddyboss', '', 'wp-menu-separator buddyboss' ); // WPCS: override ok.
			$menu[] = array( '', 'read', 'separator-plugins', '', 'wp-menu-separator plugins' ); // WPCS: override ok.
		}

		$hooks = array();

		// Changed in BP 1.6 . See bp_core_admin_backpat_menu().
		$hooks[] = add_menu_page(
			__( 'BuddyBoss', 'buddyboss' ),
			__( 'BuddyBoss', 'buddyboss' ),
			$this->capability,
			$this->settings_page,
			'bp_core_admin_backpat_menu',
			buddypress()->plugin_url . 'bp-core/images/admin/icons/logos/buddyboss.svg',
			62
		);

		$hooks[] = add_submenu_page(
			'bp-general-settings',
			__( 'BuddyBoss Help', 'buddyboss' ),
			__( 'Help', 'buddyboss' ),
			$this->capability,
			'bp-general-settings',
			'bp_core_admin_backpat_page'
		);

		// Add the Separator.
//		$hooks[] = add_submenu_page(
//			$this->settings_page,
//			__( '', 'buddyboss' ),
//			__( '', 'buddyboss' ),
//			$this->capability,
//			'bp-plugin-separator-notice',
//			''
//		);

		// Add the option pages.
		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'BuddyBoss Components', 'buddyboss' ),
			__( 'Components', 'buddyboss' ),
			$this->capability,
			'bp-components',
			'bp_core_admin_components_settings'
		);

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'Pages', 'buddyboss' ),
			__( 'Pages', 'buddyboss' ),
			$this->capability,
			'bp-pages',
			'bp_core_admin_pages_settings'
		);

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'BuddyBoss Settings', 'buddyboss' ),
			__( 'Settings', 'buddyboss' ),
			$this->capability,
			'bp-settings',
			'bp_core_admin_settings'
		);

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'Plugin Integrations', 'buddyboss' ),
			__( 'Integrations', 'buddyboss' ),
			$this->capability,
			'bp-integrations',
			'bp_core_admin_integrations'
		);

		// Credits.
		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'Credits', 'buddyboss' ),
			__( 'Credits', 'buddyboss' ),
			$this->capability,
			'bp-credits',
			array( $this, 'bp_credits_screen' )
		);



		// For consistency with non-Multisite, we add a Tools menu in
		// the Network Admin as a home for our Tools panel.
		if ( is_multisite() && bp_core_do_network_admin() ) {
			$tools_parent = 'network-tools';

			$hooks[] = add_menu_page(
				__( 'Tools', 'buddyboss' ),
				__( 'Tools', 'buddyboss' ),
				$this->capability,
				$tools_parent,
				'bp_core_tools_top_level_item',
				'',
				24 // Just above Settings.
			);

			$hooks[] = add_submenu_page(
				$tools_parent,
				__( 'Available Tools', 'buddyboss' ),
				__( 'Available Tools', 'buddyboss' ),
				$this->capability,
				'available-tools',
				'bp_core_admin_available_tools_page'
			);
		} else {
			$tools_parent = 'tools.php';
		}

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'Tools', 'buddyboss' ),
			__( 'Tools', 'buddyboss' ),
			$this->capability,
			'bp-tools',
			'bp_core_admin_tools'
		);

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( 'Help', 'buddyboss' ),
			__( 'Help', 'buddyboss' ),
			$this->capability,
			'bp-help',
			'bp_core_admin_help'
		);

		$hooks[] = add_submenu_page(
			$this->settings_page,
			__( '', 'buddyboss' ),
			__( '', 'buddyboss' ),
			$this->capability,
			'bp-plugin-separator-notice',
			''
		);

		// For network-wide configs, add a link to (the root site's) Emails screen.
		if ( is_network_admin() && bp_is_network_activated() ) {
			$email_labels = bp_get_email_post_type_labels();
			$email_url    = get_admin_url( bp_get_root_blog_id(), 'edit.php?post_type=' . bp_get_email_post_type() );

			$hooks[] = add_menu_page(
				$email_labels['name'],
				$email_labels['menu_name'],
				$this->capability,
				'',
				'',
				'dashicons-email-alt',
				26
			);

			// Hack: change the link to point to the root site's admin, not the network admin.
			//$GLOBALS['menu'][26][2] = esc_url_raw( $email_url );
		}

		// foreach( $hooks as $hook ) {
		// 	add_action( "admin_head-$hook", 'bp_core_modify_admin_menu_highlight' );
		// }
	}

Changelog

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