public static function wc_placeholder_img_src() { if (self::is_wc_version_gte_2_1()) { return wc_placeholder_img_src(); } else { return woocommerce_placeholder_img_src(); } }
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $post, $woocommerce, $data; if (!$placeholder_width) { if (function_exists('wc_get_image_size')) { $placeholder_width = wc_get_image_size('shop_catalog_image_width'); } else { $placeholder_width = $woocommerce->get_image_size('shop_catalog_image_width'); } } if (!$placeholder_height) { if (function_exists('wc_get_image_size')) { $placeholder_height = wc_get_image_size('shop_catalog_image_height'); } else { $placeholder_height = $woocommerce->get_image_size('shop_catalog_image_height'); } } $output = '<div class="image">'; if (has_post_thumbnail()) { $width = '150'; $height = '130'; if (!empty($data['woo_cat_image_size'])) { $width = $data['woo_cat_image_size']['width']; $height = $data['woo_cat_image_size']['height']; } $image = vt_resize(get_post_thumbnail_id($post->ID), '', $width, $height, true); $output .= '<a href="' . get_permalink() . '"><img src="' . $image['url'] . '" alt=""></a>'; } else { $output .= '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />'; } $output .= '</div>'; return $output; }
/** * widget function. * * @see WP_Widget * @access public * @param array $args * @param array $instance * @return void */ function widget($args, $instance) { global $woocommerce; // Use default title as fallback $title = '' === $instance['title'] ? __('Random Products', 'woocommerce') : $instance['title']; $title = apply_filters('widget_title', $title, $instance, $this->id_base); // Setup product query $query_args = array('post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $instance['number'], 'orderby' => 'rand', 'no_found_rows' => 1); $query_args['meta_query'] = array(); if (!$instance['show_variations']) { $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $query_args['post_parent'] = 0; } $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query = new WP_Query($query_args); if ($query->have_posts()) { echo $args['before_widget']; if ('' !== $title) { echo $args['before_title'], $title, $args['after_title']; } ?> <ul class="product_list_widget"> <?php while ($query->have_posts()) { $query->the_post(); global $product; ?> <li> <a href="<?php the_permalink(); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail('shop_thumbnail'); } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $woocommerce->get_image_size('shop_thumbnail_image_width') . '" height="' . $woocommerce->get_image_size('shop_thumbnail_image_height') . '" />'; } ?> <?php the_title(); ?> </a> <?php echo $product->get_price_html(); ?> </li> <?php } ?> </ul> <?php echo $args['after_widget']; } }
public static function woops_get_product_thumbnail($post_id, $size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $woocommerce; $woocommerce_db_version = get_option('woocommerce_db_version', null); $shop_catalog = version_compare($woocommerce_db_version, '2.1', '<') ? $woocommerce->get_image_size('shop_catalog') : wc_get_image_size('shop_catalog'); if (is_array($shop_catalog) && isset($shop_catalog['width']) && $placeholder_width == 0) { $placeholder_width = $shop_catalog['width']; } if (is_array($shop_catalog) && isset($shop_catalog['height']) && $placeholder_height == 0) { $placeholder_height = $shop_catalog['height']; } if (has_post_thumbnail($post_id)) { return get_the_post_thumbnail($post_id, $size); } $mediumSRC = ''; if (trim($mediumSRC == '')) { $args = array('post_parent' => $post_id, 'numberposts' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'DESC', 'orderby' => 'ID', 'post_status' => null); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { $mediumSRC = wp_get_attachment_image($attachment->ID, $size, true); break; } } } if (trim($mediumSRC == '')) { // Load the product $product = get_post($post_id); // Get ID of parent product if one exists if (!empty($product->post_parent)) { $post_id = $product->post_parent; } if (has_post_thumbnail($post_id)) { return get_the_post_thumbnail($post_id, $size); } if (trim($mediumSRC == '')) { $args = array('post_parent' => $post_id, 'numberposts' => 1, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'DESC', 'orderby' => 'ID', 'post_status' => null); $attachments = get_posts($args); if ($attachments) { foreach ($attachments as $attachment) { $mediumSRC = wp_get_attachment_image($attachment->ID, $size, true); break; } } } } if (trim($mediumSRC != '')) { return $mediumSRC; } else { return '<img src="' . (version_compare($woocommerce_db_version, '2.1', '<') ? woocommerce_placeholder_img_src() : wc_placeholder_img_src()) . '" alt="Placeholder" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />'; } }
function jck_quickview_content() { global $post, $product, $woocommerce; echo '<div class="hide">'; echo '<div itemscope itemtype="http://schema.org/Product" id="product-' . get_the_ID() . '" class="jck_quickview product">'; echo '<div class="images">'; if (has_post_thumbnail()) { echo get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single')); } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" class="attachment-shop_single wp-post-image" />'; } $attachment_ids = $product->get_gallery_attachment_ids(); if ($attachment_ids) { ?> <div class="thumbnails"><?php if (has_post_thumbnail()) { array_unshift($attachment_ids, get_post_thumbnail_id($post->ID)); } $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); foreach ($attachment_ids as $attachment_id) { $wrapClasses = array('quickviewThumbs-' . $columns . 'col', 'jck_quickview_thumb'); $classes = array('attachment-shop_thumbnail'); if ($loop == 0 || $loop % $columns == 0) { $wrapClasses[] = 'first'; } if ($loop == 0) { $wrapClasses[] = 'firstThumb'; } if (($loop + 1) % $columns == 0) { $wrapClasses[] = 'last'; } $image_class = esc_attr(implode(' ', $classes)); $lrgImg = wp_get_attachment_image_src($attachment_id, 'shop_single'); echo '<a href="' . $lrgImg[0] . '" class="' . esc_attr(implode(' ', $wrapClasses)) . '">' . wp_get_attachment_image($attachment_id, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail'), false, array('class' => $image_class)) . '</a>'; $loop++; } ?> </div> <?php } echo '</div>'; echo '<div class="summary entry-summary">'; do_action('jck_quickview_single_product_summary'); echo '</div><!-- .summary -->'; echo '</div><!-- #product-' . get_the_ID() . ' -->'; echo '</div>'; }
function woocommerce_subcategory_thumbnail($category) { // Figure $figure = \Drone\HTML::figure()->class('featured full-width'); // Hyperlink $a = $figure->addNew('a')->attr(Everything::getImageAttrs('a', array('fancybox' => false)))->href(get_term_link($category->slug, 'product_cat')); // Thumbnail $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true); $thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_catalog'); if ($thumbnail_id) { $a->add(wp_get_attachment_image($thumbnail_id, $thumbnail_size)); } elseif (woocommerce_placeholder_img_src()) { $a->add(woocommerce_placeholder_img($thumbnail_size)); } echo $figure->html(); }
public function woocommerce_template_loop_product_thumbnail() { global $post, $product, $woocommerce; $placeholder_width = get_option('shop_catalog_image_size'); $placeholder_width = $placeholder_width['width']; $placeholder_height = get_option('shop_catalog_image_size'); $placeholder_height = $placeholder_height['height']; $output = ''; $class = 'image-no-effect'; if (has_post_thumbnail()) { $attachment_ids = $product->get_gallery_attachment_ids(); if ($attachment_ids) { $class = 'image-effect'; $output .= wp_get_attachment_image($attachment_ids[0], 'shop_catalog', false, array('class' => "attachment-shop_catalog image-hover")); } $output .= get_the_post_thumbnail($post->ID, 'shop_catalog', array('class' => $class)); } else { $output .= '<img src="' . woocommerce_placeholder_img_src() . '" alt="' . __('Placeholder', 'gp_lang') . '" class="' . $class . '" width="' . $placeholder_width . '" height="' . $placeholder_height . '" />'; } echo $output; }
/** * get_template_image_file_info( $file ) * * @access public * @since 3.8 * @param $file string filename * @return PATH to the file */ public static function get_template_image_file_info($file = '') { // If we're not looking for a file, do not proceed if (empty($file)) { return; } // Look for file in stylesheet $image_info = array(); if (file_exists(get_stylesheet_directory() . '/images/' . $file)) { $file_url = get_stylesheet_directory_uri() . '/images/' . $file; list($current_width, $current_height) = getimagesize(get_stylesheet_directory() . '/images/' . $file); $image_info['url'] = $file_url; $image_info['width'] = $current_width; $image_info['height'] = $current_height; // Look for file in template } elseif (file_exists(get_template_directory() . '/images/' . $file)) { $file_url = get_template_directory_uri() . '/images/' . $file; list($current_width, $current_height) = getimagesize(get_template_directory() . '/images/' . $file); $image_info['url'] = $file_url; $image_info['width'] = $current_width; $image_info['height'] = $current_height; // Backwards compatibility } else { $woocommerce_db_version = get_option('woocommerce_db_version', null); $file_url = version_compare($woocommerce_db_version, '2.1', '<') ? woocommerce_placeholder_img_src() : wc_placeholder_img_src(); list($current_width, $current_height) = getimagesize($file_url); $image_info['url'] = $file_url; $image_info['width'] = $current_width; $image_info['height'] = $current_height; } if (is_ssl()) { $file_url = str_replace('http://', 'https://', $file_url); $image_info['url'] = $file_url; } return $image_info; }
if ($presizeimage == 1) { $product_image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); $product_image_url = $product_image[0]; $image_url = aq_resize($product_image_url, $productimgwidth, $productimgheight, true); if (empty($image_url)) { $image_url = $product_image_url; } $image = '<img width="' . $productimgwidth . '" height="' . $productimgheight . '" src="' . $image_url . '" class="attachment-shop_single wp-post-image" title="' . esc_attr(get_the_title(get_post_thumbnail_id())) . '">'; } else { $image = get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single'), array('title' => $image_title)); } $image_title = esc_attr(get_the_title(get_post_thumbnail_id())); $image_link = wp_get_attachment_url(get_post_thumbnail_id()); $attachment_count = count($product->get_gallery_attachment_ids()); if ($attachment_count > 0) { $gallery = '[product-gallery]'; } else { $gallery = ''; } echo apply_filters('woocommerce_single_product_image_html', sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image zoom" title="%s" rel="lightbox' . $gallery . '">%s</a>', $image_link, $image_title, $image), $post->ID); } else { echo apply_filters('woocommerce_single_product_image_html', sprintf('<img src="%s" alt="Placeholder" />', woocommerce_placeholder_img_src()), $post->ID); } ?> </div> <?php do_action('woocommerce_product_thumbnails'); ?> </div>
/** @see WP_Widget */ function widget($args, $instance) { global $woocommerce; $cache = wp_cache_get('widget_best_sellers', 'widget'); if (!is_array($cache)) { $cache = array(); } if (isset($cache[$args['widget_id']])) { echo $cache[$args['widget_id']]; return; } ob_start(); extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Best Sellers', 'woocommerce') : $instance['title'], $instance, $this->id_base); if (!($number = (int) $instance['number'])) { $number = 10; } else { if ($number < 1) { $number = 1; } else { if ($number > 15) { $number = 15; } } } $query_args = array('posts_per_page' => $number, 'post_status' => 'publish', 'post_type' => 'product', 'meta_key' => 'total_sales', 'orderby' => 'meta_value', 'no_found_rows' => 1); $query_args['meta_query'] = array(); if (isset($instance['hide_free']) && 1 == $instance['hide_free']) { $query_args['meta_query'][] = array('key' => '_price', 'value' => 0, 'compare' => '>', 'type' => 'DECIMAL'); } $query_args['meta_query'][] = $woocommerce->query->stock_status_meta_query(); $query_args['meta_query'][] = $woocommerce->query->visibility_meta_query(); $r = new WP_Query($query_args); if ($r->have_posts()) { ?> <?php echo $before_widget; ?> <?php if ($title) { echo $before_title . $title . $after_title; } ?> <ul class="product_list_widget"> <?php while ($r->have_posts()) { $r->the_post(); global $product; ?> <li><a href="<?php the_permalink(); ?> " title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?> "> <?php if (has_post_thumbnail()) { the_post_thumbnail('shop_thumbnail'); } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $woocommerce->get_image_size('shop_thumbnail_image_width') . '" height="' . $woocommerce->get_image_size('shop_thumbnail_image_height') . '" />'; } ?> <?php if (get_the_title()) { the_title(); } else { the_ID(); } ?> </a> <?php echo $product->get_price_html(); ?> </li> <?php } ?> </ul> <?php echo $after_widget; } $content = ob_get_clean(); if (isset($args['widget_id'])) { $cache[$args['widget_id']] = $content; } echo $content; wp_cache_set('widget_best_sellers', $cache, 'widget'); }
/** * Thumbnail column value added to brand admin. * * @access public * @param mixed $columns * @param mixed $column * @param mixed $id * @return void */ function dhwc_product_brand_column($columns, $column, $id) { global $woocommerce; if ($column == 'thumb') { $image = ''; $thumbnail_id = get_woocommerce_term_meta($id, 'thumbnail_id', true); if ($thumbnail_id) { $image = wp_get_attachment_thumb_url($thumbnail_id); } else { $image = woocommerce_placeholder_img_src(); } $columns .= '<img src="' . $image . '" alt="Thumbnail" class="wp-post-image" height="48" width="48" />'; } return $columns; }
/** * (non-PHPdoc) * @see wp-includes/WP_Widget::widget() */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', empty($instance['title']) ? __('Brands', DH_DOMAIN) : $instance['title'], $instance, $this->id_base); $o = isset($instance['orderby']) ? $instance['orderby'] : 'order'; $h = $instance['hide_empty'] ? true : false; if ($o == 'name') { $order = 'asc'; } else { $order = 'desc'; } $brands = get_terms('product_brand', array('hide_empty' => $h, 'orderby' => $o, 'order' => $order)); if (!$brands) { return; } echo $before_widget; if ($title) { echo $before_title . $title . $after_title; } ?> <div class="product-brand-slide"> <ul id="pb-<?php echo $args['widget_id']; ?> " class="list-brand"> <?php foreach ($brands as $brand) { ?> <?php $thumbnail = dhwc_get_product_brand_thumbnail_url($brand->term_id); if (!$thumbnail) { $thumbnail = woocommerce_placeholder_img_src(); } ?> <li class="item"> <a title="<?php echo $brand->name; ?> " href="<?php echo get_term_link($brand->slug, 'product_brand'); ?> "> <img alt="<?php echo $brand->name; ?> " src="<?php echo $thumbnail; ?> "> </a> <h2><a title="<?php echo $brand->name; ?> " href="<?php echo get_term_link($brand->slug, 'product_brand'); ?> "><?php echo $brand->name; ?> </a></h2> </li> <?php } ?> </ul> </div> <script type="text/javascript"> <!-- jQuery(document).ready(function($){ $('#pb-<?php echo $args['widget_id']; ?> ').bxSlider(); }); //--> </script> <?php echo $after_widget; }
public function load_product_content_callback() { $prod_id = absint($_GET['product_id']); $this->id = $prod_id; global $post, $product, $woocommerce; $post = get_post($prod_id); $product = get_product($prod_id); if ($prod_id <= 0) { die('Invalid Products'); } if (!isset($post->post_type) || strcmp($post->post_type, 'product') != 0) { die('Invalid Products'); } add_filter('woocommerce_add_to_cart_url', array($this, 'update_qs_add_to_cart_url'), 10); remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_sharing', 1000); remove_action('woocommerce_product_thumbnails', 'woocommerce_template_single_sharing', 50); global $wd_data; if (isset($wd_data['wd_catelog_mod']) && $wd_data['wd_catelog_mod'] == 0) { remove_action('wd_quickshop_single_product_summary', 'woocommerce_template_single_add_to_cart', 11); } ob_start(); ?> <div itemscope itemtype="http://schema.org/Product" id="product-<?php echo get_the_ID(); ?> " class="wd_quickshop product"> <div class="images"> <?php do_action('wd_qs_before_product_image'); ?> <?php if (has_post_thumbnail()) { $image_title = esc_attr($product->get_title()); $image = get_the_post_thumbnail($post->ID, apply_filters('single_product_large_thumbnail_size', 'shop_single'), array('alt' => $image_title, 'title' => $image_title)); $image_link = wp_get_attachment_url(get_post_thumbnail_id()); $attachment_count = count($product->get_gallery_attachment_ids()); echo apply_filters('woocommerce_single_product_image_html', sprintf('<a href="%s" itemprop="image" class="woocommerce-main-image cloud-zoom zoom wd_qs_main_image" title="%s" id=\'qs-zoom\' rel="position:\'right\',showTitle:1,titleOpacity:0.5,lensOpacity:0.5,fixWidth:362,fixThumbWidth:72,fixThumbHeight:72,adjustX: 0, adjustY:0">%s</a>', $image_link, $image_title, $image), $post->ID); } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" class="attachment-shop_single wp-post-image wd_qs_main_image" />'; } $attachment_ids = $product->get_gallery_attachment_ids(); if ($attachment_ids) { ?> <div class="thumbnails list_carousel"> <ul class="qs-thumbnails"> <?php if (has_post_thumbnail()) { array_unshift($attachment_ids, get_post_thumbnail_id($post->ID)); } $loop = 0; $columns = apply_filters('woocommerce_product_thumbnails_columns', 3); foreach ($attachment_ids as $attachment_id) { $wrapClasses = array('quickshop-thumb-' . $columns . 'col', 'wd_quickshop_thumb', 'pop_cloud_zoom cloud-zoom-gallery'); $classes = array('attachment-shop_thumbnail'); if ($loop == 0 || $loop % $columns == 0) { $wrapClasses[] = 'first'; } if ($loop == 0) { $wrapClasses[] = 'firstThumb'; } if (($loop + 1) % $columns == 0) { $wrapClasses[] = 'last'; } $image_class = esc_attr(implode(' ', $classes)); $lrgImg = wp_get_attachment_image_src($attachment_id, 'shop_single'); $lrgImg_full = wp_get_attachment_image_src($attachment_id, 'full'); echo '<li><a href="' . $lrgImg_full[0] . '"rel="useZoom: \'qs-zoom\', smallImage: \'' . $lrgImg[0] . '\'" class="' . esc_attr(implode(' ', $wrapClasses)) . '">' . wp_get_attachment_image($attachment_id, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail'), false, array('class' => $image_class)) . '</a></li>'; $loop++; } ?> </ul> <div class="slider_control"> <a id="qs_thumbnails_prev" class="prev" href="#"><</a> <a id="qs_thumbnails_next" class="next" href="#">></a> </div> </div> <?php } ?> <div class="details_view"> <a href="<?php echo the_permalink(); ?> " title="<?php _e('View Details', 'wpdance'); ?> " ><?php _e('View Details', 'wpdance'); ?> </a> </div> </div> <div class="summary entry-summary"> <?php do_action('wd_quickshop_single_product_summary'); ?> </div><!-- .summary --> </div><!-- #product-<?php echo get_the_ID(); ?> --> <?php remove_filter('woocommerce_add_to_cart_url', array($this, 'update_qs_add_to_cart_url')); $_ret_html = ob_get_contents(); ob_end_clean(); wp_reset_query(); die($_ret_html); }
<div id="<?php echo $this->slug . '_images'; ?> " class="royalSlider rsMinW"> <?php $prodImgs = array(); if (has_post_thumbnail()) { $imgId = get_post_thumbnail_id(); $prodImgs[$imgId]['slideId'][] = '-0-'; $prodImgs[$imgId]['imgSrc'] = wp_get_attachment_image_src(get_post_thumbnail_id(), apply_filters('single_product_large_thumbnail_size', 'shop_single')); $prodImgs[$imgId]['imgThumbSrc'] = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); } else { $prodImgs[0]['slideId'][] = '-0-'; $prodImgs[0]['imgSrc'] = woocommerce_placeholder_img_src(); $prodImgs[0]['imgThumbSrc'] = woocommerce_placeholder_img_src(); } // Additional Images $attachIds = $product->get_gallery_attachment_ids(); $attachment_count = count($attachIds); if (!empty($attachIds)) { foreach ($attachIds as $attachId) { $prodImgs[$attachId]['slideId'][] = '-0-'; $prodImgs[$attachId]['imgSrc'] = wp_get_attachment_image_src($attachId, apply_filters('single_product_large_thumbnail_size', 'shop_single')); $prodImgs[$attachId]['imgThumbSrc'] = wp_get_attachment_image_src($attachId, apply_filters('single_product_small_thumbnail_size', 'shop_thumbnail')); } } // !If is Varibale product if ($product->product_type == 'variable') { $prodVars = $product->get_available_variations(); if (!empty($prodVars)) {
<?php /** * Single Product Image * * @author YIThemes * @package YITH_Magnifier/Templates * @version 1.1.2 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $post, $woocommerce, $product, $is_IE; $enable_slider = get_option('yith_wcmg_enableslider') == 'yes' ? true : false; $placeholder = function_exists('wc_placeholder_img_src') ? wc_placeholder_img_src() : woocommerce_placeholder_img_src(); $slider_items = get_option('yith_wcmg_slider_items', 3); if (!isset($slider_items) || $slider_items == null) { $slider_items = 3; } ?> <?php $attachment_ids = $product->get_gallery_attachment_ids(); if (!empty($attachment_ids)) { $imageclass = 'hasthumb'; } else { $imageclass = 'nothumb'; } ?> <div class="images<?php
public function admin_fields_upload_tabs($value) { $upload_value = get_option($value['id']) !== false && get_option($value['id']) !== null ? esc_attr(stripslashes(get_option($value['id']))) : esc_attr($value['std']); ?> <tr valign="top"> <th scope="row" class="titledesc"> <label for="<?php echo esc_attr($value['id']); ?> "><?php echo $value['name']; ?> </label> </th> <td class="forminp"> <div class="form-field"> <div id="tabs_thumbnail" style="float:left;margin-right:10px;"><img src="<?php echo $upload_value != '' ? wp_get_attachment_thumb_url($upload_value) : woocommerce_placeholder_img_src(); ?> " width="60px" height="60px" /></div> <div style="line-height:60px;"> <input type="hidden" id="<?php echo esc_attr($value['id']); ?> " name="<?php echo esc_attr($value['id']); ?> " value="<?php echo $upload_value; ?> " /> <button type="button" class="upload_image_button button"><?php _e('Upload/Add image', EXTRA_WOO_TABS_TEXTDOMAN); ?> </button> <button type="button" class="remove_image_button button"><?php _e('Remove image', EXTRA_WOO_TABS_TEXTDOMAN); ?> </button> </div> <div class="clear"></div> </div> <?php echo $value['desc']; ?> </td> </tr> <script type="text/javascript"> jQuery(document).ready(function(){ // Only show the "remove image" button when needed if ( ! jQuery('#pw_woocommerce_tabs_default_image').val() ) jQuery('.remove_image_button').hide(); // Uploading files var file_frame; jQuery(document).on( 'click', '.upload_image_button', function( event ){ event.preventDefault(); // If the media frame already exists, reopen it. if ( file_frame ) { file_frame.open(); return; } // Create the media frame. file_frame = wp.media.frames.downloadable_file = wp.media({ title: '<?php _e('Choose an image', EXTRA_WOO_TABS_TEXTDOMAN); ?> ', button: { text: '<?php _e('Use image', EXTRA_WOO_TABS_TEXTDOMAN); ?> ', }, multiple: false }); // When an image is selected, run a callback. file_frame.on( 'select', function() { attachment = file_frame.state().get('selection').first().toJSON(); jQuery('#pw_woocommerce_tabs_default_image').val( attachment.id ); jQuery('#tabs_thumbnail img').attr('src', attachment.url ); jQuery('.remove_image_button').show(); }); // Finally, open the modal. file_frame.open(); }); jQuery(document).on( 'click', '.remove_image_button', function( event ){ jQuery('#tabs_thumbnail img').attr('src', '<?php echo woocommerce_placeholder_img_src(); ?> '); jQuery('#pw_woocommerce_tabs_default_image').val(''); jQuery('.remove_image_button').hide(); return false; }); }); </script> <?php }
/** * Get the placeholder image * * @access public * @return string */ function woocommerce_placeholder_img($size = 'shop_thumbnail') { global $woocommerce; $dimensions = $woocommerce->get_image_size($size); return apply_filters('woocommerce_placeholder_img', '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $dimensions['width'] . '" height="' . $dimensions['height'] . '" />'); }
private function do_javascript() { global $woocommerce; ob_start(); ?> jQuery(document).ready(function($) { var current_field_wrapper; window.send_to_editor_default = window.send_to_editor; jQuery('#swatches').on('click', '.upload_image_button, .remove_image_button', function() { var post_id = jQuery(this).attr('rel'); var parent = jQuery(this).parent(); current_field_wrapper = parent; if (jQuery(this).is('.remove_image_button')) { jQuery('.upload_image_id', current_field_wrapper).val(''); jQuery('img', current_field_wrapper).attr('src', '<?php echo woocommerce_placeholder_img_src(); ?> '); jQuery(this).removeClass('remove'); } else { window.send_to_editor = window.send_to_pidroduct; formfield = jQuery('.upload_image_id', parent).attr('name'); tb_show('', 'media-upload.php?&type=image&TB_iframe=true'); } return false; }); window.send_to_pidroduct = function(html) { jQuery('body').append('<div id="temp_image">' + html + '</div>'); var img = jQuery('#temp_image').find('img'); imgurl = img.attr('src'); imgclass = img.attr('class'); imgid = parseInt(imgclass.replace(/\D/g, ''), 10); jQuery('.upload_image_id', current_field_wrapper).val(imgid); jQuery('img', current_field_wrapper).attr('src', imgurl); var $preview = jQuery(current_field_wrapper).closest('div.sub_field').find('.swatch-wrapper'); jQuery('img', $preview).attr('src', imgurl); tb_remove(); jQuery('#temp_image').remove(); window.send_to_editor = window.send_to_editor_default; } }); <?php $javascript = ob_get_clean(); WC_Swatches_Compatibility::wc_enqueue_js($javascript); }
<a itemprop="image" href="<?php yit_image('size=shop_magnifier&output=url'); ?> " class="yith_magnifier_zoom" rel="thumbnails"><?php yit_image(array('size' => apply_filters('single_product_large_thumbnail_size', 'shop_single'))); ?> </a> <?php } else { ?> <img src="<?php echo woocommerce_placeholder_img_src(); ?> " alt="Placeholder" /> <?php } ?> <?php } ?> <?php
</tr> <tr> <td class="upload_image"> <a href="#" class="upload_image_button <?php if ($image_id > 0) { echo 'remove'; } ?> " rel="<?php echo esc_attr($variation_id); ?> "><img src="<?php if (!empty($image)) { echo esc_attr($image); } else { echo esc_attr(woocommerce_placeholder_img_src()); } ?> " /><input type="hidden" name="upload_image_id[<?php echo $loop; ?> ]" class="upload_image_id" value="<?php echo esc_attr($image_id); ?> " /><span class="overlay"></span></a> </td> <td class="options"> <label><input type="checkbox" class="checkbox" name="variable_enabled[<?php echo $loop; ?> ]" <?php
$random_cat_query = new WP_Query($random_cat_args); while ($random_cat_query->have_posts()) { $random_cat_query->the_post(); global $product; ?> <div class="[ square ][ border ]"> <div class="[ square-content ][ js-product-opener ]"> <div class="[ product-image ][ thumbnail ]"> <div class="[ product-image--sizer ][ center ]"> <?php if (has_post_thumbnail($random_cat_query->post->ID)) { echo get_the_post_thumbnail($random_cat_query->post->ID, 'medium', array('class' => '[ block center ]')); } else { echo '<img class="[ block center ]" src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" />'; } ?> </div> </div> <h4 class="[ text-center ][ ellipsis ][ no-margin ]"><?php the_title(); ?> </h4> <p class="[ text-center ]">de <a href="#"><?php echo get_seller_name(get_the_author_meta('ID')); ?> </a></p> <h5 class="[ text-center ][ product-price ]">
$image_hover_src = $image_src_hover_array[0]; break; case 'medium': $image_src_hover_array = wp_get_attachment_image_src($hover_image_id, 'medium', true); $image_hover_src = $image_src_hover_array[0]; break; default: $image_src_hover_array = wp_get_attachment_image_src($hover_image_id, 'full', true); $image_hover_src = bfi_thumb($image_src_hover_array[0], array('width' => $width * $quality, 'height' => $height * $quality)); break; } echo '<img src="' . $image_hover_src . '" alt="' . get_the_title() . '" class="product-hover-image" title="' . get_the_title() . '">'; } echo '</a>'; } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $width * $quality . '" height="' . $height * $quality . '" />'; } ?> <?php if ($mk_options['woocommerce_catalog'] == 'false') { ?> <div class="product-item-footer"> <?php if ($rating_html = $product->get_rating_html()) { ?> <span class="product-item-rating"><?php echo $rating_html; ?> </span> <?php
?> </div> </div> <?php } else { ?> <div class="recentimage"> <div class="image"> <div class="loading"></div> <?php if (has_post_thumbnail(get_the_ID())) { echo '<img src = ' . $image . ' alt = "' . get_the_title() . '" > '; } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="230px" height="' . $pmc_data['catalog_img_height'] . 'px" />'; } ?> </div> </div> <?php } ?> </a> <div class="recentdescription"> <?php woocommerce_show_product_sale_flash($product); ?> <a href="<?php echo get_permalink(get_the_id()); ?>
global $product; ?> <article> <?php woocommerce_breadcrumb(); ?> <h4><?php echo the_title(); ?> </h4> <?php if (has_post_thumbnail()) { echo the_post_thumbnail('', array('class' => "e-cinza img-responsive")); } else { echo '<img class="img-responsive" src="' . woocommerce_placeholder_img_src() . '" />'; } ?> <span class="price"><?php echo $product->get_price_html(); ?> </span> <a class="btn-comprar" href="<?php echo get_permalink($loop->post->ID); ?> " title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?>
/** * Returns the main product image * * @access public * @param string $size (default: 'shop_thumbnail') * @return string */ function get_image($size = 'shop_thumbnail') { global $woocommerce; $image = ''; if (has_post_thumbnail($this->id)) { $image = get_the_post_thumbnail($this->id, $size); } elseif (($parent_id = wp_get_post_parent_id($this->id)) && has_post_thumbnail($parent_id)) { $image = get_the_post_thumbnail($parent_id, $size); } else { $image = '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="' . $woocommerce->get_image_size('shop_thumbnail_image_width') . '" height="' . $woocommerce->get_image_size('shop_thumbnail_image_height') . '" />'; } return $image; }
function TS_VCSC_WooCommerce_Grid_Basic_Function($atts, $content = null) { global $VISUAL_COMPOSER_EXTENSIONS; global $product; global $woocommerce; ob_start(); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-visual-composer-extend-front'); } } else { wp_enqueue_script('ts-extend-hammer'); wp_enqueue_script('ts-extend-nacho'); wp_enqueue_style('ts-extend-nacho'); wp_enqueue_style('ts-extend-dropdown'); wp_enqueue_script('ts-extend-dropdown'); wp_enqueue_style('ts-font-ecommerce'); wp_enqueue_style('ts-extend-animations'); wp_enqueue_style('dashicons'); if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_LoadFrontEndForcable == "false") { wp_enqueue_style('ts-extend-buttons'); wp_enqueue_style('ts-visual-composer-extend-front'); wp_enqueue_script('ts-extend-isotope'); wp_enqueue_script('ts-visual-composer-extend-front'); } add_action('wp_footer', array($this, 'TS_VCSC_WooCommerce_Grid_Function_Isotope'), 9999); } extract(shortcode_atts(array('selection' => 'recent_products', 'category' => '', 'ids' => '', 'orderby' => 'date', 'order' => 'desc', 'products_total' => 12, 'exclude_outofstock' => 'false', 'show_image' => 'true', 'show_link' => 'true', 'link_page' => 'false', 'link_target' => '_parent', 'show_rating' => 'true', 'show_stock' => 'true', 'show_price' => 'true', 'show_cart' => 'true', 'show_info' => 'true', 'show_content' => 'excerpt', 'cutoff_characters' => 400, 'lightbox_group_name' => 'nachogroup', 'lightbox_size' => 'full', 'lightbox_effect' => 'random', 'lightbox_speed' => 5000, 'lightbox_social' => 'true', 'lightbox_backlight_choice' => 'predefined', 'lightbox_backlight_color' => '#0084E2', 'lightbox_backlight_custom' => '#000000', 'image_position' => 'ts-imagefloat-center', 'hover_type' => 'ts-imagehover-style1', 'hover_active' => 'false', 'overlay_trigger' => 'ts-trigger-hover', 'rating_maximum' => 5, 'rating_value' => 0, 'rating_dynamic' => '', 'rating_quarter' => 'true', 'rating_size' => 16, 'rating_auto' => 'false', 'rating_rtl' => 'false', 'rating_symbol' => 'other', 'rating_icon' => 'ts-ecommerce-starfull1', 'color_rated' => '#FFD800', 'color_empty' => '#e3e3e3', 'caption_show' => 'false', 'caption_position' => 'left', 'caption_digits' => '.', 'caption_danger' => '#d9534f', 'caption_warning' => '#f0ad4e', 'caption_info' => '#5bc0de', 'caption_primary' => '#428bca', 'caption_success' => '#5cb85c', 'post_type' => 'product', 'date_format' => 'F j, Y', 'time_format' => 'l, g:i A', 'filter_menu' => 'true', 'layout_menu' => 'true', 'sort_menu' => 'false', 'directions_menu' => 'false', 'filter_by' => 'product_cat', 'layout' => 'masonry', 'column_width' => 285, 'layout_break' => 600, 'show_periods' => 'false', 'sort_by' => 'postName', 'sort_order' => 'asc', 'posts_limit' => 25, 'posts_lazy' => 'false', 'posts_ajax' => 10, 'posts_load' => 'Show More', 'posts_trigger' => 'click', 'margin_top' => 0, 'margin_bottom' => 0, 'el_id' => '', 'el_class' => '', 'css' => ''), $atts)); $postsgrid_random = mt_rand(999999, 9999999); $opening = $closing = $controls = $products = ''; $posts_limit = $products_total; if (!empty($el_id)) { $posts_container_id = $el_id; } else { $posts_container_id = 'ts-vcsc-woocommerce-grid-' . $postsgrid_random; } // Backlight Color if ($lightbox_backlight_choice == "predefined") { $lightbox_backlight_selection = $lightbox_backlight_color; } else { $lightbox_backlight_selection = $lightbox_backlight_custom; } // Check for Front End Editor if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == "true") { $product_style = ''; $frontend_edit = 'true'; $description_style = 'display: none; padding: 15px;'; } else { $product_style = ''; $frontend_edit = 'false'; $description_style = 'display: none; padding: 15px;'; } $meta_query = ''; // Recent Products if ($selection == "recent_products") { $meta_query = WC()->query->get_meta_query(); } // Featured Products if ($selection == "featured_products") { $meta_query = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN'), array('key' => '_featured', 'value' => 'yes')); } // Top Rated Products if ($selection == "top_rated_products") { add_filter('posts_clauses', array(WC()->query, 'order_by_rating_post_clauses')); $meta_query = WC()->query->get_meta_query(); } // Final Query Arguments $args = array('post_type' => 'product', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => $products_total, 'orderby' => $orderby, 'order' => $order, 'paged' => 1, 'meta_query' => $meta_query); // Products on Sale if ($selection == "sale_products") { $product_ids_on_sale = woocommerce_get_product_ids_on_sale(); $meta_query = array(); $meta_query[] = $woocommerce->query->visibility_meta_query(); $meta_query[] = $woocommerce->query->stock_status_meta_query(); $args['meta_query'] = $meta_query; $args['post__in'] = $product_ids_on_sale; } // Best Selling Products if ($selection == "best_selling_products") { $args['meta_key'] = 'total_sales'; $args['orderby'] = 'meta_value_num'; $args['meta_query'] = array(array('key' => '_visibility', 'value' => array('catalog', 'visible'), 'compare' => 'IN')); } // Products in Single Category if ($selection == "product_category") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => array(esc_attr($category)), 'field' => 'slug', 'operator' => 'IN')); } // Products in Multiple Categories if ($selection == "product_categories") { $args['tax_query'] = array(array('taxonomy' => 'product_cat', 'terms' => explode(",", $ids), 'field' => 'term_id', 'operator' => 'IN')); } $menu_tax = 'product_cat'; $limit_tax = 'product_cat'; // Start WordPress Query $loop = new WP_Query($args); // Language Settings: Isotope Posts $TS_VCSC_Isotope_Posts_Language = get_option('ts_vcsc_extend_settings_translationsIsotopePosts', ''); if ($TS_VCSC_Isotope_Posts_Language == false || empty($TS_VCSC_Isotope_Posts_Language)) { $TS_VCSC_Isotope_Posts_Language = $VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_Isotope_Posts_Language_Defaults; } if (function_exists('vc_shortcode_custom_css_class')) { $css_class = apply_filters(VC_SHORTCODE_CUSTOM_CSS_FILTER_TAG, ' ' . vc_shortcode_custom_css_class($css, ' '), 'TS_VCSC_WooCommerce_Grid_Basic', $atts); } else { $css_class = ''; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'false') { $isotope_posts_list_class = 'ts-posts-timeline-view'; } else { $isotope_posts_list_class = 'ts-posts-timeline-edit'; } if ($VISUAL_COMPOSER_EXTENSIONS->TS_VCSC_VCFrontEditMode == 'true') { echo '<div id="ts-isotope-posts-grid-frontend-' . $postsgrid_random . '" class="ts-isotope-posts-grid-frontend" style="border: 1px solid #ededed; padding: 10px;">'; echo '<div style="font-weight: bold;">"Basic Products Isotope Grid"</div>'; echo '<div style="margin-bottom: 20px;">The element has been disabled in order to ensure compatiblity with the Visual Composer Front-End Editor.</div>'; echo '<div>' . __("Number of Products", "ts_visual_composer_extend") . ': ' . $posts_limit . '</div>'; $front_edit_reverse = array("excerpt" => __('Excerpt', "ts_visual_composer_extend"), "cutcharacters" => __('Character Limited Content', "ts_visual_composer_extend"), "complete" => __('Full Content', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $show_content) { echo '<div>' . __("Content Length", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("masonry" => __('Centered Masonry', "ts_visual_composer_extend"), "fitRows" => __('Fit Rows', "ts_visual_composer_extend"), "straightDown" => __('Straight Down', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $layout) { echo '<div>' . __("Content", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("postName" => __('Product Name', "ts_visual_composer_extend"), "postPrice" => __('Product Price', "ts_visual_composer_extend"), "postRating" => __('Product Rating', "ts_visual_composer_extend"), "postDate" => __('Product Date', "ts_visual_composer_extend"), "postModified" => __('Product Modified', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_by) { echo '<div>' . __("Sort Criterion", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } $front_edit_reverse = array("asc" => __('Bottom to Top', "ts_visual_composer_extend"), "desc" => __('Top to Bottom', "ts_visual_composer_extend")); foreach ($front_edit_reverse as $key => $value) { if ($key == $sort_order) { echo '<div>' . __("Initial Order", "ts_visual_composer_extend") . ': ' . $value . '</div>'; } } echo '<div>' . __("Show Filter Button", "ts_visual_composer_extend") . ': ' . $filter_menu . '</div>'; echo '<div>' . __("Show Layout Button", "ts_visual_composer_extend") . ': ' . $layout_menu . '</div>'; echo '<div>' . __("Show Sort Criterion Button", "ts_visual_composer_extend") . ': ' . $sort_menu . '</div>'; echo '<div>' . __("Show Directions Buttons", "ts_visual_composer_extend") . ': ' . $directions_menu . '</div>'; echo '</div>'; } else { $opening .= '<div id="' . $posts_container_id . '" class="ts-isotope-posts-grid-parent ' . ($layout == 'spineTimeline' ? 'ts-timeline ' : 'ts-postsgrid ') . 'ts-timeline-' . $sort_order . ' ts-posts-timeline ' . $isotope_posts_list_class . ' ' . $css_class . '" style="margin-top: ' . $margin_top . 'px; margin-bottom: ' . $margin_bottom . ';" data-lazy="' . $posts_lazy . '" data-count="' . $posts_limit . '" data-ajax="' . $posts_ajax . '" data-trigger="' . $posts_trigger . '" data-column="' . $column_width . '" data-layout="' . $layout . '" data-sort="' . $sort_by . '" data-order="' . $sort_order . '" data-break="' . $layout_break . '" data-type="' . $post_type . '">'; // Create Individual Post Output $postCounter = 0; $postCategories = array(); $categoriesCount = 0; if (post_type_exists($post_type) && $loop->have_posts()) { $products .= '<div class="ts-timeline-content">'; $products .= '<ul id="ts-isotope-posts-grid-' . $postsgrid_random . '" class="ts-isotope-posts-grid ts-timeline-list" data-layout="' . $layout . '" data-key="' . $postsgrid_random . '">'; while ($loop->have_posts()) { $loop->the_post(); $postCounter++; $product_id = get_the_ID(); $product_title = get_the_title($product_id); $post = get_post($product_id); $product = new WC_Product($product_id); $attachment_ids = $product->get_gallery_attachment_ids(); $price = $product->get_price_html(); $product_sku = $product->get_sku(); $attributes = $product->get_attributes(); $stock = $product->is_in_stock() ? 'true' : 'false'; $onsale = $product->is_on_sale() ? 'true' : 'false'; // Rating Settings $rating_html = $product->get_rating_html(); $rating = $product->get_average_rating(); if ($rating == '') { $rating = 0; } if ($rating_quarter == "true") { $rating_value = floor($rating * 4) / 4; } else { $rating_value = $rating; } $rating_value = number_format($rating_value, 2, $caption_digits, ''); if ($rating_rtl == "false") { $rating_width = $rating_value / $rating_maximum * 100; } else { $rating_width = 100 - $rating_value / $rating_maximum * 100; } if ($rating_symbol == "other") { if ($rating_icon == "ts-ecommerce-starfull1") { $rating_class = 'ts-rating-stars-star1'; } else { if ($rating_icon == "ts-ecommerce-starfull2") { $rating_class = 'ts-rating-stars-star2'; } else { if ($rating_icon == "ts-ecommerce-starfull3") { $rating_class = 'ts-rating-stars-star3'; } else { if ($rating_icon == "ts-ecommerce-starfull4") { $rating_class = 'ts-rating-stars-star4'; } else { if ($rating_icon == "ts-ecommerce-heartfull") { $rating_class = 'ts-rating-stars-heart1'; } else { if ($rating_icon == "ts-ecommerce-heart") { $rating_class = 'ts-rating-stars-heart2'; } else { if ($rating_icon == "ts-ecommerce-thumbsup") { $rating_class = 'ts-rating-stars-thumb'; } else { if ($rating_icon == "ts-ecommerce-ribbon4") { $rating_class = 'ts-rating-stars-ribbon'; } } } } } } } } } else { $rating_class = 'ts-rating-stars-smile'; } if ($rating_value >= 0 && $rating_value <= 1) { $caption_class = 'ts-label-danger'; $caption_background = 'background-color: ' . $caption_danger . ';'; } else { if ($rating_value > 1 && $rating_value <= 2) { $caption_class = 'ts-label-warning'; $caption_background = 'background-color: ' . $caption_warning . ';'; } else { if ($rating_value > 2 && $rating_value <= 3) { $caption_class = 'ts-label-info'; $caption_background = 'background-color: ' . $caption_info . ';'; } else { if ($rating_value > 3 && $rating_value <= 4) { $caption_class = 'ts-label-primary'; $caption_background = 'background-color: ' . $caption_primary . ';'; } else { if ($rating_value > 4 && $rating_value <= 5) { $caption_class = 'ts-label-success'; $caption_background = 'background-color: ' . $caption_success . ';'; } } } } } if (has_post_thumbnail($loop->post->ID)) { $featured = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full'); $thumbnail = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); $featured = $featured[0]; $thumbnail = $thumbnail[0]; } else { $featured = woocommerce_placeholder_img_src(); $thumbnail = $featured; } $title = get_the_title(); // Create Output if ($postCounter < $posts_limit + 1) { $postAttributes = 'data-visible="false" data-price="' . TS_VCSC_CleanNumberData($product->price) . '" data-rating="' . TS_VCSC_CleanNumberData($rating) . '" data-full="' . get_post_time($date_format) . '" data-author="' . get_the_author() . '" data-date="' . get_post_time('U') . '" data-modified="' . get_the_modified_time('U') . '" data-title="' . get_the_title() . '" data-comments="' . get_comments_number() . '" data-id="' . get_the_ID() . '"'; if ($exclude_outofstock == "true" && $stock == "true" || $exclude_outofstock == "false") { $product_categories = ''; if ($filter_menu == 'true' && taxonomy_exists($menu_tax)) { foreach (get_the_terms($loop->post->ID, $menu_tax) as $term) { $product_categories .= $term->slug . ' '; $category_check = 0; foreach ($postCategories as $index => $array) { if ($postCategories[$index]['slug'] == $term->slug) { $category_check++; } } if ($category_check == 0) { $categoriesCount++; $categories_array = array('slug' => $term->slug, 'name' => $term->name); $postCategories[] = $categories_array; } } } $product_categories .= 'rating-' . TS_VCSC_CleanNumberData($rating) . ' '; $products .= '<li class="ts-timeline-list-item ts-timeline-date-true ts-isotope-posts-list-item ' . $product_categories . '" ' . $postAttributes . ' style="margin: 10px;">'; $products .= '<div class="ts-woocommerce-product-slide" style="' . $product_style . '" data-hash="' . $product_id . '">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '" class="ts-image-hover-frame ' . $image_position . ' ts-trigger-hover-adjust" style="width: 100%;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-counter" class="ts-fluid-wrapper " style="width: 100%; height: auto;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-mask" class="ts-imagehover ' . $hover_type . ' ts-trigger-hover" data-trigger="ts-trigger-hover" data-closer="" style="width: 100%; height: auto;">'; // Product Thumbnail $products .= '<div class="ts-woocommerce-product-preview">'; $products .= '<img class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '</div>'; // Sale Ribbon if ($onsale == "true") { $products .= '<div class="ts-woocommerce-product-ribbon"></div>'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-sale ts-ecommerce-tagsale"></i>'; } $products .= '<div class="ts-woocommerce-product-main">'; $products .= '<div class="mask" style="width: 100%; display: block;">'; $products .= '<div id="ts-woocommerce-product-' . $product_id . '-maskcontent" class="maskcontent" style="margin: 0; padding: 0;">'; // Product Thubmnail if ($show_image == "true") { if ($link_page == "false") { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="nch-lightbox-media" data-title="' . $title . '" rel="" href="' . $featured . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } else { $products .= '<div class="ts-woocommerce-link-wrapper"><a id="" class="" data-title="' . $title . '" rel="" href="' . get_permalink() . '" target="' . $link_target . '">'; $products .= '<div class="ts-woocommerce-product-thumbnail" style="background-image: url(' . $thumbnail . ');"></div>'; $products .= '</a></div>'; } } // Product Page Link if ($show_link == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a href="' . get_permalink() . '" class="ts-woocommerce-product-link" target="_blank"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a></div>'; } // Product Rating if ($show_rating == "true") { $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 10px 0 0 10px; float: left;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; } // Product Price if ($show_price == "true") { $products .= '<div class="ts-woocommerce-product-price">'; $products .= '<i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del>' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; } $products .= '<div class="ts-woocommerce-product-line"></div>'; // Add to Cart Button (Icon) if ($show_cart == "true") { $products .= '<div class="ts-woocommerce-link-wrapper"><a class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a></div>'; } // View Description Button if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '-trigger" style="" class="ts-vcsc-modal-' . $product_id . '-parent nch-holder ts-vcsc-font-icon ts-font-icons ts-shortcode ts-icon-align-center" style="">'; $products .= '<a href="#ts-vcsc-modal-' . $product_id . '" class="nch-lightbox-modal" data-title="" data-open="false" data-delay="0" data-type="html" rel="" data-effect="' . $lightbox_effect . '" data-share="0" data-duration="' . $lightbox_speed . '" data-color="' . $lightbox_backlight_selection . '">'; $products .= '<span class="">'; $products .= '<i class="ts-font-icon ts-woocommerce-product-icon ts-woocommerce-product-info ts-ecommerce-information1" style=""></i>'; $products .= '</span>'; $products .= '</a>'; $products .= '</div>'; } // Product In-Stock or Unavailable if ($show_stock == "true") { $products .= '<div class="ts-woocommerce-product-status">'; if ($stock == 'false') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-outofstock">' . __('Out of Stock', 'woocommerce') . '</span></div>'; } else { if ($stock == 'true') { $products .= '<div class="ts-woocommerce-product-stock"><span class="ts-woocommerce-product-instock">' . __('In Stock', 'woocommerce') . '</span></div>'; } } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; // Product Title $products .= '<h2 class="ts-woocommerce-product-title">'; $products .= $title; $products .= '</h2>'; // Product Description if ($show_info == "true") { $products .= '<div id="ts-vcsc-modal-' . $product_id . '" class="ts-modal-content nch-hide-if-javascript" style="' . $description_style . '">'; $products .= '<div class="ts-modal-white-header"></div>'; $products .= '<div class="ts-modal-white-frame">'; $products .= '<div class="ts-modal-white-inner">'; $products .= '<h2 style="border-bottom: 1px solid #eeeeee; padding-bottom: 10px; line-height: 32px; font-size: 24px; text-align: left;">' . $title . '</h2>'; $products .= '<div class="ts-woocommerce-lightbox-frame" style="width: 100%; height: 32px; margin: 10px auto; padding: 0;">'; $products .= '<a style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-purchase" href="?add-to-cart=' . $product_id . '" rel="nofollow" data-id="' . $product_id . '" data-sku="' . $product_sku . '"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-cart ts-ecommerce-cart4"></i></a>'; $products .= '<a href="' . get_permalink() . '" target="_parent" style="position: inherit; margin-left: 10px; float: right;" class="ts-woocommerce-product-link"><i style="color: #000000;" class="ts-woocommerce-product-icon ts-woocommerce-product-view ts-ecommerce-forward"></i></a>'; $products .= '<div class="ts-rating-stars-frame" data-auto="' . $rating_auto . '" data-size="' . $rating_size . '" data-width="' . $rating_size * 5 . '" data-rating="' . $rating_value . '" style="margin: 0; float: right;">'; $products .= '<div class="ts-star-rating' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-active " style="font-size: ' . $rating_size . 'px; line-height: ' . ($rating_size + 5) . 'px;">'; if ($caption_show == "true" && $caption_position == "left") { $products .= '<div class="ts-rating-caption" style="margin-right: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '<div class="ts-rating-container' . ($rating_rtl == "false" ? "" : "-rtl") . ' ts-rating-glyph-holder ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_empty : $color_rated) . ';">'; $products .= '<div class="ts-rating-stars ' . $rating_class . '" style="color: ' . ($rating_rtl == "false" ? $color_rated : $color_empty) . '; width: ' . $rating_width . '%;"></div>'; $products .= '</div>'; if ($caption_show == "true" && $caption_position == "right") { $products .= '<div class="ts-rating-caption" style="margin-left: 10px;">'; if ($rating_rtl == "false") { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . $rating_value . ' / ' . number_format($rating_maximum, 2, $caption_digits, '') . '</span>'; } else { $products .= '<span class="label ' . $caption_class . '" style="' . $caption_background . '">' . number_format($rating_maximum, 2, $caption_digits, '') . ' / ' . $rating_value . '</span>'; } $products .= '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-price" style="position: inherit; margin-right: 10px; float: left; width: auto; margin-top: 0;">'; $products .= '<i style="color: #000000; margin: 0 10px 0 0;" class="ts-woocommerce-product-icon ts-woocommerce-product-cost ts-ecommerce-pricetag3"></i>'; if ($product->price > 0) { if ($product->price && isset($product->regular_price)) { $from = $product->regular_price; $to = $product->price; if ($from != $to) { $products .= '<div class="ts-woocommerce-product-regular"><del style="color: #7F0000;">' . (is_numeric($from) ? woocommerce_price($from) : $from) . '</del> | </div><div class="ts-woocommerce-product-special">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } else { $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } } else { $to = $product->price; $products .= '<div class="ts-woocommerce-product-current">' . (is_numeric($to) ? woocommerce_price($to) : $to) . '</div>'; } $products .= '</div>'; $products .= '</div>'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 10px auto 20px auto; width: 100%;"></div>'; $products .= '<img style="width: 100%; max-width: 250px; height: auto; margin: 10px auto;" class="ts-woocommerce-product-image" src="' . $featured . '" alt="" />'; $products .= '<div class="ts-woocommerce-product-seperator" style="border-bottom: 1px solid #eeeeee; margin: 20px auto 10px auto; width: 100%;"></div>'; $products .= '<div style="margin-top: 20px; text-align: justify;">'; if ($show_content == "excerpt") { $products .= get_the_excerpt(); } else { if ($show_content == "cutcharacters") { $content = apply_filters('the_content', get_the_content()); $excerpt = TS_VCSC_TruncateHTML($content, $cutoff_characters, '...', false, true); $products .= $excerpt; } else { if ($show_content == "complete") { $products .= get_the_content(); } } } $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; $products .= '</div>'; } $products .= '</div>'; $products .= '</li>'; } } } $products .= '</ul>'; $products .= '</div>'; if ($posts_lazy == "true") { $products .= '<div class="ts-load-more-wrap">'; $products .= '<span class="ts-timeline-load-more">' . $posts_load . '</span>'; $products .= '</div>'; } wp_reset_postdata(); } else { $products .= '<p>Nothing found. Please check back soon!</p>'; } // Create Post Controls (Filter, Sort) $controls .= '<div id="ts-isotope-posts-grid-controls-' . $postsgrid_random . '" class="ts-isotope-posts-grid-controls">'; if ($directions_menu == 'true' && $posts_lazy == 'false') { $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-desc ts-isotope-posts-controls-desc ' . ($sort_order == "desc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-desc-image"></span></div>'; $controls .= '<div class="ts-button ts-button-flat ts-timeline-controls-asc ts-isotope-posts-controls-asc ' . ($sort_order == "asc" ? "active" : "") . '"><span class="ts-isotope-posts-controls-asc-image"></span></div>'; } $controls .= '<div class="ts-isotope-posts-grid-controls-menus">'; if ($filter_menu == 'true') { if ($categoriesCount > 1) { $controls .= '<div id="ts-isotope-posts-filter-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-filter-trigger" data-dropdown="#ts-isotope-posts-filter-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['WooFilterProducts'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-filter-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label style="font-weight: bold;"><input class="ts-isotope-posts-filter ts-isotope-posts-filter-all" type="checkbox" style="margin-right: 10px;" checked="checked" data-type="all" data-key="' . $postsgrid_random . '" data-filter="*">' . $TS_VCSC_Isotope_Posts_Language['SeeAll'] . '</label></li>'; $controls .= '<li class="ts-dropdown-divider"></li>'; foreach ($postCategories as $index => $array) { $controls .= '<li><label><input class="ts-isotope-posts-filter ts-isotope-posts-filter-single" type="checkbox" style="margin-right: 10px;" data-type="single" data-key="' . $postsgrid_random . '" data-filter=".' . $postCategories[$index]['slug'] . '">' . $postCategories[$index]['name'] . '</label></li>'; } $controls .= '</ul>'; $controls .= '</div>'; } } if ($layout_menu == 'true') { $controls .= '<div id="ts-isotope-posts-layout-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-layout-trigger" data-dropdown="#ts-isotope-posts-layout-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonLayout'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-layout-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="masonry" style="margin-right: 10px;" ' . ($layout == 'masonry' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['Masonry'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="fitRows" style="margin-right: 10px;" ' . ($layout == 'fitRows' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['FitRows'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-layout" type="radio" name="radio-group-' . $postsgrid_random . '" data-layout="straightDown" style="margin-right: 10px;" ' . ($layout == 'straightDown' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['StraightDown'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } if ($sort_menu == 'true') { $controls .= '<div id="ts-isotope-posts-sort-trigger-' . $postsgrid_random . '" class="ts-isotope-posts-sort-trigger" data-dropdown="#ts-isotope-posts-sort-' . $postsgrid_random . '" data-horizontal-offset="0" data-vertical-offset="0"><span>' . $TS_VCSC_Isotope_Posts_Language['ButtonSort'] . '</span></div>'; $controls .= '<div id="ts-isotope-posts-sort-' . $postsgrid_random . '" class="ts-dropdown ts-dropdown-tip ts-dropdown-relative ts-dropdown-anchor-left" style="left: 0px;">'; $controls .= '<ul id="" class="ts-dropdown-menu">'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postName" style="margin-right: 10px;" ' . ($sort_by == 'postName' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooTitle'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postPrice" style="margin-right: 10px;" ' . ($sort_by == 'postPrice' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooPrice'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postRatings" style="margin-right: 10px;" ' . ($sort_by == 'postRatings' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooRating'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postDate" style="margin-right: 10px;" ' . ($sort_by == 'postDate' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooDate'] . '</label></li>'; $controls .= '<li><label><input class="ts-isotope-posts-sort" type="radio" name="radio-sort-' . $postsgrid_random . '" data-sort="postModified" style="margin-right: 10px;" ' . ($sort_by == 'postModified' ? 'checked="checked"' : '') . '>' . $TS_VCSC_Isotope_Posts_Language['WooModified'] . '</label></li>'; $controls .= '</ul>'; $controls .= '</div>'; } $controls .= '</div>'; $controls .= '<div class="clearFixMe" style="clear:both;"></div>'; $controls .= '</div>'; $closing .= '</div>'; echo $opening; echo $controls; echo $products; echo $closing; } $myvariable = ob_get_clean(); return $myvariable; }
echo get_permalink($loop->post->ID); ?> " title="<?php echo esc_attr($loop->post->post_title ? $loop->post->post_title : $loop->post->ID); ?> "> <?php woocommerce_show_product_sale_flash($post, $product); ?> <?php if (has_post_thumbnail($loop->post->ID)) { echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); } else { echo '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="300px" height="300px" />'; } ?> <h3><?php the_title(); ?> </h3> <span class="price"><?php echo $product->get_price_html(); ?> </span> </a>
function woocommerce_get_product_thumbnail($size = 'shop_catalog', $placeholder_width = 0, $placeholder_height = 0) { global $post, $product; $shop_thumb_type = ot_get_option('shop_thumb_type'); $shop_thumb_custom = ot_get_option('shop_thumb_custom'); $catalog_type = ot_get_option('catalog_type'); if (!$shop_thumb_custom) { $shop_thumb_custom = 'thumbnail'; } $output = ''; if (has_post_thumbnail()) { if ($shop_thumb_type == "none") { $thumbnail = get_the_post_thumbnail($post->ID, $size); } elseif ($shop_thumb_type == "custom-size") { $img = lpd_getImageBySize(array('attach_id' => get_post_thumbnail_id($post->ID), 'thumb_size' => $shop_thumb_custom, 'class' => "")); $thumbnail = $img['thumbnail']; } else { $thumbnail = get_the_post_thumbnail($post->ID, $shop_thumb_type); } $output .= '<a class="img-transaction" href="' . get_permalink() . '">'; $output .= '<div class="featured-img">'; $output .= $thumbnail; $output .= '</div>'; $output .= '<div class="gallery-img">'; $attachment_ids = $product->get_gallery_attachment_ids(); if ($attachment_ids) { $loop = 0; foreach ($attachment_ids as $attachment_id) { $loop++; $image_link = wp_get_attachment_url($attachment_id); if (!$image_link) { continue; } if ($loop == 1) { if ($shop_thumb_type == "none") { $output .= wp_get_attachment_image($attachment_id, $size); } elseif ($shop_thumb_type == "custom-size") { $img = lpd_getImageBySize(array('attach_id' => $attachment_id, 'thumb_size' => $shop_thumb_custom, 'class' => "")); $output .= $img['thumbnail']; } else { $output .= wp_get_attachment_image($attachment_id, $shop_thumb_type); } } } } else { $output .= $thumbnail; } $output .= '</div>'; $output .= '</a>'; } elseif (wc_placeholder_img_src()) { $thumbnail = '<img src="' . woocommerce_placeholder_img_src() . '" alt="Placeholder" width="580" height="580" />'; $output .= '<a href="' . get_permalink() . '">'; $output .= '<div class="featured-img">'; #$output .= wc_placeholder_img( $size ); $output .= $thumbnail; $output .= '</div>'; $output .= '</a>'; } return $output; }
function woocommerce_subcategory_thumbnail($category) { global $woocommerce; $small_thumbnail_size = apply_filters('single_product_small_thumbnail_size', 'shop_catalog'); $image_width = $woocommerce->get_image_size('shop_catalog_image_width'); $image_height = $woocommerce->get_image_size('shop_catalog_image_height'); $thumbnail_id = get_woocommerce_term_meta($category->term_id, 'thumbnail_id', true); if ($thumbnail_id) { $image = wp_get_attachment_image_src($thumbnail_id, $small_thumbnail_size); $image = $image[0]; } else { $image = woocommerce_placeholder_img_src(); } echo '<img src="' . $image . '" alt="' . $category->name . '" width="' . $image_width . '" height="' . $image_height . '" />'; }
function wpb_wps_sideber_feature_shortcode($atts) { extract(shortcode_atts(array('posts' => 5), $atts)); $return_string = '<div class="wpb_slider_area wpb_sidebar_slider owl-text-center wpb_fix_cart">'; $return_string .= '<div id="owl-demo-side-feature" class="owl-carousel">'; $args = array('post_type' => 'product', 'meta_key' => '_featured', 'meta_value' => 'yes', 'posts_per_page' => $posts); $loop = new WP_Query($args); if ($loop->have_posts()) { while ($loop->have_posts()) { $loop->the_post(); global $product; $return_string .= '<div class="item">'; $return_string .= '<figure>'; if (!defined('ABSPATH')) { exit; } // Exit if accessed directly global $post, $product; $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, 'wpb-pro-thumb', 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>'; $return_string .= '<div class="price_area_fix">' . do_shortcode('[add_to_cart id="' . get_the_ID() . '"]') . '</div>'; // call cart btn and price $return_string .= '</figcaption>'; $return_string .= '</figure>'; $return_string .= '</div>'; } } else { echo __('No products found'); } wp_reset_postdata(); $return_string .= '</div>'; $return_string .= '</div>'; wp_reset_query(); return $return_string; }