Guest User

Untitled

a guest
Feb 17th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.36 KB | None | 0 0
  1. <?php
  2. /**
  3. * Product Tabs Carousel
  4. *
  5. * @author Transvelo
  6. * @package Unicase/Templates
  7. * @version 1.0.0
  8. */
  9.  
  10. if ( ! defined( 'ABSPATH' ) ) {
  11. exit;
  12. }
  13.  
  14. $tabsID = uniqid();
  15. ?>
  16.  
  17. <div class="products-tabs-carousel">
  18. <?php if( apply_filters( 'unicase_show_product_tabs_carousel_title', TRUE ) ) : ?>
  19. <h3 class="section-title"><?php echo apply_filters( 'unicase_product_tabs_carousel_title', $title ); ?></h3>
  20. <?php endif; ?>
  21.  
  22. <div class="nav-tabs-wrapper">
  23. <ul class="nav nav-tabs" role="tablist">
  24. <?php foreach( $tabs as $key => $tab ) : ?>
  25. <li role="presentation" <?php if( $key == 0 ){ echo 'class="active"'; } ?>><a href="#<?php echo esc_attr( 'homepage-tab-carousel-' . $tabsID . '-' . $key );?>" aria-controls="<?php echo esc_attr( 'homepage-tab-carousel-' . $tabsID . '-' . $key );?>" role="tab" data-toggle="tab"><?php echo apply_filters( 'homepage_tab_carousel_title_'. $key , $tab['title'] ); ?></a></li>
  26. <?php endforeach; ?>
  27. </ul><!-- /.nav-tabs -->
  28. </div><!-- /.nav-tabs-wrapper -->
  29.  
  30. <div class="tab-content">
  31. <?php foreach( $tabs as $key => $tab ) : ?>
  32.  
  33. <div role="tabpanel" class="tab-pane <?php if( $key == 0 ) { echo esc_attr( 'active' ); } ?>" id="<?php echo esc_attr( 'homepage-tab-carousel-' . $tabsID . '-' . $key ); ?>">
  34.  
  35. <?php
  36. if( $product_content == 'top_rated_products' ) {
  37. $class_name = class_exists( 'WC_Shortcode_Products' ) ? 'WC_Shortcode_Products' : WC()->query;
  38. add_filter( 'posts_clauses', array( $class_name, 'order_by_rating_post_clauses' ) );
  39. $products = new WP_Query( apply_filters( 'unicase_product_tabs_carousel_query'. $key, $tab['content'] ) );
  40. remove_filter( 'posts_clauses', array( $class_name, 'order_by_rating_post_clauses' ) );
  41. } else {
  42. $products = new WP_Query( apply_filters( 'unicase_product_tabs_carousel_query'. $key, $tab['content'] ) );
  43. }
  44.  
  45. if ( $products->have_posts() ) :
  46. $carouselID = uniqid();
  47. ?>
  48. <div id="unicase-tabs-carousel-<?php echo esc_attr( $carouselID ); ?>" class="owl-carousel unicase-owl-carousel owl-outer-nav has-grid products">
  49. <?php
  50. while ( $products->have_posts() ) : $products->the_post();
  51. unicase_get_template( 'sections/products-carousel-item.php' );
  52. endwhile;
  53. ?>
  54. </div>
  55. <script type="text/javascript">
  56.  
  57. jQuery(document).ready(function($) {
  58.  
  59. function makeHomePageTabsCarousel() {
  60. $("#unicase-tabs-carousel-<?php echo esc_attr( $carouselID ); ?>").owlCarousel({
  61. items : <?php echo ( !empty( $carousel_items ) && intval( $carousel_items ) ? $carousel_items : 4 ); ?>,
  62. nav : true,
  63. slideSpeed : 300,
  64. dots: false,
  65. autoplay: true,
  66. autoplayTimeout: 3000,
  67. <?php if( is_rtl() ) : ?>
  68. rtl: true,
  69. <?php endif; ?>
  70. paginationSpeed : 400,
  71. navText: ["", ""],
  72. margin: 30,
  73. <?php if( $disable_touch_drag ) : ?>
  74. touchDrag: false,
  75. <?php endif; ?>
  76. responsive:{
  77. 0:{
  78. items:1
  79. },
  80. 480:{
  81. items:3
  82. },
  83. 768:{
  84. items:2
  85. },
  86. 992:{
  87. items:3
  88. },
  89. 1200:{
  90. items:<?php echo ( !empty( $carousel_items ) && intval( $carousel_items ) ? $carousel_items : 4 ); ?>
  91. }
  92. }
  93. });
  94. }
  95.  
  96. makeHomePageTabsCarousel();
  97.  
  98. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  99. var target = $(e.target).attr("href");
  100. var $owl = $(target).find('#unicase-tabs-carousel-<?php echo esc_attr( $carouselID ); ?>');
  101. $owl.trigger('refresh.owl.carousel');
  102.  
  103. if( typeof echo != "undefined" ) {
  104. echo.render();
  105. } else {
  106. $owl.find('.product-cover > img').each( function(){
  107. var height = $(this).height();
  108. if( height !== 0 ) {
  109. $(this).closest( '.product-image-actions' ).height( height );
  110. }
  111. });
  112. }
  113. });
  114. });
  115. </script>
  116. <?php
  117. endif;
  118. ?>
  119.  
  120. </div><!-- /.tab-pane -->
  121.  
  122. <?php endforeach; ?>
  123.  
  124. </div><!-- /.tab-content -->
  125. <?php
  126.  
  127. wp_reset_postdata();
  128. ?>
  129. </div>
Add Comment
Please, Sign In to add comment