• Resolved holle75

    (@holle75)


    Hi, function show_brands_in_loop()

    public static function show_brands_in_loop() {
    		$brands_in_loop      = get_option( 'wc_pwb_admin_tab_brands_in_loop' );
    		$image_size_selected = get_option( 'wc_pwb_admin_tab_brand_logo_size', 'thumbnail' );
    
    		if ( $brands_in_loop == 'brand_link' || $brands_in_loop == 'brand_image' ) {
    
    			global $product;
    			$product_id     = $product->get_id();
    			$product_brands = wp_get_post_terms( $product_id, 'pwb-brand' );
    			if ( ! empty( $product_brands ) ) {
    				echo '<div class="pwb-brands-in-loop">';
    				foreach ( $product_brands as $brand ) {
    
    					echo '<span>';
    					$brand_link    = get_term_link( $brand->term_id, 'pwb-brand' );
    					$attachment_id = get_term_meta( $brand->term_id, 'pwb_brand_image', 1 );
    
    					$attachment_html = wp_get_attachment_image( $attachment_id, $image_size_selected );
    					if ( ! empty( $attachment_html ) && $brands_in_loop == 'brand_image' ) {
    						echo '<a href="' . esc_url( $brand_link ) . '">' . wp_kses_post( $attachment_html ) . '</a>';
    					} else {
    						if ( $brand !== $product_brands[0] ) {
    							echo wp_kses_post( get_option( 'wc_pwb_admin_tab_brands_in_loop_separator', '' ) );
    						}
    						echo '<a href="' . esc_url( $brand_link ) . '">' . esc_html( $brand->name ) . '</a>';
    					}
    					echo '</span>';
    				}
    				echo '</div>';
    			}
    		}
    	}

    in

    /wp-content/plugins/perfect-woocommerce-brands/classes/class-perfect-woocommerce-brands.php

    creates nested <a> … product page (reduced)

    <a href=>
    	<div>
    		<span>
    		</span>
    	</div>
    	<img width="300" height="300"> 			
    	<div class="pwb-brands-in-loop">
    		<span>
    			<a href="">Le Moline</a>
    		</span>
    	</div>
    </a>

    in product archive page … (reduced)

    <a href="" class="woocommerce-LoopProduct-link woocommerce-loop-product__link">
    	<div>
    		<span class=""> 
    		</span>
    	</div>
    	<img width="300" height="300" />
    	<div class="pwb-brands-in-loop">
    		<span>
    			<a href="">Casa Vespina</a>
    		</span>
    		<span>
    			<a href="">Qualiterbe</a>
    		</span>
    	</div>
    </a>

    it works, but browsers don′t like it. Just for info.

    more info https://www.sarasoueidan.com/blog/nested-links/

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘nested links in class-perfect-woocommerce-brands.php’ is closed to new replies.