Back to Community

How to Completely Uninstall Code Snippets and Remove All Data

19 threads Sep 16, 2025 PluginCode snippets

Content

Many users of the Code Snippets plugin encounter a common issue: they deactivate and delete the plugin, only to find that their snippets and plugin data remain stored in the database. This can be particularly problematic if a faulty snippet caused a site crash, as reinstalling the plugin will reactivate the same problematic code. This guide explains why this happens and provides the definitive methods for performing a complete cleanup.

Why Does Plugin Data Remain After Deletion?

By design, the Code Snippets plugin does not automatically delete your snippets or database tables when you remove it. This is a safety feature to prevent users from accidentally losing all their custom code if they temporarily deactivate or delete the plugin for maintenance or troubleshooting. The data persists so that you can reinstall the plugin later and find all your snippets intact.

Method 1: The Preferred Solution – Using the 'Complete Uninstall' Setting

The most straightforward way to ensure all plugin data is removed is to enable the 'Complete Uninstall' option before deleting the plugin. This setting instructs the plugin to clean up all its data upon deletion.

  1. Reinstall and Reactivate: If you've already deleted the plugin, you will need to reinstall and reactivate it from your WordPress dashboard.
  2. Navigate to Settings: Go to Snippets > Settings in your WordPress admin menu.
  3. Enable the Option: In the General section, check the box for 'Complete Uninstall'.
  4. Save Changes: Click the 'Save Changes' button at the bottom of the page.
  5. Deactivate and Delete: Now, you can deactivate and delete the plugin through the standard WordPress Plugins menu. This should remove all snippet data and database tables.

Note for Multisite Networks: On a WordPress multisite installation, you may need to access network-wide plugin settings at /wp-admin/network/admin.php?page=snippets to find this option.

Method 2: Manual Database Cleanup (Advanced)

If you cannot access your WordPress admin dashboard because a snippet has crashed your site, you will need to manually remove the data from your database. This requires using a tool like phpMyAdmin, often available through your web hosting control panel.

  1. Access your Database: Log into phpMyAdmin and select your WordPress database.
  2. Locate the Tables: Look for the following tables. The prefix wp_ may be different on your installation.
    • wp_snippets
    • wp_ms_snippets (on multisite installations)
  3. Delete the Tables: You can safely delete these tables. This will permanently erase all snippets.

Warning: Directly modifying your database is risky. Always create a full backup before proceeding.

Method 3: Using Safe Mode for Troubleshooting

If your site is crashing due to a bad snippet, you may not need to uninstall the plugin entirely. The Code Snippets plugin includes a 'Safe Mode' feature designed to temporarily disable all snippets, allowing you to access your admin dashboard and fix the problem.

You can often activate Safe Mode by appending &snippets-safe-mode=1 to your admin URL, like so:

https://yoursite.com/wp-admin/admin.php?page=snippets&snippets-safe-mode=1

Once in Safe Mode, you can deactivate or delete the problematic snippet, resolving the crash without needing a full uninstall.

Frequently Asked Questions

Q: I enabled 'Complete Uninstall' and deleted the plugin, but a table like ms_snippets is still there. Why?
A: This is a known issue that has been reported by some users. In most cases, all tables are removed correctly. If a table remains, it is safe to delete it manually via phpMyAdmin as described in Method 2.

Q: Does the plugin have a trash or revisions system?
A: No. Unlike WordPress posts and pages, snippets do not have a trash can or a built-in revisions system. Deleting a snippet is permanent unless you have a database or site backup to restore from. The Code Snippets team has noted that implementing this would be a significant undertaking.

Q: I'm on a multisite network and can't delete the plugin. I get an error saying "you cannot delete a plugin while it is active on the main site." What should I do?
A: This is a WordPress core restriction, not one imposed by the plugin. You must ensure the plugin is deactivated on all subsites in your network before you can delete it. A caching plugin may also sometimes interfere with this process; try clearing your cache if you encounter issues.

Related Support Threads Support