You are here

function bs_shortcodes_nav_item in Bootstrap 3 shortcodes 7

bs_shortcodes_nav_item

File

./bs_shortcodes.module, line 434

Code

function bs_shortcodes_nav_item($attrs, $content = '') {
  extract(shortcode_attrs(array(
    "link" => '',
    "active" => '',
    "disabled" => '',
    "dropdown" => '',
    "xclass" => '',
    "data" => '',
  ), $attrs));
  $li_classes = '';
  $li_classes .= $dropdown ? 'dropdown' : '';
  $li_classes .= $active != '' ? ' active' : '';
  $li_classes .= $disabled != '' ? ' disabled' : '';
  $a_classes = '';
  $a_classes .= $dropdown != '' ? ' dropdown-toggle' : '';
  $a_classes .= $xclass ? ' ' . $xclass : '';
  $data_props = _bs_shortcodes_parse_data_attributes($data);

  # Wrong idea I guess ....

  #$pattern = ( $dropdown ) ? '<li%1$s><a href="%2$s"%3$s%4$s%5$s></a>%6$s</li>' : '<li%1$s><a href="%2$s"%3$s%4$s%5$s>%6$s</a></li>';

  //* If we have a dropdown shortcode inside the content we end the link before the dropdown shortcode, else all content goes inside the link
  $content = $dropdown ? str_replace('[dropdown]', '</a>[dropdown]', $content) : $content . '</a>';
  return sprintf('<li%1$s><a href="%2$s"%3$s%4$s%5$s>%6$s</li>', !empty($li_classes) ? sprintf(' class="%s"', check_plain($li_classes)) : '', check_url($link), !empty($a_classes) ? sprintf(' class="%s"', check_plain($a_classes)) : '', $dropdown ? ' data-toggle="dropdown"' : '', $data_props ? ' ' . $data_props : '', $content);
}