BP_Group_Extension::init( array $args = array() )
Initialize the extension, using your config settings.
Description
Your plugin should call this method at the very end of its constructor, like so:
public function __construct() { $args = array( ‘slug’ => ‘my-group-extension’, ‘name’ => ‘My Group Extension’, // … );
parent::init( $args );
}
Parameters
- $args
-
(Optional) Array of initialization arguments.
- 'slug'
(string) Unique, URL-safe identifier for your extension. - 'name'
(string) Translatable name for your extension. Used to populate navigation items. - 'visibility'
(string) Optional. Set to 'public' for your extension (the main tab as well as the widget) to be available to anyone who can access the group; set to 'private' otherwise. Default: 'public'. - 'nav_item_position'
(int) Optional. Location of the nav item in the tab list. Default: 81. - 'enable_nav_item'
(bool) Optional. Whether the extension's tab should be accessible to anyone who can view the group. Default: true. - 'nav_item_name'
(string) Optional. The translatable text you want to appear in the nav tab. Default: the value of$name
. - 'display_hook'
(string) Optional. The WordPress action that the widget_display() method is hooked to. Default: 'groups_custom_group_boxes'. - 'template_file'
(string) Optional. Theme-relative path to the template file BP should use to load the content of your main extension tab. Default: 'groups/single/plugins.php'. - 'screens'
(array) A multi-dimensional array of configuration information for the extension screens. See docblock of BP_Group_Extension for more details. - 'access'
(string|array) Which users can visit the plugin's tab. Possible values: 'anyone', 'loggedin', 'member', 'mod', 'admin' or 'noone'. ('member', 'mod', 'admin' refer to user's role in group.) Note that 'mod' targets only group moderators. If you want to allow access to group moderators and admins, specifyarray( 'mod', 'admin' )
. Defaults to 'anyone' for public groups and 'member' for private groups. - 'show_tab'
(string|array) Which users can see the plugin's navigation tab. Possible values: 'anyone', 'loggedin', 'member', 'mod', 'admin' or 'noone'. ('member', 'mod', 'admin' refer to user's role in group.) Note that 'mod' targets only group moderators. If you want to show the tab to group moderators and admins, specifyarray( 'mod', 'admin' )
. Defaults to 'anyone' for public groups and 'member' for private groups.
Default value: array()
- 'slug'
Source
File: bp-groups/classes/class-bp-group-extension.php
public function init( $args = array() ) { // Store the raw arguments. $this->params_raw = $args; // Before this init() method was introduced, plugins were // encouraged to set their config directly. For backward // compatibility with these plugins, we detect whether this is // one of those legacy plugins, and parse any legacy arguments // with those passed to init(). $this->parse_legacy_properties(); $args = $this->parse_args_r( $args, $this->legacy_properties_converted ); // Parse with defaults. $this->params = $this->parse_args_r( $args, array( 'slug' => $this->slug, 'name' => $this->name, 'visibility' => $this->visibility, 'nav_item_position' => $this->nav_item_position, 'enable_nav_item' => (bool) $this->enable_nav_item, 'nav_item_name' => $this->nav_item_name, 'display_hook' => $this->display_hook, 'template_file' => $this->template_file, 'screens' => $this->get_default_screens(), 'access' => null, 'show_tab' => null, ) ); $this->initialized = true; }
Changelog
Version | Description |
---|---|
BuddyPress 1.8.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.