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.

A tool to convert PSD to PNG

There is a Command-line (Terminal) tool from Telegraphics called PSDParse that parse Photoshop PSD format files and dump layers to PNG files.

psd2png.exe -w Filename.psd

usage: psd2png.exe [options] psdfile…
-h, –help show this help
-v, –verbose print more information
-q, –quiet work silently
-w, –writepng write PNG files of each raster layer (and merged composite)
-d, –pngdir dir put PNGs in directory (implies –writepng)
-m, –makedirs create subdirectory for PNG if layer name contains \’s
-l, –list write an ‘asset list’ of layer sizes and positions
-s, –split write each composite channel to individual (grey scale) PNG

Replacing WordPress Cron With A Real Cron Job

In many situations, the WP-Cron may not working well or work at all. By default WordPress is setup to call wp-cron.php only when someone visits your site.

A better way to use the cron job that is available on your hosting server. In your cpanel, look for your cron job icon, click on it and select Add New Cron Job, then add the following line.

wget -q -O - >/dev/null 2>&1

Remember to replace “” with your actual url of your site.

If you have access to ssh, simply type

crontab -e

This will open a file for you where you will be able to add the line above.