Make sure that the attribute is a taxonomy before unset #10506

This commit is contained in:
Claudio Sanches 2016-03-09 17:17:21 -03:00
parent 99fd5f0d68
commit 11decde0ab
1 changed files with 4 additions and 5 deletions

View File

@ -972,11 +972,10 @@ class WC_Meta_Box_Product_Data {
uasort( $attributes, 'attributes_cmp' ); uasort( $attributes, 'attributes_cmp' );
// Unset deleted attributes. // Unset deleted attributes.
$current_attributes = get_post_meta( $post_id, '_product_attributes', true ); foreach ( get_post_meta( $post_id, '_product_attributes', true ) as $key => $value ) {
foreach ( array_keys( $current_attributes ) as $_attribute ) { if ( empty( $attributes[ $key ] ) ) {
if ( empty( $attributes[ $_attribute ] ) ) { if ( $value['is_taxonomy'] && taxonomy_exists( $key ) ) {
if ( taxonomy_exists( $_attribute ) ) { wp_set_object_terms( $post_id, array(), $key );
wp_set_object_terms( $post_id, array(), $_attribute );
} }
} }
} }