This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

BP_Core::load_components()

Load components files

Description

Source

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

	private function load_components() {
		$bp = buddypress();

		/**
		 * Filters the included and optional components.
		 *
		 * @since BuddyPress 1.5.0
		 *
		 * @param array $value Array of included and optional components.
		 */
		$bp->optional_components = apply_filters('bp_optional_components', array_keys(bp_core_get_components('optional')));

		/**
		 * Filters the required components.
		 *
		 * @since BuddyPress 1.5.0
		 *
		 * @param array $value Array of required components.
		 */
		$bp->required_components = apply_filters('bp_required_components', array('members', 'xprofile'));

		// Get a list of activated components.
		if ($active_components = bp_get_option('bp-active-components')) {

			/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
			$bp->active_components = apply_filters('bp_active_components', $active_components);

			/**
			 * Filters the deactivated components.
			 *
			 * @since BuddyPress 1.0.0
			 *
			 * @param array $value Array of deactivated components.
			 */
			$bp->deactivated_components = apply_filters('bp_deactivated_components', array_values(array_diff(array_values(array_merge($bp->optional_components, $bp->required_components)), array_keys($bp->active_components))));

			// Pre 1.5 Backwards compatibility.
		} elseif ($deactivated_components = bp_get_option('bp-deactivated-components')) {

			// Trim off namespace and filename.
			foreach (array_keys((array) $deactivated_components) as $component) {
				$trimmed[] = str_replace('.php', '', str_replace('bp-', '', $component));
			}

			/** This filter is documented in bp-core/bp-core-loader.php */
			$bp->deactivated_components = apply_filters('bp_deactivated_components', $trimmed);

			// Setup the active components.
			$active_components = array_fill_keys(array_diff(array_values(array_merge($bp->optional_components, $bp->required_components)), array_values($bp->deactivated_components)), '1');

			/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
			$bp->active_components = apply_filters('bp_active_components', $bp->active_components);

			// Default to all components active.
		} else {

			// Set globals.
			$bp->deactivated_components = array();

			// Setup the active components.
			$active_components = array_fill_keys(array_values(array_merge($bp->optional_components, $bp->required_components)), '1');

			/** This filter is documented in bp-core/admin/bp-core-admin-components.php */
			$bp->active_components = apply_filters('bp_active_components', $bp->active_components);
		}

		// Loop through optional components.
		foreach ($bp->optional_components as $component) {
			if (bp_is_active($component) && file_exists($bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php')) {
				include $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php';
			}
		}

		// Loop through required components.
		foreach ($bp->required_components as $component) {
			if (file_exists($bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php')) {
				include $bp->plugin_dir . '/bp-' . $component . '/bp-' . $component . '-loader.php';
			}
		}

		// Add Core to required components.
		$bp->required_components[] = 'core';

		/**
		 * Fires after the loading of individual components.
		 *
		 * @since BuddyPress 2.0.0
		 */
		do_action('bp_core_components_included');
	}

Changelog

Changelog
Version Description
BuddyBoss 1.0.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.