I’ve been wanting to set up a ‘Test Drive WordPress’ site, and I think I’ve finally got the script that will get me there.
I tried to make it easy to configure, so you’ll find all the basic options at the top of the file. Of course, if you want more advanced customization (multiple users, extra posts, active plugins) you’ll need to add that yourself.
The idea here is that when the code first runs, it’ll schedule and update for one hour (or whatever you specify) from now. From then on, it will always compare the current time to the next scheduled time, and reset if it’s time to do so.
Why not use the built-in WP Cron API? I tried. Maybe I’m doing something wrong, but I just couldn’t get it to work for me.
During the reset, this is what happens:
- All files in the upload directory are deleted
- All WP database tables are dropped
- WP is reinstalled with given settings. Default settings defined in this plugin:
- Blog title: WP Testdrive
- User name: demo
- User email: [email protected]
- Public: 0
- User password: demo
- Hide welcome dashboard (default, true): Hides the large welcome panel that appear on the dashboard of a new installation
- Show feature pointers (default, false): Make the feature pointers appear, though they would normally be hidden on new installations
- Show credentials on login page (default, true)
- When someone logs in as the demo user, create a new demo user, show new credentials on login screen (default, true)
- Generate random passwords for new demo users (default, true)
Use with caution. This has had only limited testing so far, and none of it on multisite. This thing is dropping tables, so make sure there are none you want to keep. That said, be smart, and if something goes wrong, don’t blame me (seriously, you’ve been warned).
You’ll also want to make this a must-use plugin (put it in wp-content/mu-plugins) so that it can’t be deactivated by your test drivers.
Bugs or Suggestions?
Let me know in the comments, or catch me on twitter (@trepmal).
December 16: fixed silly bug where I used the wrong variable names for ‘hide welcome dashboard’ and ‘show feature pointers’.
December 16 (2): added more options. Next reset time is saved in an array so that it cannot be changed via options.php
December 17: Reset will only happen on admin-side. Fixed issues if ?resetnow is run on wp-login.php. Fixed redirect after reset.