Refactor empty option check
This commit is contained in:
parent
e132dcba17
commit
527fb42771
|
@ -189,7 +189,7 @@ class WC_Meta_Box_Product_Data {
|
||||||
$attribute_names_max_key = max( array_keys( $attribute_names ) );
|
$attribute_names_max_key = max( array_keys( $attribute_names ) );
|
||||||
|
|
||||||
for ( $i = 0; $i <= $attribute_names_max_key; $i++ ) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
$attribute_name = wc_clean( $attribute_names[ $i ] );
|
$attribute_name = wc_clean( $attribute_names[ $i ] );
|
||||||
|
@ -205,6 +205,10 @@ class WC_Meta_Box_Product_Data {
|
||||||
$options = wc_get_text_attributes( $options );
|
$options = wc_get_text_attributes( $options );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( empty( $options ) ) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$attribute = new WC_Product_Attribute();
|
$attribute = new WC_Product_Attribute();
|
||||||
$attribute->set_id( $attribute_id );
|
$attribute->set_id( $attribute_id );
|
||||||
$attribute->set_name( $attribute_name );
|
$attribute->set_name( $attribute_name );
|
||||||
|
|
Loading…
Reference in New Issue