Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action( 'init', 'salient_child_legacy_maps' );
- function salient_child_legacy_maps() {
- add_shortcode('vc_tour','salient_vc_tour_map');
- add_shortcode('vc_tab','salient_vc_tab_map');
- }
- function salient_vc_tour_map( $atts, $content = null ) {
- wp_enqueue_style( 'nectar-element-tabbed-section' );
- // Extract tab titles
- preg_match_all( '/vc_tab[^]]+title="([^\"]+)"(\sid\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
- $tab_titles = array();
- if ( isset($matches[0]) ) { $tab_titles = $matches[0]; }
- $tabs_nav = '';
- $tabs_nav .= '<ul class="wpb_tabs_nav ui-tabs-nav clearfix">';
- $tab_index = 0;
- foreach ( $tab_titles as $tab ) {
- preg_match('/title="([^\"]+)"(\sid\=\"([^\"]+)\"){0,1}/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE );
- if(isset($tab_matches[1][0])) {
- $active_class = ( $tab_index === 0 ) ? 'class="active-tab"' : '';
- $tabs_nav .= '<li><a href="#tab-'. (isset($tab_matches[3][0]) ? $tab_matches[3][0] : sanitize_title( $tab_matches[1][0] ) ) .'" '.$active_class.'><span>' . $tab_matches[1][0] . '</span></a></li>';
- }
- $tab_index++;
- }
- $tabs_nav .= '</ul>'."\n";
- $output = '';
- $output .= "\n\t".'<div class="wpb_content_element">';
- $output .= "\n\t\t".'<div class="wpb_wrapper tabbed clearfix" data-style="vertical_modern" data-color-scheme="accent-color">';
- $output .= "\n\t\t\t".$tabs_nav;
- ob_start();
- wpb_js_remove_wpautop($content);
- $output .= "\n\t\t\t". ob_get_contents();
- ob_end_clean();
- $output .= "\n\t\t".'</div>';
- $output .= "\n\t".'</div>';
- echo $output;
- }
- function salient_vc_tab_map( $atts, $content = null ) {
- if( isset($atts['title']) ) {
- echo do_shortcode('[tab title="'.esc_attr($atts['title']).'"]'.$content.'[/tab]');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment