BP_Component::start( string $id = '', string $name = '', string $path = '', array $params = array() )
Component loader.
Description
Parameters
- $id
-
(Optional) Unique ID. Letters, numbers, and underscores only.
Default value: ''
- $name
-
(Optional) Unique name. This should be a translatable name, eg. __( 'Groups', 'buddyboss' ).
Default value: ''
- $path
-
(Optional) The file path for the component's files. Used by BP_Component::includes().
Default value: ''
- $params
-
(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()
- 'adminbar_myaccount_order'
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();
}
Changelog
| Version | Description |
|---|---|
| BuddyPress 2.4.0 Added $params['search_query_arg'] as a configurable value. | BuddyPress 2.4.0 Added $params['search_query_arg'] as a configurable value. |
| BuddyPress 2.3.0 Added $params['features'] as a configurable value. | BuddyPress 2.3.0 Added $params['features'] as a configurable value. |
| BuddyPress 1.9.0 Added $params as a parameter. | BuddyPress 1.9.0 Added $params as a parameter. |
| BuddyPress 1.5.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.