For plugins that create custom taxonomies, wp_delete_term does not work during plugin uninstall.
|Reported by:||sscovil||Owned by:|
I ran into this problem while writing a plugin uninstall class to clean up any options, custom post types, taxonomies & terms related to the plugin.
The problem is, if a plugin creates a custom taxonomy and the plugin user creates terms for that taxonomy, the plugin cannot delete those terms during uninstall.
How to reproduce:
- Create a plugin that creates a custom taxonomy.
- Create some terms for that taxonomy.
- In uninstall.php, try using wp_delete_term to remove those terms.
Because the plugin is already deactivated by the time uninstall.php fires, $wp_taxonomies no longer contains the custom taxonomy that the plugin created. Since wp_delete_term requires a valid taxonomy as its second parameter, it does not work.
The issue is also being discussed here: http://bit.ly/RUDYOv