You are here

public function BootstrapDropdownItemShortcode::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/BootstrapDropdownItemShortcode.php, line 27
Adds shortcodes for all Bootstrap elements.

Class

BootstrapDropdownItemShortcode
@Shortcode( id = "bs_dropdown_item", token = "dropdown_item", title = @Translation("Dropdown Item"), description = @Translation("Bootstrap 3 shortcode") )

Namespace

Drupal\bs_shortcodes\Plugin\Shortcode

Code

public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
  $attributes = $this
    ->getAttributes(array(
    'link' => '',
    'disabled' => '',
    'xclass' => '',
    'data' => '',
  ), $attributes);
  $li_class = '';
  $li_class .= $attributes['disabled'] != '' ? ' disabled' : '';
  $a_class = '';
  $a_class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
  $data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
  return sprintf('<li role="presentation" class="%s"><a role="menuitem" href="%s" class="%s"%s>%s</a></li>', Html::escape($li_class), UrlHelper::stripDangerousProtocols($attributes['link']), Html::escape($a_class), $data_props ? ' ' . $data_props : '', $content);
}