BP_Buttons_Group::__construct( array $args = array() )


Parameters Parameters


(array) (Optional) array having the following parameters { @type string $id A string to use as the unique ID for the button. Required. @type int $position Where to insert the Button. Defaults to 99. @type string $component The Component's the button is build for (eg: Activity, Groups..). Required. @type bool $must_be_logged_in Whether the button should only be displayed to logged in users. Defaults to True. @type bool $block_self Optional. True if the button should be hidden when a user is viewing his own profile. Defaults to False. @type string $parent_element Whether to use a wrapper. Defaults to false. @type string $parent_attr set an array of attributes for the parent element. @type string $button_element Set this to 'button', 'img', or 'a', defaults to anchor. @type string $button_attr Any attributes required for the button_element @type string $link_text The text of the link. Required. }

Default value: array()

Source Source

File: bp-templates/bp-nouveau/includes/classes.php

	public function __construct( $args = array() ) {
		foreach ( $args as $arg ) {
			$r = bp_parse_args(
				(array) $arg,
					'id'                => '',
					'position'          => 99,
					'component'         => '',
					'must_be_logged_in' => true,
					'block_self'        => false,
					'parent_element'    => false,
					'parent_attr'       => array(),
					'button_element'    => 'a',
					'button_attr'       => array(),
					'link_text'         => '',

			// Just don't set the button if a param is missing
			if ( empty( $r['id'] ) || empty( $r['component'] ) || empty( $r['link_text'] ) ) {

			$r['id'] = sanitize_key( $r['id'] );

			// If the button already exist don't add it
			if ( isset( $this->group[ $r['id'] ] ) ) {

			 * If, in bp_nouveau_get_*_buttons(), we pass through a false value for 'parent_element'
			 * but we have attributtes for it in the array, let's default to setting a div.
			 * Otherwise, the original false value will be passed through to BP buttons.
			 * @todo: this needs review, probably trying to be too clever
			if ( ( ! empty( $r['parent_attr'] ) ) && false === $r['parent_element'] ) {
				$r['parent_element'] = 'div';

			$this->group[ $r['id'] ] = $r;

Top ↑

Changelog Changelog

Version Description
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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