| @@ -8,8 +8,12 @@ | ||
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | namespace UltimateStoreKit\Templates; |
| 11 | 11 | |
| 12 | +if (! defined('ABSPATH')) { | |
| 13 | + exit; // Exit if accessed directly | |
| 14 | +} | |
| 15 | + | |
| 12 | 16 | use UltimateStoreKit\Traits\Global_Widget_Template; |
| 13 | 17 | use UltimateStoreKit\Classes\Utils; |
| 14 | 18 | |
| 15 | 19 | |
| @@ -64,18 +68,18 @@ | ||
| 64 | 68 | <div class="usk-content"> |
| 65 | 69 | <div class="usk-content-inner"> |
| 66 | 70 | <?php if ($categories && (isset($settings['show_category']) ? $settings['show_category'] : true)) : ?> |
| 67 | 71 | <div class="usk-category"> |
| 68 | - <?php echo wp_kses_post( wc_get_product_category_list( $product->get_id(), ' ' ) ); ?> | |
| 72 | + <?php echo wp_kses_post(wc_get_product_category_list($product->get_id(), ' ')); ?> | |
| 69 | 73 | </div> |
| 70 | 74 | <?php endif; ?> |
| 71 | 75 | <?php if (isset($settings['show_title']) ? $settings['show_title'] : true) : |
| 72 | 76 | printf( |
| 73 | 77 | '<%1$s class="title"><a href="%2$s" class="usk-title" aria-label="%4$s">%3$s</a></%1$s>', |
| 74 | - esc_attr( Utils::get_valid_html_tag( $title_tags ) ), | |
| 75 | - esc_url( $product->get_permalink() ), | |
| 76 | - esc_html( $product->get_title() ), | |
| 77 | - esc_attr( sprintf( 'View details for %s', $product->get_title() ) ) | |
| 78 | + esc_attr(Utils::get_valid_html_tag($title_tags)), | |
| 79 | + esc_url($product->get_permalink()), | |
| 80 | + esc_html($product->get_title()), | |
| 81 | + esc_attr(sprintf('View details for %s', $product->get_title())) | |
| 78 | 82 | ); |
| 79 | 83 | endif; ?> |
| 80 | 84 | <?php if (isset($settings['show_price']) ? $settings['show_price'] : true && $product->get_price_html()) : ?> |
| 81 | 85 | <div class="usk-price"> |
| @@ -105,8 +109,13 @@ | ||
| 105 | 109 | |
| 106 | 110 | $tooltip_position = 'left'; |
| 107 | 111 | $gallery_thumbs = $product->get_gallery_image_ids(); |
| 108 | 112 | $product_image = wp_get_attachment_image_url(get_post_thumbnail_id(), isset($settings['image_size']) ? $settings['image_size'] : 'full'); |
| 113 | + | |
| 114 | + // if product image is empty, use placeholder | |
| 115 | + if (empty($product_image)) { | |
| 116 | + $product_image = wc_placeholder_img_src('full'); | |
| 117 | + } | |
| 109 | 118 | if ($gallery_thumbs) { |
| 110 | 119 | foreach ($gallery_thumbs as $key => $gallery_thumb) { |
| 111 | 120 | if ($key == 0) : |
| 112 | 121 | $gallery_image_link = wp_get_attachment_image_url($gallery_thumb, isset($settings['image_size']) ? $settings['image_size'] : 'full'); |
| @@ -117,10 +126,10 @@ | ||
| 117 | 126 | } |
| 118 | 127 | ?> |
| 119 | 128 | <div class="usk-image"> |
| 120 | 129 | <a href="<?php echo esc_url(get_permalink()); ?>"> |
| 121 | - <img class="img image-default" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_html(get_the_title()); ?>"> | |
| 122 | - <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_html(get_the_title()); ?>"> | |
| 130 | + <img class="img image-default" src="<?php echo esc_url($product_image); ?>" alt="<?php echo esc_attr(get_the_title()); ?>"> | |
| 131 | + <img class="img image-hover" src="<?php echo esc_url($gallery_image_link); ?>" alt="<?php echo esc_attr(get_the_title()); ?>"> | |
| 123 | 132 | </a> |
| 124 | 133 | <div class="usk-shoping"> |
| 125 | 134 | <?php |
| 126 | 135 | $this->register_global_template_add_to_wishlist($tooltip_position, $settings); |