Merge pull request #20282 from woocommerce/fix/20278

Product properties should not be accessed directly
This commit is contained in:
Mike Jolley 2018-05-29 10:55:48 +01:00 committed by GitHub
commit c9aadf19bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -701,8 +701,8 @@ function wc_get_product_attachment_props( $attachment_id = null, $product = fals
// Alt text.
$alt_text = array( wp_strip_all_tags( get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ) ), $props['caption'], wp_strip_all_tags( $attachment->post_title ) );
if ( $product ) {
$alt_text[] = wp_strip_all_tags( get_the_title( $product->ID ) );
if ( $product && $product instanceof WC_Product ) {
$alt_text[] = wp_strip_all_tags( get_the_title( $product->get_id() ) );
}
$alt_text = array_filter( $alt_text );