Skip to content

Commit

Permalink
fix term hierarchy in destination when parent term was not mapped 10u…
Browse files Browse the repository at this point in the history
…p#219

also, remove parent them, if it's removed in source
  • Loading branch information
arsendovlatyan committed Nov 28, 2018
1 parent 814ae1c commit 2631535
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion includes/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,15 @@ function set_taxonomy_terms( $post_id, $taxonomy_terms ) {
$term_array = (array) $term_array;
}

if ( ! empty( $term_array['parent'] ) ) {
if ( empty ( $term_array['parent'] ) ) {
$r = wp_update_term(
$term_id_mapping[ $term_array['term_id'] ],
$taxonomy,
[
'parent' => '',
]
);
} elseif ( isset ( $term_id_mapping[ $term_array['parent'] ] ) ) {
wp_update_term(
$term_id_mapping[ $term_array['term_id'] ],
$taxonomy,
Expand Down

0 comments on commit 2631535

Please sign in to comment.