public function BootstrapButtonShortcode::process in Bootstrap 3 shortcodes 8
Performs the shortcode processing.
Parameters
array $attributes: Array of attributes.
string $text: The text string to be processed.
string $langcode: The language code of the text to be filtered. Defaults to LANGCODE_NOT_SPECIFIED.
Return value
string The processed text.
Overrides ShortcodeInterface::process
File
- src/
Plugin/ Shortcode/ BootstrapButtonShortcode.php, line 26 - Adds shortcodes for all Bootstrap elements.
Class
- BootstrapButtonShortcode
- @Shortcode( id = "bs_button", token = "button", title = @Translation("Button"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 ) @author M. W. Delaney
Namespace
Drupal\bs_shortcodes\Plugin\ShortcodeCode
public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
$attributes = $this
->getAttributes(array(
'type' => '',
'style' => '',
'size' => '',
'block' => '',
'dropdown' => '',
'link' => '',
'target' => '',
'disabled' => '',
'active' => '',
'xclass' => '',
'title' => '',
'data' => '',
), $attributes);
$class = 'btn';
$class .= $attributes['type'] ? ' btn-' . $attributes['type'] : ' btn-default';
$class .= $attributes['size'] ? ' btn-' . $attributes['size'] : '';
$class .= $attributes['block'] != '' ? ' btn-block' : '';
$class .= $attributes['dropdown'] != '' ? ' dropdown-toggle' : '';
$class .= $attributes['disabled'] != '' ? ' disabled' : '';
$class .= $attributes['active'] != '' ? ' active' : '';
$class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
// Styles:
// Transparent
// 3d
// 3d-plus
// swag see also http://tympanus.net/Development/CreativeButtons/
$data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
return sprintf('<a href="%s" class="%s"%s%s%s>%s</a>', UrlHelper::stripDangerousProtocols($attributes['link']), Html::escape($class), $attributes['target'] ? sprintf(' target="%s"', Html::escape($attributes['target'])) : '', $attributes['title'] ? sprintf(' title="%s"', Html::escape($attributes['title'])) : '', $data_props ? ' ' . $data_props : '', $content);
}