BootstrapListGroupItemHeadingShortcode.php in Bootstrap 3 shortcodes 8
Adds shortcodes for all Bootstrap elements.
Namespace
Drupal\bs_shortcodes\Plugin\ShortcodeFile
src/Plugin/Shortcode/BootstrapListGroupItemHeadingShortcode.phpView source
<?php
/**
* @file
* Adds shortcodes for all Bootstrap elements.
*/
namespace Drupal\bs_shortcodes\Plugin\Shortcode;
use Drupal\Component\Utility\Html;
use Drupal\Core\Language\Language;
use Drupal\shortcode\Plugin\ShortcodeBase;
/**
* @Shortcode(
* id = "bs_list_group_item_heading",
* token = "list_group_item_heading",
* title = @Translation("List Group Item Heading"),
* description = @Translation("Bootstrap 3 shortcode"),
* weight = 50
* )
*/
class BootstrapListGroupItemHeadingShortcode extends ShortcodeBase {
public function process(array $attributes, $content, $langcode = Language::LANGCODE_NOT_SPECIFIED) {
$attributes = $this
->getAttributes(array(
'xclass' => '',
'data' => '',
), $attributes);
$class = 'list-group-item-heading';
$class .= $attributes['xclass'] ? ' ' . $attributes['xclass'] : '';
$data_props = _bs_shortcodes_parse_data_attributes($attributes['data']);
return sprintf('<h4 class="%s"%s>%s</h4>', Html::escape($class), $data_props ? ' ' . $data_props : '', $content);
}
/**
* {@inheritdoc}
*/
public function tips($long = FALSE) {
$output = array();
$output[] = '<p><strong>[list_group_item_heading</strong> xclass="any text" data="any text"<strong>]</strong> ... <strong>[/list_group_item_heading]</strong>';
if ($long) {
$output[] = t('More info about this shortcode <a href=":url" target="_blank">here</a>', array(
':url' => 'https://github.com/MWDelaney/bootstrap-3-shortcodes#list-group-item-heading-parameters',
)) . '.</p>';
}
else {
$output[] = t('More info <a href=":url" target="_blank">here</a>', array(
':url' => 'https://github.com/MWDelaney/bootstrap-3-shortcodes#list-group-item-heading-parameters',
)) . '.</p>';
}
return implode(' ', $output);
}
}
Classes
Name | Description |
---|---|
BootstrapListGroupItemHeadingShortcode | Plugin annotation @Shortcode( id = "bs_list_group_item_heading", token = "list_group_item_heading", title = @Translation("List Group Item Heading"), description = @Translation("Bootstrap 3 shortcode"), weight = 50 ) |