Fixes bug when adding a existing term in bulk

This commit is contained in:
weryques 2019-01-31 11:36:27 -02:00
parent 362b43cf5c
commit 2b32d2ab51
1 changed files with 18 additions and 8 deletions

View File

@ -292,14 +292,24 @@ class Terms extends Repository {
} elseif ( $taxonomy instanceof Entities\Taxonomy ) {
$taxonomy_slug = $taxonomy->get_db_identifier();
}
$args = [
'name' => $name,
'taxonomy' => $taxonomy_slug,
'parent' => $parent,
'hide_empty' => 0,
'suppress_filter' => true
];
if(is_numeric($name)){
$args = [
'id' => (int) $name,
'taxonomy' => $taxonomy_slug,
'parent' => $parent,
'hide_empty' => 0,
'suppress_filter' => true
];
} else {
$args = [
'name' => $name,
'taxonomy' => $taxonomy_slug,
'parent' => $parent,
'hide_empty' => 0,
'suppress_filter' => true
];
}
if (is_null($parent)) {
unset($args['parent']);