Modify automatically generation of slug when term is created

You will have bugs like this. because you are not sanitizing the title with sanitize_title().

And you are not checking for duplications with wp_unique_term_slug()

Bugs tests:

  1. Add spaces in the name and see the slug with spaces.
  2. After you add the sanitize_title() add term with comma 5,5 add term with space 5 5 results with duplications.

So just fix this like this:

add_action('wp_insert_term_data', 'slug_save_term_callback', 10, 3 );
function slug_save_term_callback($data, $taxonomy, $args) {
    $name = $data['name'];
    $name = wp_unique_term_slug(sanitize_title(str_replace(',', '-', $name)), (object) $args);

    $data['slug'] = $name;

    return $data;
}