WordPress Admin Screenshots

Theme Development Enhancements In WordPress 3.8

Some news on recent changes for WordPress 3.8 that make theme development even easier:

Post Formats

From 3.8 onwards, theme developers will be able to check if a post has any post format associated by checking has_post_format() without passing an argument:

// Does the post have any format assigned to it?
has_post_format();

// Does the post have this specific format assigned to it?
has_post_format( 'aside' );

// Does the post have any of these formats assigned to it?
has_post_format( array( 'aside', 'image', ) );

Background Images

Additionally, it is now possible to be more specific about a theme’s custom background support. You can now specify default-repeat, default-position-x, and default-attachment arguments for background images. This is the full array of defaults when registering theme support now:

$defaults = array(
    'default-image'          => '',
    'default-repeat'         => 'repeat',
    'default-position-x'     => 'left',
    'default-attachment'     => 'scroll',
    'default-color'          => '',
    'wp-head-callback'       => '_custom_background_cb',
    'admin-head-callback'    => '',
    'admin-preview-callback' => '',
);

Miscellaneous

  • With the improved theme experience in the Appearance menu, WordPress can accommodate for even bigger screenshot sizes of your theme, the new standard size is now 880x660px!
  • If you have themes in the WordPress.org repository or plan to release a theme there (you should!), these three tags will be available to classify your theme appropriately: responsive-layout, fluid-layout, fixed-layout.
    They replace fluid-width and fixed-width, to make the terms broader and match web design terminology better. You can also classify your theme as accessibility-ready – if it is.

Why Hard Working Classes Slack in WordPress

Nathan Ford wrote a great article about how you can use the attribute selector to define styles for a multitude of classes that share a common element. Initially I thought this was great (I actually still think this is a great idea), and used it in _s and Twenty Thirteen to simplify the clearfix selector and some others. We used [class*="site"] and [class*="content"], to grab all classes that contained those two words, essentially addressing our entire page structure with two selectors. Awesome, right?

Well, it turns out there are a few issues with this approach. After a while we received a report that Modernizr uses a generatedcontent class on the html element, screwing with the rest of the site because the styles for the [class*="content"] selector were applied. We also received reports from WordPress.com, where users specified tags, categories, or post titles that contained one of our two words. Since WordPress adds all categories and tags as classes in post_class(), this, again, broke the site’s layout.

I still think this a valid approach in projects where you can control the class namespace. Since you can’t really do that in WordPress, it’s not a good approach for theme developers.