Web Craftsman, WordPress hacker and Entrepreneur based in Atlanta, Ga.

Smarter hooks

Now that everyone’s finally understanding the benefits of using theme frameworks and the like, I’m noticing a lot more hooks in themes:

theme_before_location();
theme_location();
theme_after_location();

Where location is the location of that particular hook (e.g. header, footer, loop). Now that’s great and all, but here’s a smarter way:

do_atomic( 'location' );

Where do_atomic is:

// Registers three action hooks at once.
function do_atomic( $location = '' ) {
	if ( !isset($location) ) return;

	do_action( "theme_before_{$location}" );
	do_action( "theme_{$location}" );
	do_action( "theme_after_{$location}" );
}

Makes for much cleaner template files. The next article on smarter hooks will take this concept to an even higher level.

On using WordPress Theme Frameworks

In my last post, Kel from BadCat design brought up a very important question about theme frameworks that needs to be discussed:

On the same path… If you have a child theme (I’ll use Ian Stewart’s pro/paid Thematic child theme called Power Blog, as the example) and want to customize that – what do you do? Currently we’re talking about customizing themes by using Child Themes. If I wanted to make mods to Power Blog, I’d have to change the child theme directly, thus negating some of the reasons for using a Child theme – like upgradability.

Do we get to a day where we need grandchildren themes? I think your code might be the start of a way to “group” the family theme files together. -Kel

The day WordPress starts talking about “grandchild” themes is the same day I’ll convert all my blogs over to movable type Habari.

Way back when I started talking about theme frameworks, I talked about how WP Framework stands out:

One of the main design goals I wanted to achieve with WP Framework that differentiates it from other frameworks is the fact that it’s not styled.

A WordPress theme framework should be design-agnostic. That’s why it’s a framework. It should only contain the building blocks and the most essential code (by the way, WP Framework 0.2.4 has just be released!).

Carrington gets it. Alex King built a base framework of carrington, basically extracted all the template logic and things that made his theme work into a “core” framework. When he builds themes off of carrington, he simply extends the core framework by building on top of it; not via a child theme.

So if users of Carrington blog wanted to customize it, they would create a child theme for it and modify it accordingly. Here’s two possible scenario’s that show the benefits of what I’m describing:

  • Carrington blog gets an update that includes a new section above the sidebar (a feature dealing with the design, not the logic). Users would simply download/update Carrington blog and the new section would appear above the sidebar as expected. All of the user’s changes for Carrington is preserved and left intact via the child theme.
  • But let’s say Carrington framework fixes a bug in it’s atomic template system (an issue dealing with the framework logic, not the design). There would be an update available to all themes based on carrington, and users would simply download/update carrington blog (or which ever theme based on Carrington they have) and the fix gets applied. The user’s modifications to Carrington blog are left intact via the child theme.

It’s important to think of a theme framework as the logic of the theme, not the design or the underlying xHTML.

To put this into a step by step process:

  1. Start with a blank WordPress theme framework
  2. Create your WordPress theme based off said framework
  3. Now to customize this WordPress theme (which is essentially the first two steps combined), create a child theme for it.

That’s how WordPress theme frameworks should work. In Kel’s case, Thematic already consist of the first two steps described above when it should only be the first one. So now that she’s using the Thematic Power Blog, she won’t be able to customize her theme using a child theme because it’s already one.

Does your theme have children?

When working with WordPress theme frameworks or any parent theme, sometimes you might want to figure out whether a child theme is active or not. Here’s a quick function that’ll do exactly that:

function has_kids() {
	if (STYLESHEETPATH !== TEMPLATEPATH) return true;
	return false;
}

if ( has_kids() ) {
	// do stuff
}

This function works whether you call it from a child theme or parent.

Roll Your Own.gs

So I’m working on this top secret (shesh!) app for WP Framework. And during that process, I had to create my own custom CSS Framework.

Unlike all the other CSS Frameworks out there, this framework allows you to define your own columns, widths, and gutters (margins). Thus, rollyourown.gs was born.

It’s simple, and it works. Once I get enough time for it, I’ll give it a proper face and add some more features to it. Until then, have fun with it.

Page Specific Loading

Vladimir Prelovac just posted some neat tips for plugin developers over on mashable. Here’s one that I really think needs more attention:

#8
WordPress plugins can sometimes be a real resource hog. To make sure your plugin isn’t, you need to localize the usage of resources, by loading them only when you need them.

You can use the following example to execute certain code (like declare additional actions and filters) only when WordPress is loading plugins.php page (list of installed plugins in the backend):

$local_pages=array(’plugins.php’); // define pages we want the plugin to be activated on

if (in_array($pagenow, $local_pages))
{
// do stuff here
}

Similar to this, you should pay attention to load JavaScript files only when you need them.

All too often I find plugins, like contact forms being loaded on every single page. It’s not that hard to figure out where the user likes to put their contact form, or whatever your plugin does. And while these tips were geared for plugin developers, theme authors should take this advice too as theming becomes more advance and not just an new stylesheet addition.

I’m looking forward to hearing more things like this on the next WP Weekly episode where Jeff interviews him.

The Beginning.

If you didn’t already know, I started my first company, Design by Craftsmen earlier this year. Since February, I’ve been working at DBC full-time and I have to say, there’s been some highs and there’s been some lows but overall, it’s been phenomenal!

Before I get ahead of myself, I’m pretty sure you’re wondering what exactly is Design by Craftsmen? Well in a nutshell, DBC is a web creative studio specializing in custom WordPress solutions. I examine the way a company currently does business and use the Web to make their work flow and process more innovative, intuitive and efficient, using the power of WordPress and WP Framework.

Currently, Design by Craftsmen has been working with entrepreneurs, startups and small businesses locally and several nationally, but once the website is up, the target audience will expand internationally. More on the DBC website in another post perhaps.

One of the goals I’ve been working on for DBC is improving my work flow on dealing with clients. Here’s a typical workflow outlining the process involved for creating a website:

  1. Client needs website
  2. DBC sends them a questionnaire document so they can get their ideas onto paper
  3. Either 1) Client fills out questionnaire and sends it back or 2) We have a meeting and fill it out for them (still debating on this route)
  4. Either 1) DBC evaluates the questionnaire to see if we can deliver a solution for them or 2) If not, we’ll see if we can forward them to one of our partners.
  5. If we can provide the client a solution, DBC sends the client a creative brief document containing all the project details.
  6. If client agrees to pursue this project with us, they’ll sign off on the creative brief + a TOS document. DBC will then invoice the client the initial deposit in order to start the work.
  7. Once that’s completed, the client will gain access to DBC’s project management app to collaborate, and see the development throughout the life cycle for that particular project.
  8. DBC then starts working on the first deliverables of the project.
  9. This part varies depending on the type of project. But overall, we’ll be communicating back and forth showing revisions etc.
  10. Once half the deliverables have been completed (this milestone will be known to the client), DBC will invoice the client before the second phase starts.
  11. Step 8 through 9 will repeat but for the second phase of the project. And so forth.
  12. Once DBC is completed with the final phase and the client approves of the work, DBC sends them the last invoice and the deliverables  are given to the client.
  13. The project is completed.
  14. Follow up

Now that’s just a rough overview of our workflow. Things will changed depending on the type of project/client/situation but it’s a solid workflow that I’ve been perfecting over the years and it has a pretty high success rate. Working like this also ties well into the agile workflow which is something I’ve been growing into.

As you can see, there are about three documents that DBC has going into each project.

  1. Questionnaire
    The purpose of this document is to get all their project details onto paper so we can figure out what their looking for and evaluate if that’s something we do. If so, we’ll figure out how it’s going to work along with an estimate quote (the Creative Brief doc). If we can’t do it, we’ll send them to one of our partners if they can best fill the roll.
  2. Creative Brief
    This document outlines all the deliverables for the project, project goals and itemizes our services so they know what their paying for. The creative brief is sort of the reference, goto document that DBC or the client can refer to if something’s not clear, or if things get a little blurry down the line.
  3. Terms of Service
    Finally, the TOS. This document simply contains all the legal jargon to project DBC’s assets, if you know what I mean. That’s all really.

Financing

As you saw throughout the client to DBC workflow, we allow the client to make payments overtime. For the most part, it’s typically a three step: 50%, 25%, 25% payment. I’ve found that this works best for both parties.

Services

So in terms of services, here are some of the standard services we provide:

  • Design to HTML conversion
  • Design or HTML to WordPress
  • Custom WordPress Theme development
  • Custom WordPress Plugin development
  • Basic small website (static)
  • Large website (not the proper name, but this is what the client needs 40% of the time)
  • Website redesign
  • Small custom web application
  • E-Commerce website

That’s roughly what we do. Other services like logo design, copywriting, hosting and site maintenance are also what DBC provides, but are already included in some packages. Part of the initial work I had to done last month was to figure out all of the base prices for these services. That process involved creating a sample project 3 times for each service, and timing myself to get a good estimate on how long it takes.

Partners

If you were reading carefully, I keep referring to DBC as  “we” and “our” throughout this post. That’s because I’ve partnered with two amazingly talented folks, Maricio Bowers, a web designer here in Atlanta and Evan Denbaum, an amazing copywriter based in California. So that makes DBC 3 strong. I’m looking to build this team to include another web designer. So if your a designer looking for work, contact me asap!

Partnering with DBC simply means that we’ll be able to list the services you provide (e.g. web design if your a web designer) through us. DBC will contract that type of work through to you when needed. And as an incentive you’ll be entitled to a nifty 20% discount on any of the services DBC provides if you’d like to use us. I think that’s a sweet deal.

Business Models

Apart from the services DBC already currently provides, I’ve been brainstorming a few ways we could create passive incomes to fill in the gaps when we aren’t doing client work. I’m still working out some technicalities, but we’ll be pushing something out in the coming months.

Working hours

I’ve decided that working hours are 9-5, Monday through Thursday, and 9-12 on Fridays. I wanted to try out the 4 day work week model, but that just isn’t realistic for my situation. So Fridays I’ll work just in the morning, and I’m off the rest of the day. Now the only thing I need to do is follow through with this! I tend to work around 56 hours a week on average. They say it takes about a month to develop a new habit, so hopefully I’ll have this work-life balance back on track pretty soon.

Overall, that’s where I’m at with DBC. Getting the DesignbyCraftsmen.com website up and online is one of my top priorities right now. But before hand, I need to fill it with some quality portfolio pieces. I’ve got around 4 or so in the works so things are trucking along.

I’m pleased to announce the new release of WP Framework 0.3

I just released the latest version of WP Framework today. This release was essential for laying the groundwork for future features and innovations to come. And now that WP Framework is somewhat mature enough, I plan on dedicating more of my time towards actually building WordPress themes on top of the framework. They should serve as a way to learn how to best take advantage of the framework and show you best practices.

Droppin’ knowledge on WordPress: How to preset widgets to widget areas

I thought this would be the perfect time to introduce a new type of post I’ll be writing here at ptahd.com. Droppin’ knowledge on WordPress. Tips, tricks and lessons learned using WordPress. Everyone needs knowledge dropped on them about WordPress. Here, I’ll break it down so everybody’s in the loop!

So, how do you preset widgets to widget areas? In other words, how can you automatically assign widgets to a certain widget area (e.g. a sidebar).

I asked myself this seemingly impossible question on twitter a while ago. It was raised again by Justin so I thought I might take a stab at it. Turns out, it’s not that hard. Here’s what I came up with:

<?php
// Debug: Makes sure no widgets are registered already. If so, be gone.
//update_option( 'sidebars_widgets', NULL );

$current_theme = get_option( 'template' ); // variable stores the current theme
$target_theme = 'wpframework'; // variable stores the theme we want to target
$debug = false; // skip the ladie, da.

/**
 * $preset_widgets:
 * A two-dimensional array that stores all active sidebars and their active widgets
 *
 * Qiktip: Sidebars and widgets are identified by their unique ID
 */
$preset_widgets = array ( 'sidebar-1'  => array( 'search', 'pages' ) );

// this checks to see if the user is trying to change themes, if so,
// compare that theme with our target theme.
if ( isset( $_GET['activated'] ) && $current_theme == $target_theme || $debug ) {
	update_option( 'sidebars_widgets', $preset_widgets );
}

// Debug: What widgets/widget areas are active?
// Uncomment the next line and find out for yourself buddy ;P
//var_dump( get_option( 'sidebars_widgets' ) );
?>

The code is hopefully self explanatory. Copy and paste this into your theme’s functions.php or get the plugin version. From there, all you have to do is update two variables:

  1. $target_theme = your targeted theme based on it’s file name.
  2. $preset_widgets = a two-dimensional array containing the sidebar id(s) and their respective widgets (based on their id(s))

That’s it. Just make sure you have those widget areas defined in your theme, or you won’t see it (of course). Finally, use this wisely. It’s bad practice taking any kind of action the user didn’t directly initate.

About Ptah

I’m a 21 year old web developer, entrepreneur, and founder of Design by Craftsmen, web creative studio specializing in custom WordPress solutions. Get to know me.

Twitter