Joining X-Team

Not long ago I was contacted by Dave Rosen, the CEO of X-Team, who had stumbled across my blog (this one). He was looking for a WordPress guru who could help wrangle up their many projects on the technical/development side of things.

After just three days of communicating back and forth (and one Skype call) he offered me a full-time position, and I wholeheartedly accepted! He flew me to Los Angeles a few days later to sync up with his top developers, Weston and Josh, who have been temporarily living here while working at FOX Broadcasting.

Needless to say, it’s been an outstanding experience working with these two. They’re not only top notch programmers but also great guys who are a blast to hang out with and have become good friends of mine. Since I’ve been here I’ve really enjoyed soaking up all the new information and techniques X-Team uses, specifically learning to incorporate version control with Git via command line into my workflow. I’m very happy to say I’m no longer Cowboy Coding! :)

My next big task (apart from client projects) is to bring a WordPress framework into fruition for X-Team that we’re calling: WPized. Weston Ruter has laid a ton of groundwork for the WPized framework already, so I’ll be taking a lot of what he’s started and simplifying it into a tool for creating themes rapidly. I’ll also be writing a lot of documentation for our other WP developers so they will know how to use the custom helper functions the framework will offer and all of this will hopefully make the process of theming much more unified within X-Team.

It’s an extreme privilege to be doing what I love for a company that boasts some very big clients, has a long history of doing extraordinary things and has a lot of fun doing it! I am very fortunate to not only be running my own theme shop but now also working with a superb international team on WordPress projects full-time…from home!

Create a dropdown of custom taxonomies in WordPress (the easy way)

So you’ve been busy taking advantage of custom post type functionalities in WordPress since mid 2010. And of course you’re using custom taxonomies too, right? Of course you are.

If you’re a theme or plugin developer you may have ran across the need to populate a dropdown list of your custom taxonomies. Essentially there are two different (easy) ways to accomplish this. One you always hear about and the other you don’t.

Method #1

Since WP 2.1 the wp_dropdown_categories function has been around but in WP 3.0 the taxonomy argument was introduced. So just calling this function and using the taxonomy argument is probably the absolute easiest way to populate a dropdown list of your custom taxonomies.

<?php wp_dropdown_categories('taxonomy=my_custom_taxonomy'); ?>

This method is great if you need the output of your dropdown values to be the category ID. Because this is the HTML that will be generated:

<select name="cat" class="postform">
	<option value="3">Tax A</option>
	<option value="14">Tax B</option>
	<option value="26">Tax C</option>
	<option value="29">Tax D</option>
</select>

However, let’s say you want your option value output to be the taxonomy’s slug instead of the ID. Well, that’s impossible to achieve using the wp_dropdown_categories function.

Peering into the WordPress core we see that this function is using a walker class called Walker_CategoryDropdown. This walker is designed to output only the ID as the value for each dropdown item. There is not an argument in the function to control value output.

Method #2

That’s where Method #2 comes in. We’ll have to write our own custom function that will generate the dropdown so we can output each option value as a slug:

<?php

function custom_taxonomy_dropdown($taxonomy) {
	$terms = get_terms($taxonomy);
	echo '<select name="'.$taxonomy.'" class="postform">';
	foreach ($terms as $term) {
		echo '<option value="'.$term->slug.'">'.$term->name.'</option>';
	}
	echo '</select>';
}

?>

So, now that we’ve got a cool custom function, we can call anywhere in our code like so:

<?php custom_taxonomy_dropdown('my_custom_taxonomy'); ?>

Expansions on Method #2

If you’re a coding rockstar you can take Method #2 even further by making room for more parameters. This will give you even more control and make it function more like wp_dropdown_categories does:

<?php

function custom_taxonomy_dropdown($taxonomy, $orderby, $order, $limit, $name, $show_option_all, $show_option_none) {
	$args = array(
		'orderby' => $orderby,
		'order' => $order,
		'number' => $limit
	);
	$terms = get_terms($taxonomy, $args);
	echo '<select name="'.$name.'" class="postform">';
	if($show_option_all) echo '<option value="0">'.$show_option_all.'</option>';
	if($show_option_none) echo '<option value="-1">'.$show_option_none.'</option>';
	foreach ($terms as $term) {
		echo '<option value="'.$term->slug.'">'.$term->name.'</option>';
	}
	echo '</select>';
}

?>

Then call it in your code like so:

<?php custom_taxonomy_dropdown('my_custom_taxonomy', 'date', 'DESC', '5', 'my_custom_taxonomy', 'Select All', 'Select None'); ?>

As you can see, WordPress has done a fabulous job of making room for you and I to do pretty much whatever we want.

To reference all available arguments and parameters, please see:
http://codex.wordpress.org/Function_Reference/wp_dropdown_categories
http://codex.wordpress.org/Function_Reference/get_terms

Was this code helpful to you? Let me know in the comments!

What’s the future of the WordPress iOS app?

I don’t launch the WordPress iOS application very often, and when I do it’s usually to do a quick typo fix on a post, page or comment. Sadly, there is no other reason to use it.

Once, I heard Matt Mullenweg mention in a podcast interview (can’t remember where, sorry) that he really wasn’t happy with the app and agreed there was still a lot to be done. I’m always glad to see Matt pushing for more and it makes me very optimistic about the app’s future.

I don’t intend for this post to be a rant, I just believe that in order for the app to have a successful future, it should be supporting what WordPress is already known for. Otherwise, Tumblr, Posterous and a slew of other platforms who are thinking more “mobile” could gain a significant portion of the WordPress market share.

It seems to me that there are five major components of WordPress that just aren’t supported by the app yet.

1. Custom Post Types
This is a big one. WordPress introduced them in June 2010 with version 3.0 and we still don’t have them supported in the iOS app. This is probably the biggest upset of the five since it has been around for over a year and involves the very core of WordPress: Writing posts.

2. Widgets
Seriously? Yes, seriously. Currently, there is no way to add, modify or remove widgets from your WordPress site using the iOS app. Some may disagree that this belongs on my list, but I think it’s deserving. Widgets were introduced in version 2.2 and are one of the core things that makes WordPress unique and attractive. The mobile app should reflect WordPress’s existing core strengths to differentiate itself from other mobile players.

3. Post Formats
Post formats were introduced in version 3.1 and I think it was an excellent addition. It took the Custom Post Types functionality from version 3.0 and expanded it even further. We even saw the birth of “Tumblogs”, or WordPress themes that function like Tumblr sites, all because of Post Formats. Hell, I can’t even use the default Twentyeleven theme effectively on iOS because support for Post Formats is still missing. This would be a huge improvement.

4. Custom Fields (Post Meta)
Some plugins and advanced themes take advantage of Custom Fields on WordPress posts and pages. Although not always crucial, this is another capability that already makes WordPress unique and is part of core functionality so I believe it should be a part of the mobile strategy.

5. Theme Options
Almost every theme these days has a variety of Theme Options. And I’m not just talking about the “Theme Options” item under the Appearance menu, but also Header, Background, Sidebars and any other options page available for a particular theme. Why is this last on my list? Because Theme Options aren’t exactly critical for delivering content, which is what mobile is really all about: creating and publishing content quickly while on-the-go.

Jump on over to the WordPress iOS App Forum to join the conversation or be part of the solution.

Remove specific admin menu items in WordPress

Of course I love running the daily grind over at ChurchThemes, but every once in a (great) while I do take on a side project for a friend. And each time, I’m reminded how truly different doing client work is from being a theme publisher.

Sometimes it’s best – especially when you’re using WordPress as a CMS – to remove those unwanted admin menus that create clutter for clients. They are never going to use them so why confuse their admin experience? For example: if the client isn’t going to blog, why include the Posts and Comments menus?

Just insert this code into the functions.php file of your WordPress theme and *bam!* no more clutter.

(Make sure to remove the items in the $hidden array you don’t want to hide, this is just an example so you can see what’s possible) Enjoy!

// Remove Specific Admin Menu Items
function remove_menu_items() {
	global $menu;
	$hidden = array(
		__('Posts'),
		__('Media'),
		__('Links'),
		__('Pages'),
		__('Comments'),
		__('Plugins'),
		__('Users'),
		__('Tools')
	);
	end ($menu);
	while (prev($menu)) {
		$value = explode(' ', $menu[key($menu)][0]);
		if(in_array($value[0] != NULL?$value[0]:"", $hidden)){
			unset($menu[key($menu)]);
		}
	}
}
add_action('admin_menu', 'remove_menu_items');