We're growing into something new. Read More

Adam Patterson


TextMate keymap for PhpStorm

I love TextMate, but it really suits me best for single file applications. It took some time for me to get used to and fully appreciate the shortcuts. One of the biggest adjustments I had to make while using PhpStorm was learning all new keyboard shortcuts. Ruby Mine includes a TextMate keymap since TextMate was the devfacto editor for the Ruby community. PhpStorm on the other hand lacked in these shortcuts. I decided to invest 15 min of my valuable time and created a TextMate Keymap. I should note that this was made on OSX and I suspect will probably only work on OSX versions of PhpStorm but let me know if it works for Windows as well. Installing on OSX - Open Finder, navigate to the location where you downloaded the XML and copy it. - Then locate ~/Library/Preferences/WebIDE##/keymaps/ - Paste the .xml file in and restart your IDE. Then navigate to Settings > Keymap and select the TextMate keymap. If all goes according to plan your KeyMap should be working.

Centring Columns in Bootstrap

Grids are great, Look at all that order that they provide! I have been using them for years, but there are always certain instances where the grid fails, and you begin to loose the practicality of the grid. For instance. If you had a 9 column grid and you need a 7 column wide centered row, no issues! Offset by one. But what if you had a 9 column grid and needed to center an 8 column row? Make your own class and move on. Oh wait, What about responsive layouts? I guess we are on our own with this and we just lost predictability with out layout. Following how Bootstrap generates their scaffolding I set out to create an easier way of dealing with centring structured grids, So enjoy!


How I made WordPress next / previous links work with Custom Post

I built a site recently that required a few different custom post types. Not an issue. As I looked at the design I saw that it called for next and previous "projects" and thought no issue at all I can use next_post_link() or get_next_post_link() No problem I got this!..... 4 hours later multiple searches no real good solutions I ended up writing a plugin that "seems" to work for me.

Personal logo

I revamped my logo, its been about 12 years now. Old on the left, with the newer version on the right, I always liked the shape of it but wanted to step away from the previous flat look. Creating the layered ribbon effect was a little tricky at first, but once I got the first portion rite I was able to copy it and position it equally, I used a gradient fading to transparent and more or less where the lines would have crossed gave it the effect I wanted. The logo is of my initials AP, done in lower case I also think the newer version was a bit more defined as an ap.

Tentacle CMS - Updated marketing site

Its been a few months since I posted any updates on my CMS, but there is a new marketing site. I have put in a lot of work adding a plugin API, and a number of other supporting services. Still in beta though :)

function method_one (){
    echo 'one ';

function method_two (){
    echo 'two ';

    event::on('event_trigger', 'method_one', 2);
    event::on('event_trigger', 'method_two', 1);


PHP Event Class

I wrote this class for http://tentaclecms.com, I tried a few others but they all had their shortcomings. Most notable was that I was unable to pass data from one event to the next. So this was my end result, and it works really well.

	define('APP_PATH', __DIR__.'/');

	function delete_dir($dir) { 
	   if (substr($dir, strlen($dir)-1, 1) != '/') 
	       $dir .= '/'; 

	   if ($handle = opendir($dir)) 
	       while ($obj = readdir($handle)) 
	           if ($obj != '.' && $obj != '..') 
	               if (is_dir($dir.$obj)) 
	                   if (!delete_dir($dir.$obj)) 
	                       return false; 
	               elseif (is_file($dir.$obj)) 
	                   if (!unlink($dir.$obj)) 
	                       return false; 


	       if (!@rmdir($dir)) 
	           return false; 
	       return true; 
	   return false; 

	function recursive_glob($pattern='*', $flags = 0, $path='')
	    $paths = glob($path.'*', GLOB_MARK|GLOB_ONLYDIR|GLOB_NOSORT);

	    $files = glob($path.$pattern, $flags);

		foreach ($paths as $path) { 
			$files=array_merge($files,recursive_glob($pattern, $flags, $path));

	    return $files;

	function string_to_parts($file) {

		$file_parts = explode('/', $file);

		$file_name = end($file_parts);

		$path_parts = array();
		foreach ($file_parts as $key => $value) {
			if ($file_name != $value) {
				$path_parts[] = $value;

		$file_path = '';
		foreach ($path_parts as $part) {
			$file_path .= $part.'/';

		$file_clean['path'] = $file_path;
		$file_clean['name'] = $file_name;
		$file_clean['full'] = $file_path.$file_name;

		return $file_clean;

	function array_clean($source)
	    foreach ($source as $key => $val) {
	        if ($val == '') {

	    return $source;

	// Path from Serpent API
	$client = curl_init('http://localhost/_lab/upgrade/source/update.zip');

	curl_setopt($client, CURLOPT_RETURNTRANSFER, 1);  //fixed this line

	$filedata = curl_exec($client);

	file_put_contents(APP_PATH.'update.zip', $filedata);

	if (file_exists(APP_PATH.'update.zip')) {
		echo '<p>File downloaded!</p>';

	$zip = new ZipArchive;

	if ($zip->open(APP_PATH.'update.zip') === TRUE) {

			$update_files = recursive_glob('*.*');

			echo '<ul class="list">';

			foreach ($update_files as $file) {
				$parts = string_to_parts($file);

				$update_file_path = APP_PATH.'update/'.$parts['full'];
				$site_folder_path = APP_PATH.'site/'.$parts['path'];
				$site_file_path = APP_PATH.'site/'.$parts['full'];

				if (!is_dir($site_folder_path)) {
					echo "<li><strong>Creating folder:</strong> ".$parts['path'].'</li>';
					mkdir( $site_folder_path );

				if (file_exists($site_file_path)) {
					echo "<li><strong>Updated:</strong> ".$parts['full']."</li>";
				} else {
					echo "<li><strong>Added:</strong> ".$parts['full']."</li>";

				$file = file_get_contents( $update_file_path );

				$fp = fopen( $site_file_path, 'w' );

				fwrite($fp, $file);

			echo '</ul>';

			# Clean up!

			echo '<p>Tentacle CMS was updated successfully!</p>';

	} else {
	    echo 'Something Went Wrong!';

PHP Upgrade script

Hey, I was working on http://tentaclecms.com and have also created an API to manage plugins, themes, and core releases. This API also has versioning abilities that hooks into a developers Github account. Along with this I needed a way of updating the core CMS when a new version comes out as well as allowing users the ability to add and update themes and plugins. SO I present to you a chunk of code ( experimental ) that will grab a ZIP, extract it to a temp directory, and copy/create files and folders as needed. It works perfect on my local computer but I have not tested it on a web server yet. If you try this script out please let me know if you have any issues and what environment you are running it in. Other than that, check out my CMS http://tentaclecms.com and let me know what you do with this code :) Cheers!


You asked for a Tentacle CMS Demo, well you got it!

Hey guys, I have had some really good feedback in the past, I had a number of requests for a demo of my CMS. This is a demo installation of Tentacle CMS, We are still in beta so please let us know if any issues you see. So here it is :) Login @ demo.tentaclecms.com/admin/ username: demo password: demo