Escape caption in product-thumbnail template

This commit is contained in:
Mike Jolley 2016-07-19 18:59:57 +01:00
parent 2b6cbc7629
commit 40351f7e63
1 changed files with 24 additions and 17 deletions

View File

@ -13,11 +13,11 @@
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.3.0
* @version 2.6.3
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
global $post, $product, $woocommerce;
@ -34,28 +34,35 @@ if ( $attachment_ids ) {
$classes = array( 'zoom' );
if ( $loop === 0 || $loop % $columns === 0 )
if ( $loop === 0 || $loop % $columns === 0 ) {
$classes[] = 'first';
}
if ( ( $loop + 1 ) % $columns === 0 )
if ( ( $loop + 1 ) % $columns === 0 ) {
$classes[] = 'last';
}
$image_link = wp_get_attachment_url( $attachment_id );
if ( ! $image_link )
if ( ! $image_link = wp_get_attachment_url( $attachment_id ) ) {
continue;
}
$image_title = esc_attr( get_the_title( $attachment_id ) );
$image_caption = esc_attr( get_post_field( 'post_excerpt', $attachment_id ) );
$props = wc_get_product_attachment_props( $attachment_id, $post );
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $props );
$image_class = implode( ' ', $classes );
$image = wp_get_attachment_image( $attachment_id, apply_filters( 'single_product_small_thumbnail_size', 'shop_thumbnail' ), 0, $attr = array(
'title' => $image_title,
'alt' => $image_title
) );
$image_class = esc_attr( implode( ' ', $classes ) );
echo apply_filters( 'woocommerce_single_product_image_thumbnail_html', sprintf( '<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>', $image_link, $image_class, $image_caption, $image ), $attachment_id, $post->ID, $image_class );
echo apply_filters(
'woocommerce_single_product_image_thumbnail_html',
sprintf(
'<a href="%s" class="%s" title="%s" data-rel="prettyPhoto[product-gallery]">%s</a>',
$image_link,
esc_attr( $image_class ),
esc_attr( $props['caption'] ),
$image
),
$attachment_id,
$post->ID,
esc_attr( $image_class )
);
$loop++;
}