Category Archives: Tutorials

WordPress, HTTPS, CDN and W3 Total Cache – Take 2

I’ve previously mentioned some of the workarounds of using the excellent W3 Total Cache plugin with a CDN and utilising HTTPS on some pages. The heart of the matter is that some CDN providers do not provide Custom HTTPS support out of the box or do but with a normally large monthly fee attached, some like the excellent MaxCDN will provide free shared SSL support but that is on there own domain, for example for this website, using MaxCDN my HTTPS domain for CDN is

The Problem

By default when you configure W3 Total Cache with a CDN it assumes that your CDN hostname is the same for HTTP or HTTPS. However for providers like MaxCDN and people that don’t want to pay or simply merit the costs of Custom HTTPS support, this means, that as before without disabling CDN on HTTPS pages you would get a mixed content error or worse the CDN elements may fail to load at all, something especially true with Google Chrome.

The Solution

We stumbled upon a solution while chatting with the W3 EDGE team about the issue that there currently exists a way to specify the HTTPS CDN hostname separately from the HTTP hostname. It appears that this feature request was completed some time ago but never made its way into documentation, and the solution is remarkably simple and requires no code changes or additions to get working.

w3tc-cdn-settingsYes it is that simple! in case the image is unclear, in the replace site’s hostname with field, simply supply a comma separated list of hostnames in the format,

and W3 Total Cache will do the rest for you. If you take a look of our Contact page source then you will see that things like CSS files are now loaded from the different HTTPS endpoint compared to the other pages on the site.

If you are a MaxCDN or NetDNA customer you can find your HTTPS domain very easily, login to your MaxCDN/NetDNA portal, go and manage your Pull Zone, there should be a tab called SSL, simply make sure the enable shared SSL option is ticked and save your settings, then the SSL URL should be shown on that same tab if it wasn’t already like in this screenshot:


Now you can enjoy faster more consistent page load times even on HTTPS without causing an extra drain on your server or your wallet.

Use WordPress and Gravity Forms to submit a ticket to Sirportly

We recently moved our support system from Zendesk to Sirportly as its a cheaper and much cleaner and simpler solution. what i’ve been trying to do for sometime now is to be able to have a form on our site for general contact queries (as well as an old fashioned email address) that would log a ticket in a seperate channel on the support system, the zendesk implementations didnt seem to allow this, with Sirportly however they had basic remote forms which generate a html form that you can embed on a site which is great, just what we wanted.

If you read around you will know that embedding a simple html form on a wordpress site can be challenging in the least at times, so i wanted to avoid that, i already had gravity forms installed from some old historic (no longer used) forms so thought i might be able to hook into that and i found out we could. using the gform_post_submission hook we are able to do just that! so i set about creating a function that hooked in and took the gravity forms data and submitted it to sirportly and came up with a basic “dirty” function, i’m calling it dirty because i’m sure theres a better way to do things most likely via there API and with a gravity forms addon and it also creates an entry on your site too (free backup?), it also doesnt detect errors on the sirportly side (eg with the post), before i get to the code, a little bit of setup is required:

On the Sirportly side, you need to create a remote form as per the docs here: you have to fill in the success and failure redirection but we wont use this: i just put in the website home page to allow it to go through, i also deselected include custom fields (but with some manual work this could be made to work also as its only extra fields) then click on test/view form markup to see the html, the most important piece of info you need from here is the form post url, it will be in  a format similar to: where formnumber is the actual remote form id, keep this for later!

Next import the following form to gravity forms, its just a basic contact form: but helps speed up matters – remember to disable all notifications on the form (you dont want 2 lots of emails now do you!), save the form and take note of its form_id , you’ll need this now.

all thats left to do is link together with some custom code that does the magic, add the following to your functions.php file in your theme (or custom_functions.php within the custom folder if you use thesis) – you may not need the php opening and closing tags – this is just for the benefit of the syntax highlighter


//edit this to match the form id matching the form you want to post to sirportly for me it was form_id 3
add_action("gform_post_submission_3", "post_to_sirportly", 10, 2);

function post_to_sirportly($entry, $form){

//numbers in here should match the field ID's in your gravity form
$post_data['name'] = $entry["1"];
$post_data['email'] = $entry["2"];
$post_data['subject'] = $entry["3"];
$post_data['message']= $entry["4"];

foreach ( $post_data as $key => $value) {
$post_items[] = 'ticket[' . $key . ']' . '=' . $value;

$post_string = implode ('&', $post_items);

//edit this to the post url in the generated HTML for your sirportly remote form
//create cURL connection
$curl_connection = curl_init('');

//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);

//we dont want sirportly to redirect us as we are allowing gravity forms to handle things
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);

//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);

//perform our request
$result = curl_exec($curl_connection);

//close the connection



now on line 4 above, edit the action so that it only targets the form you created earlier, in my case it was form_id 3 hence the value, then take the POST url you grabbed from the Sirportly remote form html earlier and replace the url in the curl_init statement with it, save the file and upload it and test your form, if all worked you should be able to successfully submit the form and it will post it off to sirportly and you will get a nice email in your inbox saying a ticket has arrived!

now our contact page has a great form and we get it all logged through sirportly so that we don’t lost track of queries that come in via the website.

HOWTO: Upgrade Debian Lenny (5.0) to Debian Squeeze (6.0) on Rackspace Cloud Servers

I recently posted on how to update Debian for servers and its intricacies, I have since been able to document the process for Rackspace and this guide also works for Virtuozzo or OpenVZ VPS’ where you don’t have direct control over the kernel from your VPS so here goes.

strong>Disclaimer: please test this yourself first on a NON PRODUCTION SERVER. this may or may not work with other server providers but is specifically tailored to the Rackspace system, I do not guarantee its results outside of my tested system (Rackspace Cloud Server US DC from a stock Debian Lenny install).

I have found that on current Rackspace templates the archive key for squeeze has yet to be installed on the template so its best to start by updating the keyring to prevent GPG errors, I always recommend to start by running an apt-get update but this may not successfully complete so you may need to start with:

apt-get install debian-archive-keyring

you may also need to accept the GPG error temporarily, alternatively you can get the squeeze GPG key from and adding it into apt by running:

wget && apt-key add archive-key-6.0.asc

after this we can continue the step of updating our Debian install to Squeeze, to continue we must first update our sources.list file:

nano /etc/apt/sources.list

i recommend cleaning out the old list completely if this is a stock install otherwise replace the default Debian mirrors with:

deb squeeze main
deb-src squeeze main

deb squeeze/updates main
deb-src squeeze/updates main

deb squeeze-updates main
deb-src squeeze-updates main

remembering to update the mirror URL’s to ones closer to you if not using the UK Rackspace cloud.

Update the package lists.

apt-get update

Install locales update (to stop lots of annoying Locales errors while upgrading).

apt-get install locales

Then the final upgrade.

apt-get dist-upgrade

When you are asked for options.

Change to dash – doesn’t matter which is chosen this can be whatever you prefer.

Chainload grub 2 – NO.

Change to dependency based sequencing (i selected both and its fine).

Restart services just hit enter.

Reboot for good luck (Isn’t actually needed because kernel is more up to date than Debian and not updated during the upgrade but better to eliminate issues ahead of crunch time).


Sit back and Enjoy!