I'm writing a plugin that involves a large hierarchical taxonomy that is 5 levels deep. Users should be able to turn parts of the taxonomy on/off depending on what is relevant to them.
It's all going fine, taxonomy & terms defined with checkboxes in a settings page for what parts they want to use. But now I'm struggling with how to remove a term and all it's subterms if a checkbox is first ticked then unticked.
The function wp_delete_term is fine for removing one term but if a term has children the child terms get added as children of the removed terms parent (if that makes sense!).
So essentially I want to remove a term and all it's children from a custom taxonomy. I tried doing several loops to loops through each subterm but with so many levels and nested loops it got a bit mind boggling!
If anyone has done anything like this before (perhaps for CustomPress?) that would be great.