scribu / wp-term-management-tools

A WordPress plugin to help with taxonomy term management. Now maintained by theMikeD
https://github.com/theMikeD/wp-term-management-tools
35 stars 22 forks source link

Changing Taxonomies Leads to Duplicates #12

Open jcrawford opened 4 years ago

jcrawford commented 4 years ago

I have noticed that when I have a category named 'Fun' and a tag named 'Fun' if I try to change the taxonomy of the category to become a tag then I end up with duplicate named tags.

For instance if my post count is such.

Category Fun: 30 posts Tag Fun: 10 posts

The end result is that I have two tags for Fun such as the following

Tag Fun: 30 posts Tag Fun: 10 posts

Is this a bug or is the plugin meant to duplicate the tags? I would have expected it to look for a term within the new taxonomy that matched the name of the old taxonomy term and then if one was found to use that one rather than creating a second. With this issue in place it is leaving me no option but to use the hook 'term_management_tools_term_changed_taxonomy' and try to merge them together after the fact.

jcrawford commented 4 years ago

I can only assume this is a bug because WordPress core throws an error if you try to add a tag with a name that already exists, yet this plugin will create a secondary duplicate term even if it already exists in the new taxonomy.

scribu commented 4 years ago

I'm not sure why it does that. It doesn't seem ideal.

A better UX would be to let the user decide what they want to do:

The tag already exists in the destination taxonomy.

Would you like to merge the old tag in?

[Merge] - perform a merge (already implemented in a different part of the plugin)
[Cancel] - do nothing
theMikeD commented 3 years ago

The change taxonomy operation currently does not consider any terms that already exist. This is by design: the terms simply have their associated taxonomies set directly using a $wpdb command. So this is not a bug, but a feature request.