I know that I should probably be using some form of version control for my WordPress site, but setting up something like GitHub seems a bit too geeky for me. That means that I’m stuck changing code on live sites like most WordPress site owners, which is unfortunately pretty common and even has a meme associated with it:
WordPress does provide version control for posts (ramp is a good option for WordPress authors who need content version control) but to safeguard your entire site from bad code, you can try one of the WordPress versioning strategies discussed below.
The Revisr Plugin
Revisr allows you to use your Git repository to push out / revert code changes to your WordPress site. The plugin uses the Git methodology of branches to allow you to test out different versions of your websites (including different options being set in your database tables) before deploying. Revisr expects the WordPress installation to be in the root of your git repository so don’t stuff it away in a subdirectory. I mentioned that I’m not fluent in Git to use a plugin like Revisr but I know people will be searching for a WordPress Github version control plugin so here it is.
VersionPress is a paradigm breaking plugin that changes the way you approach “backing up” your site. Every change you make gets backed up and can also be undone. Take the example where you mess up something on your site but don’t notice it until days later. With a traditional backup, you’d have to undo all the changes you’ve made in the interim to get back the last working version of your site. Using VersionPress, you could selectively revert your mistake without affecting any thing you’ve changed to your site afterwards. VersionPress also allows bidirectional syncing between a testing environment and your live site and also allows pushing changes to remote repositories like GitHub or BitBucket. Follow the VersionPress Twitter feed to keep up on its development.
The Localhost Method of Version Control
A simple version control system can be accomplished by running localhost on your desktop computer while syncing & reverting both database and file changes to your production site. This setup requires two things to be setup:
1. PHP / MySQL / Apache to be setup on your home machine. Desktop Server is quickly becoming my preferred solution, with Windows & Mac support and a free version that allows for 3 separate localhost sites. The paid version is required to see your localhost sites ‘live’ on the Internet, but you can achieve the same outcome using ngrok.com or localtunnel.
2. A plugin that talks to both your localhost / live sites and is able to push / sync / revert changes. WP Migrate DB Pro is adept at this:
And I advise you to use the open-source fork of it at https://github.com/senlin/wp-sync-db which also provides the media library syncing capabilities (a paid WP Migrate DB Pro upgrade) for free.
Pantheon for WordPress Version Control
Instead of relying on a plugin or 3rd party service to ensure you’re not testing code changes on your production server, what if your host made changes to your live site impossible without testing it first on a development server? That’s the approach that Pantheon takes and their setup goes far beyond the ‘staging server’ setups that you find at managed hosts like Pressable and WPEngine. Hosting a site on Pantheon places you in a workflow that looks like this:
This setup requires you to pull code changes that you’ve made in your dev subdomain into your testing subdomain before pushing those changes into your live site.
Working with a hosting environment that has Git baked-in (SiteGround’s GoGeek plan is another) saves you from having to rely on Capistrano or a secondary service like dploy.io to push changes. But you don’t have to use Github to benefit from Pantheon’s version control. You can make changes in your dev environment in SFTP mode & commit those changes so they stick. You can also create bundles using their plugin (wp-admin/options-general.php?page=wpcfm) which creates a bundle_name.json file in wp-content/config:
Pantheon also handles the cache for you at the server level so you don’t need to install caching plugins like WP Super Cache / W3 Total Cache (which are not supported on their platform). If you used plugins like W3 Total Cache just for the CDN component in the past you can try using something like the WP Stack CDN drop-in instead. There’s a one-click process for starting a new WordPress site or you can import an existing site using a WordPress Duplicator / BackupBuddy archive which it will automatically parse and import.