Guest User

Untitled

a guest
May 24th, 2021
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. add_action( 'init', 'salient_child_legacy_maps' );
  2.  
  3. function salient_child_legacy_maps() {
  4. add_shortcode('vc_tour','salient_vc_tour_map');
  5. add_shortcode('vc_tab','salient_vc_tab_map');
  6. }
  7.  
  8.  
  9. function salient_vc_tour_map( $atts, $content = null ) {
  10.  
  11. wp_enqueue_style( 'nectar-element-tabbed-section' );
  12.  
  13. // Extract tab titles
  14. preg_match_all( '/vc_tab[^]]+title="([^\"]+)"(\sid\=\"([^\"]+)\"){0,1}/i', $content, $matches, PREG_OFFSET_CAPTURE );
  15.  
  16. $tab_titles = array();
  17.  
  18. if ( isset($matches[0]) ) { $tab_titles = $matches[0]; }
  19.  
  20. $tabs_nav = '';
  21. $tabs_nav .= '<ul class="wpb_tabs_nav ui-tabs-nav clearfix">';
  22. $tab_index = 0;
  23. foreach ( $tab_titles as $tab ) {
  24. preg_match('/title="([^\"]+)"(\sid\=\"([^\"]+)\"){0,1}/i', $tab[0], $tab_matches, PREG_OFFSET_CAPTURE );
  25. if(isset($tab_matches[1][0])) {
  26. $active_class = ( $tab_index === 0 ) ? 'class="active-tab"' : '';
  27. $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>';
  28.  
  29. }
  30. $tab_index++;
  31. }
  32.  
  33. $tabs_nav .= '</ul>'."\n";
  34.  
  35. $output = '';
  36. $output .= "\n\t".'<div class="wpb_content_element">';
  37. $output .= "\n\t\t".'<div class="wpb_wrapper tabbed clearfix" data-style="vertical_modern" data-color-scheme="accent-color">';
  38. $output .= "\n\t\t\t".$tabs_nav;
  39. ob_start();
  40. wpb_js_remove_wpautop($content);
  41. $output .= "\n\t\t\t". ob_get_contents();
  42. ob_end_clean();
  43. $output .= "\n\t\t".'</div>';
  44. $output .= "\n\t".'</div>';
  45.  
  46. echo $output;
  47. }
  48.  
  49. function salient_vc_tab_map( $atts, $content = null ) {
  50. if( isset($atts['title']) ) {
  51. echo do_shortcode('[tab title="'.esc_attr($atts['title']).'"]'.$content.'[/tab]');
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment