WordPress Plugin Lifecycle Generator
Generate safer activation, deactivation and uninstall code WordPress plugins have three different lifecycle moments, and mixing their responsibilities can cause lost settings, stale rewrite rules, or database clutter. This generator creates starter code that keeps activation setup, temporary deactivation cleanup, and permanent uninstall cleanup separate. What this generator helps with Use it when building a […]
Runs locally in your browserReview destructive uninstall code before shipping. Deactivation should not normally erase persistent user data.
Generate safer activation, deactivation and uninstall code
WordPress plugins have three different lifecycle moments, and mixing their responsibilities can cause lost settings, stale rewrite rules, or database clutter. This generator creates starter code that keeps activation setup, temporary deactivation cleanup, and permanent uninstall cleanup separate.
What this generator helps with
Use it when building a plugin that needs default options, rewrite-rule setup, transient cleanup, or an explicit uninstall policy. The generated code is intentionally conservative: deactivation keeps persistent user data, while destructive cleanup is placed in an uninstall.php example and only generated when you explicitly select it.
Activation vs deactivation vs uninstall
Activation is appropriate for one-time setup such as adding defaults or preparing rewrite rules. Deactivation is appropriate for temporary cleanup such as cached runtime data. Uninstall happens when the plugin is deleted and is the appropriate stage for permanent removal of plugin-owned options or tables when that matches the product’s data-retention policy.
Before using generated code
Review every generated identifier and cleanup statement. Do not drop a table merely because a plugin is removed unless users have been clearly told that uninstall deletes stored data. For multisite plugins, network activation and per-site cleanup require additional planning and should not be treated as a simple single-site loop.
Verification checklist
Test on staging. Activate the plugin and confirm defaults are created without overwriting existing values. Deactivate and reactivate it and confirm persistent settings remain. Test permalinks if the plugin registers rewrite-producing content. Finally, test uninstall on a disposable copy and inspect the database to verify that only the intended plugin-owned data was removed.
