Evaluates empty numeric values #422.

This commit is contained in:
mateuswetah 2020-10-09 13:49:48 -03:00
parent 7f0c109866
commit eec60b10cc
1 changed files with 6 additions and 2 deletions

View File

@ -70,7 +70,9 @@ class Item_Metadata extends Repository {
return $item_metadata;
} else {
if ( $unique ) {
if( empty( $item_metadata->get_value() ) ) {
$is_numeric = is_numeric($item_metadata->get_value());
if ( ( !$is_numeric && empty( $item_metadata->get_value()) ) || ($is_numeric && $item_metadata->get_value() == '') ) {
if ( $item_metadata->get_metadatum()->get_parent() > 0 )
delete_metadata_by_mid( 'post', $item_metadata->get_meta_id() );
else
@ -101,7 +103,9 @@ class Item_Metadata extends Repository {
$values = $item_metadata->get_value();
foreach ( $values as $value ) {
if( empty($value) || $value == "" ) {
$is_numeric = is_numeric($value);
if ( (!$is_numeric && empty($value)) || ($is_numeric && $value == "") ) {
continue;
}
add_post_meta( $item_metadata->get_item()->get_id(), $item_metadata->get_metadatum()->get_id(), wp_slash( $value ) );