Cleaning up when uninstalling

It could happen to any developer: a user decides to uninstall your plugin. It's a scenario that you should prepare for, especially if your plugin performs any database modifications. You should consider it a bit rude if your plugin makes custom modifications to the database or file system and does not clean up its mess when asked to leave. Cleaning up is just being considerate. Unfortunately, many plugin authors fail to do this, and who can blame them when the process is so poorly documented? Let's show you how to do this relatively simple task.

When you choose to delete a plugin, WordPress will look for a special file, named uninstall.php, located at the root of your plugin's directory. In it, you can place all the ...

Get WordPress 3 Plugin Development Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.