RevealTheme logo
Back to Blog

WordPress Plugin Cleanup After Deactivation

WordPress Plugin Cleanup After Deactivation
The RevealTheme Team

By

··3 min read

Deactivating a WordPress plugin stops it from running but leaves its data behind: options in wp_options, custom database tables, scheduled cron events, user metadata. The leftover data accumulates over years.

The cleanup after deactivation is small effort with real benefit. Sites that don't clean up accumulate database bloat from years of deactivated plugins.

Step 1: deactivate fully

If you're certain the plugin is no longer needed, fully delete rather than just deactivate. The deletion through WordPress admin runs the plugin's uninstall hooks if they exist.

The plugin's uninstall hooks should clean up its own data. Quality plugins do this; lower-quality plugins don't.

Step 2: check for leftover options

Query wp_options for entries with the plugin's prefix:

SELECT * FROM wp_options WHERE option_name LIKE 'plugin_prefix_%';

Entries that remain are the plugin's leftovers. Delete them.

Many plugins use predictable prefixes; some use less predictable patterns. Search documentation for the plugin's option naming if you're not sure.

Step 3: check for custom tables

Plugins sometimes create custom database tables. After plugin removal, the tables remain.

List tables: SHOW TABLES FROM database_name. Compare against the standard WordPress tables. Unfamiliar tables are likely from plugins.

Drop tables from removed plugins: DROP TABLE table_name. Always backup first.

Step 4: check for cron events

Plugins schedule cron events that may persist after deactivation. WP Crontrol shows the cron queue.

Events scheduled by removed plugins should be unscheduled. WP Crontrol lets you remove them.

Step 5: check user metadata

Some plugins store data in wp_usermeta. After plugin removal, the user metadata may persist.

The cleanup is similar to wp_options: query for entries with the plugin's meta_key prefix; delete them.

The automation option

Plugins like Advanced Database Cleaner identify orphaned data from removed plugins. The automated identification is more reliable than manual searching.

For sites with many historic plugin installations, the automated cleanup can recover significant database space.

The honest framing

Plugin cleanup is a discipline that prevents database bloat over years. Each individual cleanup is small; the cumulative effect of disciplined cleanup is significant.

For sites that have never cleaned up after plugin removals, the first audit usually reveals more leftover data than expected. The cleanup is one-time work that prevents future accumulation.