I hear a lot of the Internet Marketing gurus brag about how they cannot even write their own landing pages. They argue that most (or all) of the technical stuff should be outsourced so you can spend time on marketing instead of hacking. There is no money in hacking, they proclaim. I see their point, and who am I to argue? After all, the number of “million dollar launches” that I have been involved in is exactly zero.

I do wonder sometimes how you know if outsourced technical jobs are being done correctly if you don't understand the underlying technology, but that is a subject for another blog post. This post is about code. And one thing you can say about internet marketing specifically, and the internet in general — there is a lot of code out there. Code makes things work, and the quality of code can make or break a project (or an application).

WordPress is a great example of a situation where coding quality is absolutely critical. Apart from the core engine, there are hundreds upon hundreds of plugins that depend on the quality of the core code. Those plugins, if improperly written, can crash other plugins or even crash WordPress itself. In addition to that, there are themes which are really just code. If your theme is not written well, it can break too.

Last week, I was working with an excellent WordPress theme developer on a new theme. We were doing all of our testing on a site that was recently upgraded to WordPress 2.5, and were using some stock WordPress 2.5 template files. During our testing we found that some of the stock WordPress 2.5 theme files did not run on a WordPress 2.3 install. Now this is understandable — after all, why would anybody expect something designed specifically for WordPress 2.3 to run in WordPress 2.5. (Note that he was doing all the work — I was just along for the ride).

As it happens, the theme test we were working on crashed in WordPress 2.3 because it depended on the new gravatars function called in comments.php. Gravatars is the cool function now native to WordPress 2.5 that puts the author's picture next to their comment. The code in the them looks like this:

echo get_avatar( $comment, 32 );

See the problem? The theme called get_avatar without checking the return status (if available) or at least whether or not the function existed. Luckily, php provides for situations like this. The “function_exists” function lets you test to make sure that a function is there before you call it. So, a better way to call a function like this is:

if( function_exists('get_avatar')) { echo get_avatar( $comment, 32 );

This tests to make sure that there is a function called get_avatar available to be called. It does not say anything about whether or not the call is successful. Now, you can reasonably make the argument that there is no need to test for get_avatar in a WordPress 2.5 theme since only a knuckle head would run WordPress 2.5 code under WordPress 2.3. I get that. But I also believe that it is always good practice to design code so that it is robust against unexpected circumstances.

Always use protection.

Regards,
Mark

P.S. The theme that I was working on is called SEOAdMax by Garry Conn. It is available for free.

TEST