Support » Plugin: Custom Product Tabs for WooCommerce » WP AMP conflict with tabs

  • Resolved oleg_yanchuk

    (@oleg_yanchuk)


    Hi! Thanks for the nice plugin. Got the issue with WP AMP plugin (https://wordpress.org/support/plugin/amp/).

    The tab output is not correct.

    https://www.zipsil.ru/conductive-silicone-emi-rfi-shielding-square-profile/amp/?112

    <?php
    $tabs = apply_filters( 'woocommerce_product_tabs', array() );
    global $wp_query, $post;
    $postid = $post->ID;
    if ( ! empty( $tabs ) && dima_helper::dima_am_i_true( dima_helper::dima_get_option( 'dima_shop_product_tap_display' ) ) ) { ?>
        <amp-accordion>
    		<?php foreach ( $tabs as $key => $tab ) : ?>
    
                <section>
                    <h4><?php echo apply_filters( 'woocommerce_product_' . esc_attr( $key ) . '_tab_title', esc_html( $tab['title'] ), $key ); ?></h4>
                    <div>
    					<?php
    					if ( 'description' == $key ) {
    						the_excerpt();
    					} else if ( 'reviews' == $key ) {
    						$comments_link_url = get_permalink( $postid );
    						?>
    						<?php if ( $comments_link_url ) : ?>
    							<?php $comments_link_text = __( 'Submit Review', 'noor' );
    							?>
                                <a class="dima-button fill float-center"
                                   href="<?php echo esc_url( $comments_link_url . "#tab-reviews" ); ?>">
    								<?php echo esc_html( $comments_link_text ); ?>
                                </a>
    						<?php endif;
    					} else {
    						call_user_func( $tab['callback'], $key, $tab );
    					}
    					?>
                    </div>
                </section>
    
    		<?php endforeach; ?>
        </amp-accordion>
    <?php } ?>

    WP AMP plugin adds carousel for somekind of reason.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @oleg_yanchuk,

    Can you explain to me what the issue is? I am seeing the <amp-accordion> HTML on the page and it looks like it’s working. I can’t tell what the problem is.

    Let me know.

    Thank you,
    Kevin.

    Hi Kevin!
    Thanks for the fast reply.

    Yes, amp-accordion is there, but within the amp-accordion the amp-carousel and product price are inserted for the custom tabs. There should not be amp-carousel and prices there.

    You can check the last two custom tabs in amp page. They got amp-carousel under accordion. There should not be any amp-carousel and product price there.

    AMP page:
    https://www.zipsil.ru/conductive-silicone-emi-rfi-shielding-square-profile/amp/?11s

    Non amp page:
    https://www.zipsil.ru/conductive-silicone-emi-rfi-shielding-square-profile/

    Please check the last two custom tabs. They both are custom tabs and they both got the same issue.

    Thanks,
    Oleg

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi Oleg,

    I think I see the issue – the last two custom tabs are repeating the same content as the product? Is that right?

    You don’t have an amp-carousel defined for the tab (on the admin) but that’s what’s showing on the front-end. Is that the problem?

    If so, try adding these filter functions:

    add_filter( 'yikes_woo_use_the_content_filter', '__return_false' );
    
    add_filter( 'yikes_woo_filter_main_tab_content', 'yikes_woo_custom_tab_content_filter', 10, 1 );
    
    function yikes_woo_custom_tab_content_filter( $content ) {
    
    	$content = function_exists( 'capital_P_dangit' ) ? capital_P_dangit( $content ) : $content;
    	$content = function_exists( 'wptexturize' ) ? wptexturize( $content ) : $content;
    	$content = function_exists( 'convert_smilies' ) ? convert_smilies( $content ) : $content;
    	$content = function_exists( 'wpautop' ) ? wpautop( $content ) : $content;
    	$content = function_exists( 'shortcode_unautop' ) ? shortcode_unautop( $content ) : $content;
    	$content = function_exists( 'prepend_attachment' ) ? prepend_attachment( $content ) : $content;
    	$content = function_exists( 'wp_make_content_images_responsive' ) ? wp_make_content_images_responsive( $content ) : $content;
    	$content = function_exists( 'do_shortcode' ) ? do_shortcode( $content ) : $content;
    
    	if ( class_exists( 'WP_Embed' ) ) {
    
    		// Deal with URLs
    		$embed = new WP_Embed;
    		$content = method_exists( $embed, 'autoembed' ) ? $embed->autoembed( $content ) : $content;
    	}	
    
    	return $content;
    }

    Let me know if you need help applying these tabs or if I have misunderstood the problem.

    Cheers,
    Kevin.

    Hi @yikesitskevin. I am trying to replicate the error from my side. The theme you are using features a custom AMP reader mode template. While I am checking do you mind letting me know the other plugins you are also using, and did you test with another theme?

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Hi @jamesosborne, I think you’re looking for these answers from @oleg_yanchuk, no?

    Hi James & Kevin.

    James.

    1. Yes, I’m using AMP reader mode.

    2. Got a lot of plugins installed. I’ll disable them and check it this still an issue.

    3. I’ll check the issue with another theme.

    Kevin, thanks for the code.
    I’ll test your code and let you know.

    Oleg

    oleg_yanchuk

    (@oleg_yanchuk)

    Hi Kevin!

    I inserted the code you provided in functions.php.
    It worked! Thank you! It’s awesome!

    I no longer see the issue.

    So, What’s the best solution for it?
    Just leaving out the code?

    Oleg

    Plugin Contributor yikesitskevin

    (@yikesitskevin)

    Leave the code there – that’s the best solution. Quite a few of our users (who also use page builder plugins) use this snippet.

    Good! Thank you, Kevin!

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.