You should be using the register_deactivation_hook
and/or register_uninstall_hooks
. That may be why some functions don’t work. I’d have to do some testing to be sure, but loading your method directly like WP_Plugin_Janitor::cleanup( $opt, $cpt, $tax );
seems like a pretty good way to skip over some of the WordPress load sequence or to run things out of order.
As far as loading the class twice, I have an answer, but that is a different question and not really WordPress specific. 🙂