The Conflicted Developer

As a developer I’m always struggling to balance the urge to learn new stuff and the need to be the best at the stuff I already know. I’m not sure you can be both, right? You’re either the guy (or gal) who knows everything about WordPress or Drupal or Ruby or whatever. Or you’re the guy who is flexible enough to work with all of them. So how do you know which one you are? And which one should you want to be?

I oscillate between the extremes daily. I’m starting to learn Kohana (the “swift” PHP framework). Of course, by the time I learn it there will be something else out there that needs to be learned. Chasing the dragon.

On the other hand I’m pretty comfortable working with Codeigniter for Custom PHP and WordPres for the quick stuff. Maybe I should just focus on being good at those before trying to learn new stuff.

What’s a developer to do?

 

WordPress Hack #3

Here’s a function that really should be in WordPress core by now. And maybe it is and I just can’t find it. But to get the source url for a post thumbnail you have to hack. Here it is:

/** 
**
** Parameters: 
** Size (optional): The width/height of the source image. Accepts either a string designating the WordPress image size, ( i.e. "thumbnail", "full","medium") or an array containing a custom size, i.e.  array(250,250) . Defaults to full size
**/
function get_post_thumbnail_url($size = 'full') {
global $post;
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), $size, false, '' );
echo $src[0];
}

Why WordPress?

I assume other developers often ponder this question. In a practical sense, the answer is “because it’s what you know”. But I’m pondering a bigger question. As a developer with a keen interest in PHP should I waste my time with WordPress? Can you ever get “respect” as a PHP developer when your tool of choice is WordPress?

WordPress is a dinosaur compared to most of the popular custom PHP frameworks. Frameworks like Codeigniter,Kohana and others are very light weight and scalable. They generally focus on concepts like OOP (object-oriented programming) and MVC (model-view-controller). Code reusability and encapsulation are priorities not luxuries.

WordPress is a vestige of  PHP before PHP had a robust object-oriented structure. As such it is mostly a collection of libraries of functions. Of course, with every new release these function are streamlined and improved. But ultimately WordPress is always going to be a procedural framework.

So if you’re interested in PHP why waste your time with a code base that will never be the vangard of PHP development?

Well, for one, just because WordPress core is less than impressive from a PHP point of view, does not mean that cutting edge approaches to coding are not implemented via plugins. Plugins are essentially little custom apps that tie into the WordPress API. But as such there are lots of plugins that exemplify flexible and cutting edge approaches to code development.

For instance, there’s a plugin out there the integrates Doctrine ORM with WordPress. Doctrine is a “Object-Relational-Mapping” interface that aims to cleanup how PHP interacts with Databases. Sure WordPress core doesn’t have a Database Abstraction layer, but if your interested you can use Doctrine in your plugins!

PodsCMS, one of my favorite plugins, is another one that pushes better code into WordPress. Pods is capable of managing massive complexity in WordPress content, but itself is a very light-weight, Object-Oriented framework. Moreover, PodsCMS, while not entirely MVC, at least separates code from markup which is a feature sorely lacking in WordPress core.

Other plugins, among them Shopp (an e-commerce plugin) and GravityForms, take very Object-Oriented approaches to coding. So just because there are limitations to WordPress core, does not mean developers passionate about PHP cannot excel and flourish. If anything, the lack of cutting edge PHP in WordPress creates a tremendous opportunity for hard core PHP developers.

But why? Why drive a station wagon when you could be driving a sport car? Well, because you have places to go and things to do … and people to take with you. The simple reality is that there’s a huge market for WordPress development. A bigger market than just about any other out-of-the-box CMS. And that means an opportunity develop good code for good projects.

So if you’re a WordPress developer and want to branch out into custom PHP, my advice is first, learn the WordPress way of doing things. Then forget the WordPress way of doing things. Experiment with custom frameworks and try to find ways to incorporate the innovations into the WordPress projects you’re working on.

And most importantly, don’t be afraid to NOT use WordPress for a project or two. Getting outside your comfort zone is what gets your  creative juices flowing.

Genesis Framework, Not Too Shabby

So, I’ve posted elsewhere that I’m not a huge fan of theme frameworks. The short version: I’m not sure we need anymore hooks and filters than WordPress Core already provides and my time is better spent learning those hooks than learning some trendy theme hooks that merely obscur or repackage those core WP hooks.

However, then I contradicted myself and went a redesigned my website using the Genesis Framework. So I feel obligated to explain. I chose the Genesis Framework because I like StudioPress. I first used a Brian Gardner theme back in 2008 when it was still “Revolution”. I’ve always found his code clean, efficient and easy to work with. Indeed, I found those traits reflected in Genesis as well.

Moreover, modifying Genesis was (for the most part) much more straight forward than other frameworks like Thesis. For instance, with Genesis you can still use custom template pages without putting all the code into a function. I’m old school so I like that. I also find the core Genesis libraries are intuitively organized so that if you want to know what hooks are involved in a particular piece of the header,  it’s relatively easy to find ‘/lib/structure/header.php’.

So, while in general, I still don’t dig on theme frameworks, Genesis is definitely a good one. Cheers, Brian.