Better way of detecting empty numeric values #422.

This commit is contained in:
mateuswetah 2020-10-09 14:17:39 -03:00
parent 7ee1cfdc57
commit d12e2622d4
1 changed files with 2 additions and 5 deletions

View File

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