WordPress: Adding Some Class to Meta Boxes

For WordPress plugin developers, the metabox API generally proves to be invaluable. Meta boxes allow you to organize various bits of information, groups of options and more into nice, attractive, collapsible boxes rather easily. What’s more, these boxes can be dragged around the screen and reorganized without much hassle. However, one thing that you can’t do with meta boxes is to assign additional CSS classes to them.

However, in WordPress 3.2, you will be able to do just that. WordPress 3.2 will introduce a brand new filter that allows you to modify the list of classes that are applied to a meta box. In order to use it, you’ll need to know the slug of the page on which the meta box is being displayed and the ID of the meta box.

Adding a Bit of Workflow to WordPress

As much as I love WordPress, one of the areas it really lacks is workflow. There are three basic statuses for posts (draft, pending review and published), but there’s very little difference between “draft” status and “pending review.” When a post is saved as “Pending for review”, nothing happens automatically. No email messages are dispatched to any of the site’s editors or administrators, no special, obvious flags fly within the admin area, etc. It might as well just be a “draft” for all intents and purposes. The idea behind creating the “pending review” status was to allow editors and administrators to tell the difference between an in-progress draft and a draft that was ready to be published, but that seems to be about it.

Adding Settings Fields to Your WordPress Plugin

When developing a plugin for WordPress, a lot of times you’ll want to create your own page of options within the administration area. To do so, you’ll usually use the add_options_page() or add_submenu_page() function to actually create the page; but then you’ll have to populate that page with the actual settings fields.

The first step in that process is to understand the add_settings_field() function. This function accepts 6 different parameters. They are as follows:

Using jQuery in your WordPress plugins

This evening on Twitter, @viper007Bond posted a quick tip about using jQuery in your WordPress plugins (also applicable to themes). His initial tweet was:

Using jQuery in your WordPress plugin? Make sure you’re using quotes in your selector strings! http://api.jquery.com/category/selectors/

Then, @dimensionmedia, @viper007Bond and I had the following brief conversation:

WordPress: Hooking Into The Upload Action

While WordPress implements a really nice asynchronous upload function, it doesn’t really offer any simple way to manipulate the files before they’re actually stored in your uploads folder.┬áThere are multiple filters you can hook into after the file’s been uploaded and processed; but there aren’t any filters available to do anything with the file beforehand.

WordPress: Optional Widget Areas

When developing a new WordPress theme, sometimes you might need to create optional widget areas within the template; that is, areas that can include widgets if the user wants, but don’t appear at all if the user has not added any widgets to that particular area.

For instance, some users of your theme might want to include a tag cloud above the footer; or maybe they want to include Google AdSense ads above the content. Other users of your theme might not want anything to appear in those areas, though.

So how do you create an optional widget area in a WordPress theme? The simple answer is, you use the is_active_sidebar() function.

Pages: