Advertisement
Guest User

Untitled

a guest
Jul 13th, 2021
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.82 KB | None | 0 0
  1.  
  2.  
  3.  
  4. // ADD PRODUCT CATEGORY DESCRIPTION IN RIGHT PLACE
  5. add_filter("get_the_archive_title_prefix", "__return_empty_string");
  6.  
  7. add_action( 'init', 'avia_woocommerce_full_width_category_images', 50 );
  8. function avia_woocommerce_full_width_category_images()
  9. {
  10. remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
  11. remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 );
  12. add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11);
  13. //add_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner_child_theme', 11);
  14.  
  15. function avia_woocommerce_shop_banner_child_theme()
  16. {
  17. global $avia_config;
  18.  
  19. if(is_shop() || (is_product_category() && avia_get_option('shop_banner_global') == "shop_banner_global") && !isset($avia_config['woo-banner']))
  20. {
  21. $options = avia_get_option();
  22.  
  23. if( isset( $options['shop_banner'] ) && ( $options['shop_banner'] == 'av-active-shop-banner' ) )
  24. {
  25. $bg = $options['shop_banner_image'];
  26. $overlay = $options['shop_banner_overlay_color'];
  27. $opacity = $options['shop_banner_overlay_opacity'];
  28. $description= wpautop($options['shop_banner_message']);
  29. $font = $options['shop_banner_message_color'];
  30.  
  31. echo avia_woocommerce_parallax_banner($bg, $overlay, $opacity, $description, $font);
  32. }
  33. }
  34. }
  35.  
  36. function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font)
  37. {
  38.  
  39. if(is_numeric($bg))
  40. {
  41. $bg = wp_get_attachment_image_src($bg, 'full');
  42. if(is_array($bg) && $bg[0] != "") $bg = $bg[0];
  43. }
  44.  
  45. if($font) $font = "style='color:{$font};'";
  46. if($bg) $bg = "background-image: url(".$bg.");";
  47.  
  48. $output = "";
  49.  
  50. $output .='<div id="av_product_description" class="avia-section main_color avia-section-large avia-no-border-styling avia-full-stretch av-parallax-section av-section-color-overlay-active avia-bg-style-parallax container_wrap fullsize" data-section-bg-repeat="stretch" '.$font.'>';
  51. $output .='<div class="av-parallax avia-full-stretch" data-avia-parallax-ratio="0.3">';
  52. $output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">';
  53. $output .='</div>';
  54. $output .='</div>';
  55.  
  56. $output .='<div class="av-section-color-overlay-wrap">';
  57. if(!empty($overlay))
  58. {
  59. $output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>';
  60. }
  61.  
  62. $output .='<div class="container">';
  63. $output .='<main class="template-page content av-content-full alpha units">';
  64. $output .= "<h1>".get_the_archive_title()."</h1>";
  65. if(false) $output .= "<h1>".$description."</h1>";
  66. $output .='</main></div></div></div>';
  67.  
  68. return $output;
  69. }
  70.  
  71. function avia_woocommerce_big_cat_banner_child_theme()
  72. {
  73. if(is_product_category())
  74. {
  75. global $wp_query, $avia_config;
  76.  
  77. if(isset($wp_query->query_vars['taxonomy']))
  78. {
  79. $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
  80. if(!empty($term->term_id))
  81. {
  82. $description = term_description() ;
  83. $style = get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
  84. $attachment_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
  85.  
  86. $overlay = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay');
  87. $font = get_woocommerce_term_meta($term->term_id, 'av-banner-font');
  88. $opacity = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity');
  89.  
  90. if(!empty($style))
  91. {
  92. remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
  93. echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font);
  94. $avia_config['woo-banner'] = true;
  95. }
  96. }
  97. }
  98. }
  99. }
  100. }
  101.  
  102. /**
  103. * Show an archive description on taxonomy archives.
  104. */
  105. function woocommerce_taxonomy_archive_description() {
  106. if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
  107. $term = get_queried_object();
  108.  
  109. if ( $term && ! empty( $term->name ) ) {
  110. if(is_tax("product_tag")) {
  111. echo '<h1 class="h1tag">' . wp_kses_post( $term->name ) . '</h1>';
  112. }
  113. echo '<p class="ptag">' . wp_kses_post( $term->description ) . '</p>';
  114. }
  115. }
  116. }
  117.  
  118. /**
  119. * Archive descriptions.
  120. *
  121. * @see woocommerce_taxonomy_archive_description()
  122. * @see woocommerce_product_archive_description()
  123. */
  124.  
  125. // ADD PRODUCT CATEGORY DESCRIPTION IN RIGHT PLACE
  126. add_action("wp", function() {
  127. if ( is_tax("product_cat") ) {
  128. add_action( "woocommerce_before_shop_loop", "woocommerce_taxonomy_archive_description", 10 );
  129. add_action( "woocommerce_before_shop_loop", "woocommerce_before_shop_loop", 10 );
  130. }
  131. }, 20);
  132.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement