Created
June 15, 2014 17:00
-
-
Save danfisher85/9ef8c8f02c43cf69a872 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-----------------------------------------------------------------------------------*/ | |
/* Tabs Shortcodes | |
/*-----------------------------------------------------------------------------------*/ | |
$tabs_divs = ''; | |
function tabs_group($atts, $content = null ) { | |
global $tabs_divs; | |
$tabs_divs = ''; | |
$output = '<div class="tabs-wrapper"><ul class="nav nav-tabs">'; | |
$output.= do_shortcode($content).'</ul>'; | |
$output.= '<div class="tab-content">'.$tabs_divs.'</div>'; | |
return $output; | |
} | |
add_shortcode('tab', 'tab'); | |
function tab($atts, $content = null) { | |
global $tabs_divs; | |
extract(shortcode_atts(array( | |
'id' => '', | |
'title' => '', | |
'state' => '' | |
), $atts)); | |
if(empty($id)) { | |
$id = 'side-tab'.rand(100,999); | |
} | |
$state_link = ''; | |
if($state == 'open') { | |
$state = 'in active'; | |
$state_link = 'active'; | |
} | |
$output = ' | |
<li class="'.$state_link.'"> | |
<a href="#'.$id.'" data-toggle="tab">'.$title.'</a> | |
</li> | |
'; | |
$tabs_divs.= '<div id="'.$id.'" class="tab-pane fade '.$state.'">'.$content.'</div>'; | |
return $output; | |
} | |
add_shortcode('tabs', 'tabs_group'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment