<?php 

function ventoux_tabgroup_shortcode( $atts, $content = null ) {

        
        
        //Enqueue scripts
        wp_enqueue_script('ventoux_tabs');
       
        
        // Display Tabs
        $defaults = array();
        extract( shortcode_atts( $defaults, $atts ) );
        preg_match_all( '/tab title="([^\"]+)"/i', $content, $matches, PREG_OFFSET_CAPTURE );
        $tab_titles = array();
        if( isset($matches[1]) ){ $tab_titles = $matches[1]; }
        $output = '';
        if( count($tab_titles) ){
            $output .= '<div id="ventoux-tab-'. rand(1, 100) .'" class="ventoux-tabs">';
            $output .= '<ul class="ui-tabs-nav ventoux-clearfix">';
            foreach( $tab_titles as $tab ){
                $output .= '<li><a href="#ventoux-tab-'. sanitize_title( $tab[0] ) .'">' . $tab[0] . '</a></li>';
            }
            $output .= '</ul>';
            $output .= do_shortcode( $content );
            $output .= '</div>';
        } else {
            $output .= do_shortcode( $content );
        }
        if (is_customize_preview()) {
            wp_deregister_script( 'jquery-ui-tabs' );
            $output_no_display = '<p class="no-preview">Sorry, this item is disabled in the customizer preview window.</p>';
            return $output_no_display;
        }else{
        return $output;
    }
}
add_shortcode( 'ventoux_tabgroup', 'ventoux_tabgroup_shortcode' );

if (!function_exists('ventoux_tab_shortcode')) {
    function ventoux_tab_shortcode( $atts, $content = null ) {
        $defaults = array(
            'title'         => 'Tab',
            'class'         => '',
            'visibility'    => 'all',
        );
        extract( shortcode_atts( $defaults, $atts ) );
        return '<div id="ventoux-tab-'. sanitize_title( $title ) .'" class="tab-content '. $class .' ventoux-'. $visibility .'">'. do_shortcode( $content ) .'</div>';
    }
}
add_shortcode( 'ventoux_tab', 'ventoux_tab_shortcode' );