When developing solutions such as themes, plugins or a custom solution, the database tends to get bigger and also with the defaults already saved. When adding new and complex features, to test them, databases should be empty.
WP Reset is a free WordPress plugin that has a lot of features that you might have used through different plugins.
This plugin is focused on resetting data so any files that you have, will always be there (be it plugins, themes or uploads). But if you want to completely remove them, which does come in handy when testing uploads, you can.
If you are used to and like to work with WP CLI, this plugin does provide you a command list for this plugin.
So what does this plugin reset?
- All default WordPress tables,
- All custom tables with the same prefix.
But, before resetting the tables, you might want to save the current state of your database.
Snapshots
Snapshots are a really handy tool which is going to save a copy of your database, so you can then review what has changed in a recent update or a new feature. You can then also restore that snapshot if you want to get to a prior database state.
Each snapshot can be downloaded, deleted, restored and previewed. The preview of the snapshots gives you the ability to see what changed and what is different between the current tables and the snapshot tables.
You can see how this tools compares the current database with the snapshot’s one. Each compared tables can be expanded to see their summed values. If a table has different values, you’ll see a yellowish colored background of table names.
Tools
There are also several tools with the WP Reset plugin. Some are data related and some are file related.
Delete Transients
This is a data related tool which can be used to delete all transients in your database. This can be helpful when you’re developing a feature of your solution that uses transients to cache data.
For example, complex queries done with WP_Query
or with direct database calls, can take a lot of time to perform. Transients can help here so they deliver the data without the complex queries.
With this tool, you can test the implementation of this caching mechanism while developing it.
Clean Uploads Folder
This is a tool that is file-related and will delete all folders and files inside of the wp-content/uploads
folder. When developing solutions that have anything to do with uploads, this really can be a helpful tool.
When I’ve built solutions with custom folders in the uploads folder, this tool would be useful to me as my folder grew more and more in size.
Reset Theme Options
This is another data related tool. Be aware that this tool can’t reset options that are not stored using the WordPress Theme Modification API.
This might guide you also when building themes to use the modification API and develop your theme in an even more “WordPress way”.
Also, this WP Reset tool will reset data from all the themes, not only the active one.
Delete Themes
This tool will delete all themes from the wp-content/themes
folder, even the active one. This can be helpful if you want to test your solution and be sure that it is not dependant on a theme.
Or if you have a fresh WordPress install, this will get rid of all the default themes that come with WordPress.
Delete Plugins
This is the same as the previous tool but related to plugins. This will delete all the plugins from the wp-content/plugins
folder. The only plugin that won’t be deleted is the WP Reset itself.
Empty or Delete Custom Tables
This tool is data related and it will delete or just rest the custom tables and not touch the default ones.
If you’re building custom plugins and you create custom tables for better scalability and performance, this is something that might be useful to you. I have recently published a new plugin and this tool will help me testing new features that use my custom tables.
You can also delete them completely. This can be really handy if you want to test how and when your custom tables are going to install. If you’ve changed the table schema, you should use this tool to see if there are any errors when the tables are being created.
Delete .htaccess File
This will delete the .htaccess file. The team behind WP Reset also provides a tool to edit the .htaccess called Htaccess Editor.
If you’re testing several .htaccess configurations and your file got too big. You might want to start with a fresh default WordPress .htaccess. You can delete the current one with this tool and then go to Settings > Permalinks, hit save and you have the default one created for you.
Resetting your data
Now that we are aware of all the available tools and features, let’s get to know the main function of WP Reset, and that is to reset your data.
You can choose what actions should be performed after the data was reset. Those actions are:
- Reactivate the current theme,
- Reactivate the WP Reset plugin,
- Reactivate all currently active plugins.
The default option that is active is to reactivate the WP Reset plugin. If you want to have everything activated as it is before the reset, you can check the other two as well.
WP CLI
This plugin comes with a set of commands you can use with WP CLI. By typing wp help reset
, you can get the list of them.
To find out how to use each of the commands, you have to type wp help reset <command>
.
Delete Command
The delete command will delete whatever you set to be deleted. When using this command, you have a few options.
wp reset delete <objects>
The options are:
objects
can be: plugins|themes|transients|uploads|custom-tables|htaccess|theme-options, if you pass
--yes
, the confirmation prompt will be ignored as if we were saying Yes to the delete command,, if you pass
--empty
, custom tables will be emptied and not deleted.
Reset Command
This command will perform the reset function of the WP Reset plugin. We can use it as it is, or with options.
wp reset reset
The options are:
--reactivate-theme
, if passed, it will reactivate the current theme,--reactivate-plugins
, if passed, it will reactivate all active plugins,--reactivate-webhooks
, if passed, it will reactivate the WP Webhooks plugin,--deactivate-wp-reset
, if passed, it will deactivate the WP Reset plugin,--yes
, if passed, the confirmation prompt will be ignored as if we were saying Yes to the delete command.
Snapshots Command
The snapshots command will help you manipulate the WP Reset Snapshots tool. When using that command, you have to specify which action to perform and you can optionally specify a few more options.
wp reset snapshots <action>
All the options are:
action
can be list|create|restore|export|delete,--id
, if we try to restore, delete or export a snapshot, we need to pass the ID,--name
, if we want to create a new snapshot, we need to pass the name of the snapshot,--yes
, if passed, the confirmation prompt will be ignored as if we were saying Yes to the delete command.
Conclusion
WP Reset is a great tool if you are developing solutions upon WordPress. This can make you test features, that have anything to do with data, more easily.
You can check how a plugin performs on fresh install, or on a specific database configuration using snapshots.
This can also come in handy on a staging site if you are testing a single feature. Having more snapshots can help you test a new feature on the staging site with different setups.
Become a Sponsor
Share this: