<?php


function accordions($atts, $content = null) {
        return'<div class="accordion" id="accordion">'.do_shortcode($content).'</div>';
}
add_shortcode('xs_accordiangroup', 'accordions');


function accordian($atts, $content = null)
{
    extract(shortcode_atts(array(
        'id' => rand(100,1000),
        'title'            => '',
        'collapse'             => '',
    ), $atts, 'xs_accordion'));
       
    if($collapse == 'open')
    {
        $collapsed = 'in';
        
    }
    
    elseif ($collapse =='closed')
    {
        $collapses = ' class="collapsed"';  
    }
//    else
//    {
//        $collapses = ' class="collapsed"';
//        
//    }

    $result = ' <div class="panel accordion-item"><div class="accordion-heading"><h5 class="accordion-title"><a '.$collapses.' data-toggle="collapse" data-parent="#accordion" href="#'.$id.'">'.$title.'</a></h5> </div> ';
    $result .= '<div id="'.$id.'" class="accordion-collapse collapse '.$collapsed.'"><div class="accordion-body">'.$content.'</div> </div>';
    $result .= '</div>';
   
    
    return $result;
}
add_shortcode( "xs_accordion", "accordian" );


?>
