Merge pull request #20282 from woocommerce/fix/20278
Product properties should not be accessed directly
This commit is contained in:
commit
c9aadf19bd
|
@ -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 );
|
||||
|
|
Loading…
Reference in New Issue