Automated Multiple WordPress Version Setup

Automated WordPress Setup
Automated WordPress Setup

For plugin development, you need to maintain a number of WordPress versions for testing. I need to at least install 5 version of WordPress if I start with 4.7.
The setup of a normal setup is:
1. Create database, user and password
2. Download WordPress, unzip, move to expanded folder
3. Copy and rename wp-config-sample.php to wp-config.php and add-in the credentials
4. WordPress core is updated automatically, you need to remove auto update feature by adding a line in wp-config.php

The Problem
Repeating the task everything you need a clean testing environment can be tedious.

Of course, there is WP-CLI the command line interface for WordPress but many web-hosts do not have WP-CLI installed, sometimes they have a strip down version, others they simply don’t work. If your host is provided with ssh, we could write a script for these, if not a good option will be to create all the files and then send it up by FTP.

The Solutions
For now, we will work with SSH. The solution will consist of 2 parts, a script to install the files and setup the database and another to open up the browser and complete the setups.

Part 1: The Server Script
We need a script that can be executed on the server that will download WordPress version 4.7.1 – 4.8. Since the archive version URL naming is quite standard

We can easily use a bash script to loop through and grab them with wget or curl.

arr=( "4.8" "4.7.5" "4.7.4" "4.7.3" "4.7.2" "4.7.1" )
## now loop through the above array
for i in "${arr[@]}"
curl -O$i.tar.gz

To complete the code, we need to unzip, rename the folder, add and insert our credentials to the wp-config.php
I modified a code by bgallagh3r.

We still need to add the code for creating the database. Since most web-host do not allow the use of root for MySQL, you need a user id that has the privilege of creating databases. If not, you can only create it manually through your web interface.

function createdatabase () {

During my research phase I came across some solution that generates different username and password for each site, but I prefer to keep it simple with just one username and password for all sites. I anticipate that these sites will be torn down once the testing is done.

Part 2: The Client-Side Script
We need a script to open up the browser and input, select and click through the steps. I choose Python and selenium. You can find out more here

First, download Python bindings for Selenium.
sudo pip install selenium

We need ChromeDriver that can be download here and read the ChromeDrive documentation here

from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver') # Optional argument, if not specified will search path.

Test and make sure that the path to ChromeDrive is correct and Selenium is installed correctly. This should launch google on a new browser window.
Now let’s work on our script.

Automated WordPress Setup Part 2
Automated WordPress Setup Part 2

Now let see how the whole thing runs on the client side.

See how easy it is to automate everything with a few lines of code.

Plugin for a productized service

If you are looking to launched a productized service like There are currently no plugins that support this fully.

I am cobbler together a few plugin and duct tape one for proof of concept.

The Required Plugins:
Responsive Pricing Table
WP Full Stripe Free
Contact Form 7

The Main Setup
First Setup your 3 tier offer using Responsive Pricing Table

Create all the payment type in WP Full Stripe Free.

In each payment type create a Thank You page with in contact from 7. Here you collect all the necessary information from your customer e.g. email address, web URL.

The duct tape Part
Under the 3-tier offer that you have setup in Responsive Pricing Table. On each button link, link to the payment type you have created.

On the payment form that you created in WP Full Stripe Free, add the page under “Redirect to” select the correct thank you  page.

Basically we are just creating 1 offer, 1 payment and 1 contact from for each tier that we offer.


First recurring payment is not setup, this can be easily fix by upgrading  WP Full Stripe Free to Pro, which include recurring payment. However, I would like to allow clients to create an account, purchase a subscription, change subscription type of cancel subscription. How about support/ job tickets tracking, allow clients to upload files such as backups. Ideally I could create reports and send notifications for clients, admin and maybe staffs.

Would you be interested in a plugin that have all these features?

Customising Woocommerce Report

Creating a simple plugin to generate a woocommerce report that suits your need. All woocommerce sites are different, the way they sell are different. Many plugins available are able to generate reports and customise them. Still I get a lot of request on customising reports for woocommerce.

I use the WC_Admin_Report class from woocommerce to accomplish this. With WC_Admin_Report, you organise all your required fields and condition in an array and pass it over. Write the results in a CSV, comma delimited file, using fputcsv and you are done. Throw in some nice jQuery and you get a really slick reporting system.