Post Message To Slack

If you are using slack I am sure you have thought of making certain items post real-time to slack so you can keep track of it.. this is actually easier then you think. You can put the below code in a function of use it directly. Lets get started:

define('SLACK_WEBHOOK', '*your slack detail*');
$fields = array();
$slackMessage = array();
// Pass through an array of data consisting of a title and a value. This will be added to the clack message
foreach($data as $key => $d) {
             $fields[] = array(
			'title' => $key,
			'value' => implode(',',$d),
			'short' => false
	} else {
		$fields[] = array(
			'title' => $key,
			'value' => $d,
			'short' => false

$slackData = array(
	'color' => "#f49600",
	'pretext' => '* Insert your message heading *',
	'fields' => $fields,
	'ts' => strtotime(date('Y-m-d'))

$slackMessage['attachments'][] = $slackData;

// Make your message
$message = array('payload' => json_encode($slackMessage));

// Use curl to send your message
$c = curl_init(SLACK_WEBHOOK);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $message);
$result = curl_exec($c);

WordPress relative url’s in posts

If have you ever used wordpress in an environment where you have dev, testing, staging and production environments you would understand that the default wordpress uses when inserting media into posts is by adding the complete url to the media item. Now In a scenario where you have different environments with different urls and you use git and scripts to snc the database between the environments the full url can cause issues because as soon as its deployed to a new environment the urls will differ and your images in your content will be broken.

So the easiest way to fight this is by changing the way wordpress inserts the media items, instead of adding in the full url’s rather add them with a relative url. What this means is instead of adding a url like “” it will insert a url like “/wp-content/uploads/07/images.jpg”.

Basicly it doesnt matter what the domain is the images will include correctly and when deployed over to new environment it will work fine.

So this can be accomplished with a few lines of code that you can add into the functions.php of your theme.

function switch_to_relative_url($html, $id, $caption, $title, $align, $url, $size, $alt)
$imageurl = wp_get_attachment_image_src($id, $size);
$relativeurl = wp_make_link_relative($imageurl[0]);
$html = str_replace($imageurl[0],$relativeurl,$html);

return $html;

How To: Leverage browser caching

If you are using google pagespeed to measure your site speed you might find it says you must leverage browser caching to improve your site speed.

Fairly simple job and fairly standard. All you need is to add a few lines of code to the .htaccess file which can be found in the root of your website files.

Open it by using filemanager in your cpanel or downloading – editing – and uploading it.

When opened go to the last line and on a new line add the following:

<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"


Windows 10 Cant send email Issue

I recently found a few client phoning me explaining, they cant send emails from outlook even though on the account settings screen the “Test Account Settings” test delivers successful results.

The Message Office gives is something similar to cant connect to server. All of the clients had one thing in common, they recently upgraded to Windows 10. Well luckily there has been oen fix that proved successful every time so far.

On the PC open a Command Prompt window, this can be done by clicking on the search icon and type “CMD”. From the results you are given right click the “Command Prompt” item and click on “Run as Administrator”.

A new window opens ( with a black background ). in this window type “sfc /scannow”.

Leave it to finish and thats it. Close your Outlook and open it again.

Should be working.

Usefull Links

Here are some links that is dropping of my bookmark bar =)

Have to save them somewhere so might as well do it here.

Awesome CSS3 E-Commerce Cart Ideas


View Link

doCapture- Free, quick, high-res, website screen captures in the exact size you need.


View Link

Designbeep – Free Resources For Designers and Developers

Screen Shot 2015-08-28 at 8.11.17 AM

View Link

WordPress SEO – The Definitive Guide To Higher Rankings For WordPress Sites

Screen Shot 2015-08-28 at 8.11.25 AM

View Link