$alias =
get_term_by( 'slug',
$args['alias_of'
],
$taxonomy );
if ( !
empty( $alias->term_group
) ) { // The alias we want is already in a group, so let's use that one.
$term_group =
$alias->term_group;
} elseif ( !
empty( $alias->term_id
) ) { /*
* The alias is not in a group, so we create a new one
* and add the alias to it.
*/
$term_group =
$wpdb->
get_var( "SELECT MAX(term_group) FROM
$wpdb->terms"
) + 1;
wp_update_term( $alias->term_id,
$taxonomy,
array
( 'term_group' =>
$term_group,
) );
} } /*
* Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy,
* unless a unique slug has been explicitly provided.
*/