mercredi 29 juin 2016

WordPress shortcode displaying as plain text

we have been using a plugin on a website for over a year but for some reason the shortcode is now outputting as a plain text, so actually showing the shortcode itself. The shortcode should produce a product slider.

the plugin in question is: WPB WooCommerce Product slider

The website is: http://ift.tt/29oezrk

The entire page was created inside the WYWYG editor inclusive of the shortcodes. Im unfortunately in a position where I cant start disabling the plugins to identify if theres a conflict.

I have been looking all over the web, I did check out the shortcodes.php file thats included witihn the plugin and I can see in there:

add_shortcode('wpb-latest-product', 'wpb_wps_shortcode');

if( !function_exists( 'wpb_wps_shortcode' ) ):
    function wpb_wps_shortcode($atts){
        extract(shortcode_atts(array(
            'title' => __( 'Latest Products','wpb-wps' ),
        ), $atts));

        $return_string = '<div class="wpb_slider_area wpb_fix_cart">';
        $return_string .= '<h3 class="wpb_area_title">'.$title.'</h3>';
        $return_string .= '<div id="wpb-wps-latest" class="wpb-wps-wrapper owl-carousel '.wpb_ez_get_option( "wpb_slider_type_gen_lat", "wpb_wps_style", "grid cs-style-3" ).'">';

        $args = array(
            'post_type'         => 'product',
            'posts_per_page'    => wpb_ez_get_option( 'wpb_num_pro', 'wpb_wps_general', 12 )
        );

        $loop = new WP_Query( $args );

        if ( $loop->have_posts() ) {
            while ( $loop->have_posts() ) : $loop->the_post();
                global $post, $product;
                $return_string .= '<div class="item">';
                $return_string .= '<figure>';           
                $return_string .= '<a href="'.get_permalink().'" class="wpb_pro_img_url">';
                if (has_post_thumbnail( $loop->post->ID )){
                    $return_string .= get_the_post_thumbnail($loop->post->ID, 'shop_catalog', array('class' => "wpb_pro_img"));
                }else{
                    $return_string .= '<img id="place_holder_thm" src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" />';
                }
                $return_string .='</a>';
                $return_string .='<figcaption>';
                $return_string .='<h3 class="pro_title">';
                if (strlen($post->post_title) > 20) {
                    $return_string .= substr(the_title($before = '', $after = '', FALSE), 0, wpb_ez_get_option( 'wpb_title_mx_ch', 'wpb_wps_style', 10 )) . '...';
                }else{
                    $return_string .= get_the_title();
                }
                $return_string .='</h3>';
                if( $price_html = $product->get_price_html() ){
                    $return_string .='<div class="pro_price_area">'. $price_html .'</div>';
                }
                $return_string .= '<div class="wpb_wps_cart_button"><a href="'.esc_url( $product->add_to_cart_url() ).'" rel="nofollow" data-product_id="'.esc_attr( $product->id ).'" data-product_sku="'.esc_attr( $product->get_sku() ).'" data-quantity="'.esc_attr( isset( $quantity ) ? $quantity : 1 ).'" class="button '. ($product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '') .' product_type_'.esc_attr( $product->product_type ).'">'.esc_html( $product->add_to_cart_text()).'</a></div>';
                $return_string .='</figcaption>';
                $return_string .= '</figure>';
                $return_string .= '</div>';
            endwhile;
        } else {
            echo __( 'No products found','wpb-wps' );
        }
        wp_reset_postdata();
        $return_string .= '</div>';
        $return_string .= '</div>';
        wp_reset_query();
        return $return_string;   
    }
endif;

The shortcode I am using is [wpb-latest-product title=”Latest Product”]

I am seeing if anyone else has encountered this? Or what the best steps are to diagnose such issues.

Also, I tried adding the shortcode in the 'text' tab rather than the 'visual' tab but had no effect.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire