Guest User

Untitled

a guest
Jan 22nd, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. // WooCommerce add a custom tab
  3. function load_custom_tab( $tab_key, $tab_info ) {
  4.  
  5. echo apply_filters( 'the_content', $tab_info['tabContent'] );
  6.  
  7. }
  8.  
  9. function add_content_tabs( $tabs ) {
  10.  
  11. global $post;
  12.  
  13. $custom_tabs = get_field( 'tabs', $post->ID );
  14.  
  15. if ( $custom_tabs ) :
  16.  
  17. foreach( $custom_tabs as $index => $tab ) {
  18.  
  19. $tabs[$tab['tab_tite']] = array(
  20.  
  21. 'title' => $tab['tab_title'],
  22.  
  23. 'priority' => 50 + $index,
  24.  
  25. 'tabContent' => $tab['tab_content'],
  26.  
  27. 'callback' => 'load_custom_tab'
  28.  
  29. );
  30.  
  31. }
  32.  
  33. endif;
  34.  
  35. return $tabs;
  36.  
  37. }
  38.  
  39. add_filter( 'woocommerce_product_tabs', 'add_content_tabs' );
Add Comment
Please, Sign In to add comment