Make sure that the attribute is a taxonomy before unset #10506
This commit is contained in:
parent
99fd5f0d68
commit
11decde0ab
|
@ -972,11 +972,10 @@ class WC_Meta_Box_Product_Data {
|
|||
uasort( $attributes, 'attributes_cmp' );
|
||||
|
||||
// Unset deleted attributes.
|
||||
$current_attributes = get_post_meta( $post_id, '_product_attributes', true );
|
||||
foreach ( array_keys( $current_attributes ) as $_attribute ) {
|
||||
if ( empty( $attributes[ $_attribute ] ) ) {
|
||||
if ( taxonomy_exists( $_attribute ) ) {
|
||||
wp_set_object_terms( $post_id, array(), $_attribute );
|
||||
foreach ( get_post_meta( $post_id, '_product_attributes', true ) as $key => $value ) {
|
||||
if ( empty( $attributes[ $key ] ) ) {
|
||||
if ( $value['is_taxonomy'] && taxonomy_exists( $key ) ) {
|
||||
wp_set_object_terms( $post_id, array(), $key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue