Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ADD PRODUCT CATEGORY DESCRIPTION IN RIGHT PLACE
- add_filter("get_the_archive_title_prefix", "__return_empty_string");
- add_action( 'init', 'avia_woocommerce_full_width_category_images', 50 );
- function avia_woocommerce_full_width_category_images()
- {
- remove_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner', 11 );
- remove_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner', 11 );
- add_action( 'ava_after_main_container', 'avia_woocommerce_big_cat_banner_child_theme', 11);
- //add_action( 'ava_after_main_container', 'avia_woocommerce_shop_banner_child_theme', 11);
- function avia_woocommerce_shop_banner_child_theme()
- {
- global $avia_config;
- if(is_shop() || (is_product_category() && avia_get_option('shop_banner_global') == "shop_banner_global") && !isset($avia_config['woo-banner']))
- {
- $options = avia_get_option();
- if( isset( $options['shop_banner'] ) && ( $options['shop_banner'] == 'av-active-shop-banner' ) )
- {
- $bg = $options['shop_banner_image'];
- $overlay = $options['shop_banner_overlay_color'];
- $opacity = $options['shop_banner_overlay_opacity'];
- $description= wpautop($options['shop_banner_message']);
- $font = $options['shop_banner_message_color'];
- echo avia_woocommerce_parallax_banner($bg, $overlay, $opacity, $description, $font);
- }
- }
- }
- function avia_woocommerce_parallax_banner_child_theme($bg, $overlay, $opacity, $description, $font)
- {
- if(is_numeric($bg))
- {
- $bg = wp_get_attachment_image_src($bg, 'full');
- if(is_array($bg) && $bg[0] != "") $bg = $bg[0];
- }
- if($font) $font = "style='color:{$font};'";
- if($bg) $bg = "background-image: url(".$bg.");";
- $output = "";
- $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.'>';
- $output .='<div class="av-parallax avia-full-stretch" data-avia-parallax-ratio="0.3">';
- $output .='<div class="av-parallax-inner" style="'.$bg.' main_color background-attachment: scroll; background-position: 50% 50%; background-repeat: no-repeat;">';
- $output .='</div>';
- $output .='</div>';
- $output .='<div class="av-section-color-overlay-wrap">';
- if(!empty($overlay))
- {
- $output .='<div class="av-section-color-overlay" style="opacity: '.$opacity.'; background-color: '.$overlay.'; "></div>';
- }
- $output .='<div class="container">';
- $output .='<main class="template-page content av-content-full alpha units">';
- $output .= "<h1>".get_the_archive_title()."</h1>";
- if(false) $output .= "<h1>".$description."</h1>";
- $output .='</main></div></div></div>';
- return $output;
- }
- function avia_woocommerce_big_cat_banner_child_theme()
- {
- if(is_product_category())
- {
- global $wp_query, $avia_config;
- if(isset($wp_query->query_vars['taxonomy']))
- {
- $term = get_term_by( 'slug', get_query_var($wp_query->query_vars['taxonomy']), $wp_query->query_vars['taxonomy']);
- if(!empty($term->term_id))
- {
- $description = term_description() ;
- $style = get_woocommerce_term_meta($term->term_id, 'av_cat_styling');
- $attachment_id = get_woocommerce_term_meta($term->term_id, 'thumbnail_id');
- $overlay = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay');
- $font = get_woocommerce_term_meta($term->term_id, 'av-banner-font');
- $opacity = get_woocommerce_term_meta($term->term_id, 'av-banner-overlay-opacity');
- if(!empty($style))
- {
- remove_action( 'woocommerce_before_shop_loop', 'woocommerce_taxonomy_archive_description', 11 );
- echo avia_woocommerce_parallax_banner_child_theme($attachment_id, $overlay, $opacity, $description, $font);
- $avia_config['woo-banner'] = true;
- }
- }
- }
- }
- }
- }
- /**
- * Show an archive description on taxonomy archives.
- */
- function woocommerce_taxonomy_archive_description() {
- if ( is_product_taxonomy() && 0 === absint( get_query_var( 'paged' ) ) ) {
- $term = get_queried_object();
- if ( $term && ! empty( $term->name ) ) {
- if(is_tax("product_tag")) {
- echo '<h1 class="h1tag">' . wp_kses_post( $term->name ) . '</h1>';
- }
- echo '<p class="ptag">' . wp_kses_post( $term->description ) . '</p>';
- }
- }
- }
- /**
- * Archive descriptions.
- *
- * @see woocommerce_taxonomy_archive_description()
- * @see woocommerce_product_archive_description()
- */
- // ADD PRODUCT CATEGORY DESCRIPTION IN RIGHT PLACE
- add_action("wp", function() {
- if ( is_tax("product_cat") ) {
- add_action( "woocommerce_before_shop_loop", "woocommerce_taxonomy_archive_description", 10 );
- add_action( "woocommerce_before_shop_loop", "woocommerce_before_shop_loop", 10 );
- }
- }, 20);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement