Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_shortcode( 'tabgroup', 'tab_group' );
- function tab_group( $atts, $content ){
- extract(shortcode_atts(array(
- 'set' => ''
- ), $atts));
- $GLOBALS['tab_count'] = 0;
- do_shortcode( $content );
- if( is_array( $GLOBALS['tabs'] ) ){
- $tab_count=0;
- foreach( $GLOBALS['tabs'] as $tab ){
- $tab_count++;
- $tabs[] = '<li><a href="#tabs-'. $set .'-'. $tab_count .'">'.$tab['title'].'</a></li>';
- $panes[] = '<div id="tabs-'. $set .'-'. $tab_count .'" class="tab_content">'. do_shortcode($tab['content']) .'</div>';
- }
- $return = "\n".'<div class="tabs"><ul class="clearfix">'.implode( "\n", $tabs ).'</ul>'."\n".''.implode( "\n", $panes ).'</div>'."\n";
- }
- return $return;
- }
- add_shortcode( 'tab', 'single_tab' );
- function single_tab( $atts, $content ){
- extract(shortcode_atts(array(
- 'title' => 'Tab %d'
- ), $atts));
- $x = $GLOBALS['tab_count'];
- $GLOBALS['tabs'][$x] = array(
- 'title' => sprintf( $title, $GLOBALS['tab_count'] ),
- 'content' => $content
- );
- $GLOBALS['tab_count']++;
- }
Advertisement
Add Comment
Please, Sign In to add comment