Attachment Body Classes

There was an interesting bug reported for Twenty Twelve recently: The .single-attachment body class only gets applied when the attachment’s parent is a post (or custom post type). If the attachment’s parent happens to be a page, that class is missing.

In case you have been using .single-attachment to specify styles for the image attachment page, make sure to test your theme with images that have a page as a parent. And use the .attachment body class in the future. ;)

Developer plugin v1.1: Optimize Your Theme Development Environment

The amazing Code Wranglers at Automattic recently released version 1.1.1 of the Developer Plugin, which helps you optimize your WordPress development environment (plus saves you time) by making sure you have all of the essential development plugins installed. This new version targets the people who design and develop themes — you! Read on to learn more.

Continue reading

Introducing the Monster Widget

An important part of the theme development process is testing. As a member of the Theme Team at Automattic I can say that we like to test everything we can! One thing that we have observed is that widget testing can take up a lot of time. WordPress provides 13 widgets, many of which contain a form enabling us to customize each instance. Populating a sidebar with widgets can be rather time consuming especially if you have to tweak each widget’s settings.

Continue reading

Don’t let Lorem Ipsum decide the fonts used in your WordPress Themes

Have you checked the character map for the web font you use in your WordPress theme?

Thanks to all web fonts, nowadays we have much more choices for fonts in our WordPress themes. You might have checked if your theme looks good with Lorem Ipusum text but I’m afraid that’s not good enough. Lorem Ipusum text doesn’t have all digits, punctuations, and symbols from the Basic Latin character set. A WordPress theme should support at least all the Basic Latin characters, and this is only assuming your theme will be used for English language. This seems to be basic but often it’s overlooked. Continue reading

On Breaking and Fixing WordPress Themes at WordCamp Singapore 2011

My coworkers at Automattic and I frequently discuss the speed with which we’re able to onboard new themes into the WordPress.com theme directory.

Our top priority as the Theme Team is to make sure that all of our users feel like they have a theme that fits them perfectly; in order to meet that goal we’re focused on bringing a variety of themes into WordPress.com through a few primary channels: the WordPress.org theme directorypremium theme shops; and Automattic (in-house) themes.

It’s often the case that each conversion—that is, making a theme’s code WordPress.com-safe and ready—will take us anywhere between one week and one month, depending on the complexity and quality of the code. In a perfect world, though, we’d be able to snap our fingers and have every single awesome-looking theme available on WP.com right now.

Continue reading

Using TextMate for WordPress Code Cleanup

I spend a lot of time cleaning up WordPress themes. During the code cleanup I often perform certain cleanup tasks over and over, which makes them perfect for TextMate commands.

In this post I’ll show you how to add two useful commands to TextMate, then move through the steps I take for theme code cleanup and put the commands into practice.

First, let’s add the commands to a TextMate bundle. If you don’t know how to add commands to a TextMate bundle, or don’t have your own bundle set up yet, start here and add a new bundle. I usually add my own commands to a bundle called @lance so it sticks to the top of my bundle list.

Continue reading

Quick and Dirty Widget Testing

Testing widgets with your WordPress theme would be so much faster if you could enable all widgets at once, instead of dragging them one by one.

Here are two small functions to help with widget testing. The first takes all “Inactive Widgets” and adds them to the first registered sidebar in the theme. The second removes all widgets, leaving the widget area empty.

To use, add the code into your theme’s functions.php and uncomment the add_action() calls to trigger the functions. Happy testing!

<?php

/**
 * Quick and dirty inactive widget loading
 * Loads all inactive widgets into first registered sidebar
 *  
 * @global array $wp_registered_sidebars
 */

// To use: uncomment the add_filter call below, then refresh your admin Widgets page
// add_action( 'in_widget_form', 'enable_inactive_widgets' );

function enable_inactive_widgets() {

	// get first registered sidebar
	global $wp_registered_sidebars;
	$first_sidebar_id = array_shift( array_keys( $wp_registered_sidebars ) );

	// get widgets
	$widgets = get_option( 'sidebars_widgets' );

	// if inactive widgets exist, add them to the first sidebar
	if ( isset( $widgets['wp_inactive_widgets'] ) && '' != $widgets['wp_inactive_widgets'] ) {
		$inactive_widgets = array(
			$first_sidebar_id => $widgets['wp_inactive_widgets']
		);
		update_option( 'sidebars_widgets', $inactive_widgets );
	}
}

/**
 * Quick and dirty widget removal
 * This will remove both active and inactive widgets
 *  
 */

// To use: uncomment the add_action call below, then refresh your admin Widgets page
// add_action( 'in_widget_form', 'remove_all_widgets' );

function remove_all_widgets() {
	update_option( 'sidebars_widgets', null );
}

?>