public function BootstrapCollapsiblesShortcode::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/ BootstrapCollapsiblesShortcode.php, line 27 - Adds shortcodes for all Bootstrap elements.
Class
- BootstrapCollapsiblesShortcode
- @Shortcode( id = "bs_collapsibles", token = "collapsibles", title = @Translation("Collapsibles"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 )
Namespace
Drupal\bs_shortcodes\Plugin\ShortcodeCode
public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
$attributes = $this
->getAttributes(array(
'xclass' => '',
'data' => '',
), $attributes);
$class = 'panel-group';
$class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
$id = 'custom-collapse-' . $GLOBALS['collapsibles_count'];
$data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
if (isset($GLOBALS['collapsibles_count'])) {
$GLOBALS['collapsibles_count']++;
}
return sprintf('<div class="%s" id="%s"%s>%s</div>', Html::escape($class), Html::getUniqueId($id), $data_props ? ' ' . $data_props : '', $content);
}