Skip to content

Commit 356304e

Browse files
committed
first version, not tested yet
1 parent 08f6b0b commit 356304e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Taxonomy_Command.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,16 +251,20 @@ public function migrate( $args, $assoc_args ) {
251251
}
252252

253253
if ( $values ) {
254-
$wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join(',', $values) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" );
254+
$wpdb->query( "INSERT INTO $wpdb->term_relationships (object_id, term_taxonomy_id, term_order) VALUES " . join( ',', $values ) . " ON DUPLICATE KEY UPDATE term_order = VALUES(term_order)" );
255255
$wpdb->update($wpdb->term_taxonomy, array( 'count' => $term->count ), array( 'term_id' => $term->term_id, 'taxonomy' => $args[2] ) );
256256

257-
WP_CLI::success( "Term added to posts." );
257+
WP_CLI::success( "Term migrated!" );
258258

259259
$clean_term_cache[] = $term->term_id;
260260
}
261261

262262
$del = wp_delete_term( $term_id, $tax );
263263

264+
if ( is_wp_error( $del ) ) {
265+
WP_CLI::error( "An error has occured: " . $id->get_error_message() );
266+
}
267+
264268
// Set all parents to 0 (root-level) if their parent was the converted tag
265269
$wpdb->update( $wpdb->term_taxonomy, array( 'parent' => 0 ), array( 'parent' => $term_id, 'taxonomy' => $tax ) );
266270

0 commit comments

Comments
 (0)