BP_Component::start( string $id = '', string $name = '', string $path = '', array $params = array() )

Component loader.


Parameters Parameters

$id

(string) (Optional) Unique ID. Letters, numbers, and underscores only.

Default value: ''

$name

(string) (Optional) Unique name. This should be a translatable name, eg. __( 'Groups', 'buddypress' ).

Default value: ''

$path

(string) (Optional) The file path for the component's files. Used by BP_Component::includes().

Default value: ''

$params

(array) (Optional) Additional parameters used by the component.

  • 'adminbar_myaccount_order'
    (int) Set the position for our menu under the WP Toolbar's "My Account menu".
  • 'features'
    (array) An array of feature names. This is used to load additional files from your component directory and for feature active checks. eg. array( 'awesome' ) would look for a file called "bp-{$this->id}-awesome.php" and you could use bp_is_active( $this->id, 'awesome' ) to determine if the feature is active.
  • 'search_query_arg'
    (string) String to be used as the query argument in component search URLs.

Default value: array()


Source Source

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

	public function start( $id = '', $name = '', $path = '', $params = array() ) {

		// Internal identifier of component.
		$this->id   = $id;

		// Internal component name.
		$this->name = $name;

		// Path for includes.
		$this->path = $path;

		// Miscellaneous component parameters that need to be set early on.
		if ( ! empty( $params ) ) {
			// Sets the position for our menu under the WP Toolbar's "My Account" menu.
			if ( ! empty( $params['adminbar_myaccount_order'] ) ) {
				$this->adminbar_myaccount_order = (int) $params['adminbar_myaccount_order'];
			}

			// Register features.
			if ( ! empty( $params['features'] ) ) {
				$this->features = array_map( 'sanitize_title', (array) $params['features'] );
			}

			if ( ! empty( $params['search_query_arg'] ) ) {
				$this->search_query_arg = sanitize_title( $params['search_query_arg'] );
			}

		// Set defaults if not passed.
		} else {
			// New component menus are added before the settings menu if not set.
			$this->adminbar_myaccount_order = 90;
		}

		// Move on to the next step.
		$this->setup_actions();
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.4.0 Added $params['search_query_arg'] as a configurable value.
2.3.0 Added $params['features'] as a configurable value.
1.9.0 Added $params as a parameter.
1.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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