VersionPress – WordPress Meets Version ControlBy Shaumik Daityari
With the increasing popularity of version control, most developers are now accustomed to its capabilities. We have tried to extend the use of version control beyond the management of source code — like managing database dumps and designs. Therefore, it is not a surprise that the last few years have seen the application of version control to WordPress too.
Earlier this year, I published a post on Revisr, a Git plugin for WordPress. Revisr enabled you to initialize a Git repository within your WordPress source code, and also include database dumps in your backups.
Revisr is a great tool, but it’s not fit for everyone. You need to have the basic understanding of Git to be able to use the plugin seamlessly. Also, I believe that it would be difficult for beginners to handle remotes to move their backups to the cloud.
This article focuses on VersionPress, another plugin that we’ve previously touched on that tries to apply version control to a WordPress project. Although VersionPress uses Git, there is no mention of Git, as long as you have installed the requirements. It tracks every action that you perform on the WordPress admin panel, enabling you to undo every change, or roll back to the state of that change. One thing that struck me the most was the simplicity of the plugin — there are no unnecessary settings to divide your attention.
In my examples, I’ll be using the 1.0-RC3 version of the plugin. Download the plugin, install and activate it. After activation, a new item appears on the left panel. Clicking it takes you to the second step of activation, where the plugin needs to perform a few actions before tracking changes in your WordPress site.
Second step of activation.
Track changes to the whole site
Let us now explore what VersionPress is capable of. Let us create and publish a new post — “Test Post 1” and see how VersionPress records our actions.
Status after creating a post.
VersionPress correctly notes that a draft for the post was first created, and then it was published. We will go through undo and roll back in the next section.
Let us now change a few settings and see what how VersionPress records them.
Status after changing settings.
It is interesting to note that while changing multiple settings, VersionPress only reports one change in the message next to the change. We will get back to this issue later, when we dig into the working of the plugin.
Next, we install a plugin and check the changes as reported by VersionPress to make sure it records each change.
Turn Back Time
As discussed earlier, VersionPress allows you to perform two actions —
- Revert specific changes without affecting new changes
- Rollback to the state after a change
Let us first undo the settings change in the previous part.
It is worthy to note that although the message showed a single change, an undo affected all the changes I made to the settings.
Similarly, let us rollback to a plugin install stage.
Another important part to note is that VersionPress only records changes that are made to your database or source code. It can not ascertain whether the process of undo or rollback can break the site. For instance, on activation of the jetpack plugin above, you can see a specific table change too. Rollback or Undo of one can affect the plugin, which is why you should be careful while performing these changes.
Check the Git Status
This is an optional section and you should proceed only if you are familiar with Git, a popular version control solution.
On navigating to the root folder of your WordPress project, you would find that VersionPress has initialized a Git repository. You can check the commits that have been created by running the following command —
If you notice carefully, you can see that revert commits are created when you undo a change rather than removing commits.
Also, if you decide to work on the Git repository through the terminal or a GUI client, the custom commits that you create are picked up in the VersionPress log and you can perform undo or roll back operations on them.
Database structure of plugin
If you notice the database schema, there is only one table created by VersionPress —
vp_id. This is to link different elements with the same IDs in WordPress like a post, page or a comment, which are treated the same way by VersionPress.
This project is fairly new and there is a high probability of errors. If you find an error, click on the gear on top right and send a bug report to the developers.
We’ve now covered the workings of VersionPress in detail. The developers are soon going to add new features, one of which is to introduce the ability to create backups of your whole project. Separate functionality of database backups is not needed as every change in the database is recorded by VersionPress and you can easily revert them back. Another feature that would be great to have, is the ability to sync the changes in the local repository with the cloud through a remote (although currently, it can be achieved by adding a remote and pushing the changes manually).
There are also certain issues that might be raised with the use of this plugin in the future. Let us take the example of sporting news site Sportskeeda, which thrives on thousands of contributions from the community daily. Facebook has concluded that Git becomes slower with such a huge number of commits. It would be interesting to see how VersionPress will handle such drawbacks of Git — when Git itself takes up a huge amount of space and multiple people are accessing the site at the same time.
I would like to conclude by congratulating the developers on coming up with a wonderful product, which simplifies a complex problem for the masses. If you would like to test the plugin, feel free to get in touch with the VersionPress developers here.