Refactor empty option check

This commit is contained in:
Claudiu Lodromanean 2017-03-02 08:21:20 -08:00
parent e132dcba17
commit 527fb42771
1 changed files with 5 additions and 1 deletions

View File

@ -189,7 +189,7 @@ class WC_Meta_Box_Product_Data {
$attribute_names_max_key = max( array_keys( $attribute_names ) );
for ( $i = 0; $i <= $attribute_names_max_key; $i++ ) {
if ( empty( $attribute_names[ $i ] ) || ! isset( $attribute_values[ $i ] ) || is_string( $attribute_values[ $i ] ) && "" === trim( $attribute_values[ $i ] ) ) {
if ( empty( $attribute_names[ $i ] ) || ! isset( $attribute_values[ $i ] ) ) {
continue;
}
$attribute_name = wc_clean( $attribute_names[ $i ] );
@ -205,6 +205,10 @@ class WC_Meta_Box_Product_Data {
$options = wc_get_text_attributes( $options );
}
if ( empty( $options ) ) {
continue;
}
$attribute = new WC_Product_Attribute();
$attribute->set_id( $attribute_id );
$attribute->set_name( $attribute_name );