Deletion of shared options using uninstall.php

The question:

I’m using uninstall.php for my plugin to delete all the traces my plugin did to a site on uninstall (delete). I did it in a good way, but even after the deletion there are some fields in the options table:

  • uninstall_plugins
  • recently_activated
  • _site_transient_update_plugins

in these options there are multiple values from other plugins too.

How can I take care of such traces, how can I remove all those traces too?

I checked WooCommerce and found they leave no traces after there deletion, if the “delete data” checkbox is checked.

How can I do so?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

I don’t think that you should touch these options. WordPress core already handles this, whether by removing the references to your plugin when it is deleted (as in delete_plugins()), or by being coded in such a way that it can ignore the reference to the removed plugin. Actually, none of these three options will last very long, since they are all regenerated regularly. The one is a transient, which naturally expires anyway. The plugins are removed from the recently activated list after a week. And the plugin is removed from the uninstall_plugins option by uninstall_plugin().

Also, WooCommerce doesn’t touch these. It probably just looked like it removed itself because it was never added to these values in the first place, or was removed that quickly by WordPress. (It wouldn’t have been added to uninstall_plugins at all, because it uses an uninstall.php file instead of a function).

So, TL;DR: You don’t need to worry about this, WordPress will take care of it.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment