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. 🙂
Related Posts:
- Insert terms for custom taxonomy on plugin activation, or each page load (init hook)
- How to Get Current Custom Post Type Associated Taxonomy Term
- term_exists() returning NULL on term that exists
- add_action priority and taxonomy used in plugin
- How to display custom taxonomy and terms using/creating plugin template
- What’s the difference between term_id and term_taxonomy_id
- Inserting Taxonomy Terms During a Plugin Activation?
- register_uninstall_hook() vs uninstall.php – which one is better way to handle plugin uninstallation script?
- How to Make a Category Always Selected?
- How does uninstalling WordPress plugins work?
- Deletion of shared options using uninstall.php
- Rewrite Point Doesn’t Work on Custom Taxonomy
- can I prevent WP users (even admin) from deleting custom categories?
- Example of uninstaller routine to remove all custom theme options from wp_options
- Plugin Uninstall and Deactivate via Options Menu
- If a function requires add_action(‘init’) how can I run it only once on plugin activation?
- Get Objects While Deleting term
- Custom plugin: Loop through taxonomy types and update columns for all types?
- Clearing caches on plugin uninstall
- Custom Taxonomy to dropdown box on adminside wordpress
- $_FILES empty on created_{taxonomy} and create_{taxonomy} yet is is not on edit_{taxonomy}
- Notice: Trying to get property ‘term_id’ of non-object
- Why is the WordPress taxonomy not registering?
- Plugin development: delete options when updating to a new version
- Translate slug in WPMU with PO files
- Ordering taxonomies by rank
- wp_get_post_terms Order by not working
- Ajax is not working in a loop
- Taxonomies within plugin invalid
- Let plugin check if taxonomy is already registered by another plugin
- Non editable custom taxonomy
- modify show UI of a registered taxonomy
- How add default term meta to prevent an error?
- How to create taxonomy without using register_taxonomy () function
- Add location tag to wordpress posts
- Using init hook for register_taxonomy is causing invalid_taxonomy in wp_insert_term()
- Add default custom taxonomy to plugin activation
- Javascript not being loaded only in custom taxonomy template
- set a custom post type to a taxonomy term programmatically in metabox
- Making Woocommerce optimized for more than 500k products
- Is there better way to do this without duplicating queries?
- edit-tags.php in plugin admin menu hides when is the active page
- Get term_id for each instance of custom taxonomy
- How to show custom taxonomy child posts through shortcode in WordPress
- If I want to create new taxonomies (e.g. Project / Documents / Etc…) is it better to create them in the theme’s functions.php or within a plugin? [duplicate]
- Is the only way to add taxonomy terms via an admin panel?
- WordPress Breadcrumb Taxonomy Display
- How to boost WP custom post REST API GET queries by custom taxonomies
- How do I create Widget within plugin that uses its own class?
- Select options not reloading after form submit
- Get URL of Post You Are Editing
- Best practice to include custom user styles in widgets
- Nothing happens on WordPress Update command
- Looking for Hook that is fired after a plugin or wp upgrade is installed/updated
- Very Quick Custom Pluggable Function Question
- first_name property missing inside register_user action hook
- How to display posts list on my plugin page?
- Change the class of wordpress menu
- WordPress.org how to force expire Cached Banner-772×250 from my Plugin page
- Get user logged in status from within a plugin. $current_user not defined
- What is the Timeline for the Active Version Pie Chart in the Repository?
- Apply Filters Causing a 500 Internal Server Error
- Combo/Drop down box on plugin settings page that allows additional options to be added
- Pass results of custom query to loop – when writing a plugin
- Altering term_id and name via $wpdb class
- Multiple category lists on one page
- WordPress Beginer to Guru [duplicate]
- Create wordpress dashboard metabox which spans all columns
- Saving multiple fields as array
- How to set/change another post author by custom fields or something else?
- Unable to display the post titles in a drop down
- How to use permalink query to go to specific tabs in posts
- Fatal error: Call to a member function query() on a non-object in my ajaxpage
- Custom options page for themes
- wp_mail_from not changing from address
- Page reload occurs before request finishes
- How do I query posts and have their related taxonomies returned in the results?
- Loop output for custom plugin [solution found]
- PHP Fatal error when using plugin_basename
- How to Rewrite WordPress URL for a Plugin
- How to parse without changing the characters case (lower and upper) in wordpress the_content?
- On one of my sites a file is shown as 404 but the file IS there
- Options don’t save, validation callback not executed
- Why does this fail: Disabling plugins enqueue_script() in functions.php
- Sharing changes to a post (preview changes) with another user
- I want to add post meta for picture thum during submit for revision
- Add admin settings and options
- mysql_real_escape_string() error using xml2ary in WordPress plugin
- Menu_slug used for creating options page
- “Print to printer” functionality in a plugin
- get_the_term_list() wanting to loop through the returned values
- List custom taxonomy terms
- show 10 most recent custom post types excluding the one(s) from specific custom taxonomy
- modify buddpress adminbar only in admin pages
- How to specify widget order or css name via script?
- How do you filter get_media_items by mime type in a custom media upload tab?
- Deactivate plugin on registration
- How to view plugin ratings?
- get_categories exclusion issues
- How to conditionally include a custom field on category editor screen not category “add” screen