function bs_carousel($atts, $content = null)
 {
     if (isset($GLOBALS['carousel_count'])) {
         $GLOBALS['carousel_count']++;
     } else {
         $GLOBALS['carousel_count'] = 0;
     }
     $GLOBALS['carousel_default_count'] = 0;
     $atts = shortcode_atts(array("interval" => false, "pause" => false, "wrap" => false, "xclass" => false, "data" => false), $atts);
     $div_class = 'carousel slide';
     $div_class .= $atts['xclass'] ? ' ' . $atts['xclass'] : '';
     $inner_class = 'carousel-inner';
     $id = 'custom-carousel-' . $GLOBALS['carousel_count'];
     $data_props = $this->parse_data_attributes($atts['data']);
     $atts_map = bs_attribute_map($content);
     // Extract the slide titles for use in the carousel widget.
     if ($atts_map) {
         $indicators = array();
         $GLOBALS['carousel_default_active'] = true;
         foreach ($atts_map as $check) {
             if (!empty($check["carousel-item"]["active"])) {
                 $GLOBALS['carousel_default_active'] = false;
             }
         }
         $i = 0;
         foreach ($atts_map as $slide) {
             $indicators[] = sprintf('<li class="%s" data-target="%s" data-slide-to="%s"></li>', !empty($slide["carousel-item"]["active"]) || $GLOBALS['carousel_default_active'] && $i == 0 ? 'active' : '', esc_attr('#' . $id), esc_attr($i));
             $i++;
         }
     }
     return sprintf('<div class="%s" id="%s" data-ride="carousel"%s%s%s%s>%s<div class="%s">%s</div>%s%s</div>', esc_attr($div_class), esc_attr($id), $atts['interval'] ? sprintf(' data-interval="%d"', $atts['interval']) : '', $atts['pause'] ? sprintf(' data-pause="%s"', esc_attr($atts['pause'])) : '', $atts['wrap'] == 'true' ? sprintf(' data-wrap="%s"', esc_attr($atts['wrap'])) : '', $data_props ? ' ' . $data_props : '', $indicators ? '<ol class="carousel-indicators">' . implode($indicators) . '</ol>' : '', esc_attr($inner_class), do_shortcode($content), '<a class="left carousel-control"  href="' . esc_url('#' . $id) . '" data-slide="prev"><span class="glyphicon glyphicon-chevron-left"></span></a>', '<a class="right carousel-control" href="' . esc_url('#' . $id) . '" data-slide="next"><span class="glyphicon glyphicon-chevron-right"></span></a>');
 }
Example #2
0
function bs_tabs($atts, $content = null)
{
    if (isset($GLOBALS['tabs_count'])) {
        $GLOBALS['tabs_count']++;
    } else {
        $GLOBALS['tabs_count'] = 0;
    }
    $GLOBALS['tabs_default_count'] = 0;
    $div_class = 'tab-content';
    $id = 'custom-tabs-' . $GLOBALS['tabs_count'];
    $atts_map = bs_attribute_map($content);
    // Extract the tab titles for use in the tab widget.
    if ($atts_map) {
        $tabs = array();
        $GLOBALS['tabs_default_active'] = true;
        foreach ($atts_map as $check) {
            if (!empty($check["tab"]["active"])) {
                $GLOBALS['tabs_default_active'] = false;
            }
        }
        $i = 0;
        foreach ($atts_map as $tab) {
            $class = '';
            $class .= !empty($tab["tab"]["active"]) || $GLOBALS['tabs_default_active'] && $i == 0 ? 'active' : '';
            $class .= !empty($tab["tab"]["xclass"]) ? ' ' . $tab["tab"]["xclass"] : '';
            $tabs[] = sprintf('<li%s><a href="#%s" data-toggle="tab">%s</a></li>', !empty($class) ? ' class="' . $class . '"' : '', 'custom-tab-' . $GLOBALS['tabs_count'] . '-' . md5($tab["tab"]["title"]), $tab["tab"]["title"]);
            $i++;
        }
    }
    return sprintf('<ul class="tabs-nav" id="%s">%s</ul><div class="%s">%s</div>', esc_attr($id), $tabs ? implode($tabs) : '', esc_attr($div_class), do_shortcode($content));
}
Example #3
0
function tabs($atts, $content = null)
{
    if (isset($GLOBALS['tabs_count'])) {
        $GLOBALS['tabs_count']++;
    } else {
        $GLOBALS['tabs_count'] = 0;
    }
    $GLOBALS['tabs_default_count'] = 0;
    extract(shortcode_atts(array("type" => false, "xclass" => false), $atts));
    $ul_class = 'nav';
    $ul_class .= $type ? ' nav-' . $type : ' nav-tabs';
    $ul_class .= $xclass ? ' ' . $xclass : '';
    $div_class = 'tab-content';
    $id = 'custom-tabs-' . $GLOBALS['tabs_count'];
    $atts_map = bs_attribute_map($content);
    // Extract the tab titles for use in the tab widget.
    if ($atts_map) {
        $tabs = array();
        $GLOBALS['tabs_default_active'] = true;
        foreach ($atts_map as $check) {
            if (!empty($check["tab"]["active"])) {
                $GLOBALS['tabs_default_active'] = false;
            }
        }
        $i = 0;
        foreach ($atts_map as $tab) {
            $tabs[] = sprintf('<li%s><a href="#%s" data-toggle="tab">%s</a></li>', !empty($tab["tab"]["active"]) || $GLOBALS['tabs_default_active'] && $i == 0 ? ' class="active"' : '', 'custom-tab-' . $GLOBALS['tabs_count'] . '-' . sanitize_title($tab["tab"]["title"]), $tab["tab"]["title"]);
            $i++;
        }
    }
    $ul_class = esc_attr($ul_class);
    $id = esc_attr($id);
    $tabs = $tabs ? implode($tabs) : '';
    $div_class = esc_attr($div_class);
    $output = '<ul class="' . $ul_class . '" id="' . $id . '">' . $tabs . '</ul><div class="' . $div_class . '">' . do_shortcode($content) . '</div>';
    return $output;
}
Example #4
0
function bs_tabs_vertical($atts, $content = null)
{
    if (isset($GLOBALS['tabs_count'])) {
        $GLOBALS['tabs_count']++;
    } else {
        $GLOBALS['tabs_count'] = 0;
    }
    $GLOBALS['tabs_default_count'] = 0;
    $atts = shortcode_atts(array("type" => false, "xclass" => false, "data" => false), $atts);
    $ul_class = 'nav';
    $ul_class .= $atts['type'] ? ' nav-' . $atts['type'] : ' nav-tabs';
    $ul_class .= $atts['xclass'] ? ' ' . $atts['xclass'] : '';
    $ul_class .= ' tabs-vertical tabs-left';
    $div_class = 'tab-content';
    $id = 'custom-tabs-' . $GLOBALS['tabs_count'];
    $data_props = $atts['data'];
    $atts_map = bs_attribute_map($content);
    // Extract the tab titles for use in the tab widget.
    if ($atts_map) {
        $tabs = array();
        $GLOBALS['tabs_default_active'] = true;
        foreach ($atts_map as $check) {
            if (!empty($check["tab"]["active"])) {
                $GLOBALS['tabs_default_active'] = false;
            }
        }
        $i = 0;
        foreach ($atts_map as $tab) {
            $class = '';
            $class .= !empty($tab["tab"]["active"]) || $GLOBALS['tabs_default_active'] && $i == 0 ? 'active' : '';
            $class .= !empty($tab["tab"]["xclass"]) ? ' ' . $tab["tab"]["xclass"] : '';
            $tabs[] = sprintf('<li%s><a href="#%s" data-toggle="tab">%s</a></li>', !empty($class) ? ' class="' . $class . '"' : '', 'custom-tab-' . $GLOBALS['tabs_count'] . '-' . md5($tab["tab"]["title"]), $tab["tab"]["title"]);
            $i++;
        }
    }
    return sprintf('<div class="col-sm-3"><ul class="%s" id="%s"%s>%s</ul></div><div class="col-sm-9"><div class="%s">%s</div></div>', esc_attr($ul_class), esc_attr($id), $data_props ? ' ' . $data_props : '', $tabs ? implode($tabs) : '', esc_attr($div_class), do_shortcode($content));
}