Taxonomies: Force renaming of terms

If you find that your manually modified taxonomy terms are getting the slug of their parent term appended automatically, try the following snippet.

For example, on the parent blog: Products > Cars have the slugs products > cars-products

On the child blog the slugs get renamed: products > cars-produts-products

this snippet will force rename cars-products-products to cars-products again.

/**
    @brief        Force changing of a term slug after update.
    @since        2021-02-23 14:28:52
**/
add_action( 'threewp_broadcast_wp_update_term', function( $action )
{
    ThreeWP_Broadcast()->debug( 'Forcing renaming slug of %s to %s', $action->new_term->term_id, $action->old_term->slug );
    wp_update_term( $action->new_term->term_id, $action->new_term->taxonomy, [ 'slug' => $action->old_term->slug ] );
}, 100 );