src/Common.php
public function button($class, $name, array $options = array())
    {
        $attributes = array('type' => 'button');
        foreach ($options as $key => $value) {
            if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) {
                $attributes[$key] = $value;
            }
        }
        $attributes['class'] = $this->prefixClasses('btn', array('block', 'xs', 'sm', 'lg', 'default', 'primary', 'success', 'info', 'warning', 'danger', 'link'), $class);
        if (isset($options['dropdown']) || isset($options['dropup'])) {
            $html = '';
            unset($attributes['href']);
            $class = (isset($options['dropup'])) ? 'btn-group dropup' : 'btn-group';
            $links = (isset($options['dropup'])) ? $options['dropup'] : $options['dropdown'];
            $html .= '<div class="'.$class.'">';
            list($dropdown, $id) = $this->dropdown($links, $options);
            if (is_array($name) && isset($name['split'])) {
                $html .= $this->page->tag('button', $attributes, $name['split']);
                $attributes['id'] = $id;
                $attributes['class'] .= ' dropdown-toggle';
                $attributes['data-toggle'] = 'dropdown';
                $attributes['aria-haspopup'] = 'true';
                $attributes['aria-expanded'] = 'false';
                $html .= $this->page->tag('button', $attributes, '<span class="caret"></span>', '<span class="sr-only">Toggle Dropdown</span>');
            } else {
                $attributes['id'] = $id;
                $attributes['class'] .= ' dropdown-toggle';
                $attributes['data-toggle'] = 'dropdown';
                $attributes['aria-haspopup'] = 'true';
                $attributes['aria-expanded'] = 'false';
                $html .= $this->page->tag('button', $attributes, $name, '<span class="caret"></span>');
            }
            $html .= $dropdown;
            $html .= '</div>';

            return $html;
        } elseif (isset($options['href'])) {
            unset($attributes['type']);

            return $this->page->tag('a', $attributes, $name);
        } else {
            return $this->page->tag('button', $attributes, $name);
        }
    }
public function button($class, $name, array $options = array())
    {
        $attributes = array('type' => 'button');
        foreach ($options as $key => $value) {
            if (!in_array($key, array('dropdown', 'dropup', 'active', 'disabled', 'pull'))) {
                $attributes[$key] = $value;
            }
        }
        $attributes['class'] = $this->prefixClasses('btn', array('block', 'xs', 'sm', 'lg', 'default', 'primary', 'success', 'info', 'warning', 'danger', 'link'), $class);
        if (isset($options['dropdown']) || isset($options['dropup'])) {
            $html = '';
            unset($attributes['href']);
            $class = (isset($options['dropup'])) ? 'btn-group dropup' : 'btn-group';
            $links = (isset($options['dropup'])) ? $options['dropup'] : $options['dropdown'];
            $html .= '<div class="'.$class.'">';
            list($dropdown, $id) = $this->dropdown($links, $options);
            if (is_array($name) && isset($name['split'])) {
                $html .= $this->page->tag('button', $attributes, $name['split']);
                $attributes['id'] = $id;
                $attributes['class'] .= ' dropdown-toggle';
                $attributes['data-toggle'] = 'dropdown';
                $attributes['aria-haspopup'] = 'true';
                $attributes['aria-expanded'] = 'false';
                $html .= $this->page->tag('button', $attributes, '<span class="caret"></span>', '<span class="sr-only">Toggle Dropdown</span>');
            } else {
                $attributes['id'] = $id;
                $attributes['class'] .= ' dropdown-toggle';
                $attributes['data-toggle'] = 'dropdown';
                $attributes['aria-haspopup'] = 'true';
                $attributes['aria-expanded'] = 'false';
                $html .= $this->page->tag('button', $attributes, $name, '<span class="caret"></span>');
            }
            $html .= $dropdown;
            $html .= '</div>';

            return $html;
        } elseif (isset($options['href'])) {
            unset($attributes['type']);

            return $this->page->tag('a', $attributes, $name);
        } else {
            return $this->page->tag('button', $attributes, $name);
        }
    }
public function button ( $ class , $ name , array $ options = array ( ) ) { $ attributes = array ( 'type' => 'button' ) ; foreach ( $ options as $ key => $ value ) { if ( ! in_array ( $ key , array ( 'dropdown' , 'dropup' , 'active' , 'disabled' , 'pull' ) ) ) { $ attributes [ $ key ] = $ value ; } } $ attributes [ 'class' ] = $ this -> prefixClasses ( 'btn' , array ( 'block' , 'xs' , 'sm' , 'lg' , 'default' , 'primary' , 'success' , 'info' , 'warning' , 'danger' , 'link' ) , $ class ) ; if ( isset ( $ options [ 'dropdown' ] ) || isset ( $ options [ 'dropup' ] ) ) { $ html = '' ; unset ( $ attributes [ 'href' ] ) ; $ class = ( isset ( $ options [ 'dropup' ] ) ) ? 'btn-group dropup' : 'btn-group' ; $ links = ( isset ( $ options [ 'dropup' ] ) ) ? $ options [ 'dropup' ] : $ options [ 'dropdown' ] ; $ html .= '<div class="' . $ class . '">' ; list ( $ dropdown , $ id ) = $ this -> dropdown ( $ links , $ options ) ; if ( is_array ( $ name ) && isset ( $ name [ 'split' ] ) ) { $ html .= $ this -> page -> tag ( 'button' , $ attributes , $ name [ 'split' ] ) ; $ attributes [ 'id' ] = $ id ; $ attributes [ 'class' ] .= ' dropdown-toggle' ; $ attributes [ 'data-toggle' ] = 'dropdown' ; $ attributes [ 'aria-haspopup' ] = 'true' ; $ attributes [ 'aria-expanded' ] = 'false' ; $ html .= $ this -> page -> tag ( 'button' , $ attributes , '<span class="caret"></span>' , '<span class="sr-only">Toggle Dropdown</span>' ) ; } else { $ attributes [ 'id' ] = $ id ; $ attributes [ 'class' ] .= ' dropdown-toggle' ; $ attributes [ 'data-toggle' ] = 'dropdown' ; $ attributes [ 'aria-haspopup' ] = 'true' ; $ attributes [ 'aria-expanded' ] = 'false' ; $ html .= $ this -> page -> tag ( 'button' , $ attributes , $ name , '<span class="caret"></span>' ) ; } $ html .= $ dropdown ; $ html .= '</div>' ; return $ html ; } elseif ( isset ( $ options [ 'href' ] ) ) { unset ( $ attributes [ 'type' ] ) ; return $ this -> page -> tag ( 'a' , $ attributes , $ name ) ; } else { return $ this -> page -> tag ( 'button' , $ attributes , $ name ) ; } }
A button by itself is easy enough, but when you start including dropdowns and groups your markup can get ugly quick. Follow the examples. We'll start simple and go from there.

@param string $class   The classes: '**xs**', '**sm**', '**lg**', '**block**', '**default**', '**primary**', '**success**', '**info**', '**warning**', '**danger**', and '**link**' will all be prefixed with '**btn-...**', and we include the '**btn**' class too. Notice how we left out the '**btn-group**' option? Don't worry about that one. Feel free to add any more that you like such as '**disabled**'.
@param string $name    The text of your button. You may also include badges, labels, icons, etc, but leave the caret up to us. If you are including a dropdown menu and you would like to split the button from the menu, then you can make this an ``array('split' => $name)``.
@param array  $options These are all of the attributes that you would like to include in the ``<button>`` tag, except if you include an '**href**' key then it will be an ``<a>`` tag. Other potential options include: '**id**', '**style**', '**title**', '**type**', '**data-...**', etc, but the ones we take notice of and do special things with are:

- '**dropdown**' => This is an ``array($name => $link, ...)`` of names and their associated links.
- If the **$name** is numeric (ie. not specified) then the **$link** will be a header (if it is not empty), or a divider if it is.
- '**dropup**' => The same as dropdown, only the caret and menu goes up instead of down.
- '**active**' => This is to specify a **$link** that will receive the "**active**" class. You can set this value to either the **$name** or the **$link** of your dropdown menu, or an **integer** (starting from 1). If you just want it to select the current page then you can specify '**url**' which will match the current url and path, or '**urlquery**' which will match the current url, path, and query string.
- '**disabled**' => This is to specify a link that will receive the "disabled" class. You can set this value to either the **$name** or the **$link** of your dropdown menu.
- '**pull**' => Either '**left**' (default) or '**right**'. Where you would like the dropdown to be positioned, relative to the parent.

@return string

@example

```php
echo $bp->button('primary', 'Primary');

echo $bp->button('lg success', 'Link', array('href'=>'#'));

echo $bp->button('default', 'Dropdown', array(
'dropdown' => array(
'Header',
'Action' => '#',
'Another action' => '#',
'Active link' => '#',
'',
'Separated link' => '#',
'Disabled link' => '#',
),
'active' => 'Active link',
'disabled' => 'Disabled link',
));
```
A button by itself is easy enough but when you start including dropdowns and groups your markup can get ugly quick . Follow the examples . We ll start simple and go from there .