Tips on Picking a WordPress Plugin

WordPress.org Plugins

On many of my long term projects my clients are heavily involved in the development cycles. We mark everything that’s not in the current cycle as a ‘future feature’ and collect information on it as we work out the items that are currently marked as features.

Often, as we look at a particular piece of functionality, we find that it is covered, at least in part, by a plugin. Unfortunately while the WordPress Plugin eco-system has a lot of good plugins there are also lots that have been abandoned or are of low quality. But how does someone new to WordPress determine the quality of a plugin?

The Short List

When determining the quality of a plugin here are the first three things I look at to see if the plugin deserves a deeper look.

  1. Current Version Compatibility

    When looking for a plugin the first thing to check is that it is listed as compatible with the current version of WordPress (you are running the current version right?). Unless a new version of WordPress has just been released (like in the last week or two) any plugin you are looking at using should list compatibility with the current version of WordPress. It’s a pretty sure sign that it’s been abandoned if you don’t see any updates. It may still work but if the developer couldn’t take the time to tag the version the plugin isn’t really high on their priority list and we don’t want to get involved with plugins that could break and not get updated.

  2. Forum Posts

    If the plugin is listed as compatible with the current version of WordPress the next place to look is the posts in the WordPress.org forums that deal with the plugin. Are people posting about issues with the plugin? If there are lots of people with plugin issues then it might be a good idea to look elsewhere. There is a caveat here though, the more popular a plugin is the more posts you’ll see with issues. Many users will only scan the documentation in the plugin and can often miss easy but critical steps with a plugin. Weigh any issues listed with your own intuition. If the poster sounds like a whiner and is demanding response it’s likely that they don’t really know what they’re doing and the plugin may work entirely fine. On the other hand if there are lots of issues with the plugin and lots of “me too” posts it’s probably a good idea to walk away.

  3. Developer Response

    Coupled with checking the forum for issues is looking at the developer response to issues. Do they respond? If you see no response to forum posts also check the documentation of the plugin. It is possible that the developer has setup their own forum and only responds to issues submitted there. If you’re working fulltime and providing a plugin for free you’re doing everything you can to streamline your workflow and only checking one place for issues is a good way to do that.

So if you’re looking for a plugin check out those things before you commit to it. Sure if you can read code go ahead and read through the plugin looking for WordPress coding standards. A plugin that follows best practice as outlined by WordPress is most likely of higher quality. I’ve found that many plugins fail on one of the three items above pretty quick. If the function of the plugin is a ‘have to have’ then I might use it anyway but I make sure I read through the code and know what we’re getting in to.

Contribute to Documentation Even if It’s Not Sexy

We should all contribute to open source projects. If you’re building websites you’re using something open source and it just seems right that we should give something back.

The real sexy thing to so when contributing to open source is committing code. For every open source project that’s out there I’m sure you can find lots of developers that committed two lines and if you go look at their sites you’ll find a line saying that they contributed to WordPress, or Ruby, or Rails or whatever it is they work with.

It’s sexy (if a bit self serving) to say you’ve added code to a project.

The real hole in most projects that needs developers and users to work on is documentation. For all the smart people doing the sexy work there are very few of those people that actually work on the documentation. If you write a line of code how about you add to the documentation on that line of code instead of calling your job done. There are lots of people that are working to learn WordPress, Rails, whatever that need solid documentation to work with.

Yeah I know that you’re adding code but that’s only half the job, the sexy part. Do the whole job.

Including code in WordPress Child Themes

Codex Child Theme Page

A project of even moderate size easily builds up quite a few items in it’s functions.php file. Even when working on a child theme I find that it’s not uncommon to need to add a custom admin panel or a custom post type. There is another gotcha in child themes though.

Typical code samples that talk about organizing files for WordPress will show you something like this.

[php]
require_once( TEMPLATEPATH . ‘/path/to/file.php’ );
[/php]

That works perfectly fine for a regular WordPress them but in a child them it’s pointing at the parent theme. To fix/get around this all you need it a simple modification of which constant you use to:

[php]
require_once( STYLESHEETPATH . ‘/path/to/file.php’ );
[/php]

This is not the first time I’ve written about an include gotcha with Child Themes in WordPress so go read the other article if this isn’t quite what you’re looking for.

WordPress StackExchange Question of the Week – Oct 17 – 23

This week we’ll highlight a StackExchange question dealing with corrupted databases. The question asker has corrupt tables, specifically term tables, that are causing incorrect data to be displayed. Basically he lost all his tags. Our answer comes from Denis and deals with repairing tables. Hit the link below for a full explanation on repairing broken tables in WordPress.

http://wordpress.stackexchange.com/questions/3160/corrupt-wordpress-database

Make Blogging Easy with MarsEdit

Let’s face it many of us plan to blog way more than we do, at the very least it applies to me and this blog (well me and all the blogs I have). The original plan was to have something out each Tuesday but life, stuff, StarCraft II, seem to get the way. Since I started using MarsEdit I’ve been doing a bit better and I figured I’d review the software and tell you why it’s helping me.

The Why

As I said in my previous run down of my OSX Setup, I used to write all my blog posts in TextMate. At the time TextMate was simple and I already owned a copy it. I typically write my blog posts in HTML anyway so why would I need some other fancy blogging client?

So if TextMate was the cats ass why did I switch to a blogging specific software? I often found that with TextMate I’d start thinking about some of my development work and then start getting distracted by coding, when I should be blogging. Also since I never found the blogging bundles and set them up I always had to do a bunch of cut/paste to get the article onto the site.

Along Came MarsEdit

Then I found/remembered MarsEdit and figured I’d give it a try.

The Good

One of the features I love about MarsEdit is that it lets you pick if you write in HTML mode or WYSIWYG mode. I write HTML all day so I don’t have any trouble reading or writing it. I’m also picky about what my code looks like (I am a programmer) so having direct control over it is awesome.

When I’m doing the final read of a post I do like to just read it as the user would see the text. MarsEdit has an beautiful preview window. No clutter just your text black on a white background. It makes reading easy.

MarsEdit Preview Window
MarsEdit Preview Window

My fulltime job is to design and build WordPress sites so of course I run my blogs on WP and have to have a desktop editor that works with both WordPress and WordPress Multisite. MarsEdit does both with no extra configuration needed for Multisite installs. I’ll admit I’ve only tried it on domain mapped Multsite, so let me know if it’s any different for installs that are sub-directory or sub-domain.

MarsEdit lets you edit not only local documents but also the post and pages on your live site. It even saves them in the local draft on edit so you can make some changes on a few pages then publish them all at once (or nearly at once since it’s one after the other as fast as you can click). It did take me some time to find the menu item for creating a new page (seriously why isn’t it an option when you create a new post to just make it a page instead?) but it’s there down at the bottom of the main MarsEdit window. Yup that tiny plus is where you can add a page.

Room for Improvement

Like I said above I’m a WordPress based blogger and while I know that not every blog is powered by WordPress but if your blog is powered by something else your wrong. Seriously I’d love to see MarsEdit add support for featured images in WordPress. It’s been around for a few versions and it would be nice to see.

Probably one of the biggest things that annoys me about MarsEdit is the fact that you can’t eliminate local drafts by blog title. Like many people I have a few blogs kicking around and I write down ideas for posts in MarsEdit. Well all local drafts just go into one pane sure you can enable a new column with the blog title in it but I’d love to see folders under local drafts that represent each of your blogs. Lets just get some of the distraction of lots of drafts out of the way.

MarsEdit Post Drafts
MarsEdit Post Drafts

Yeah this is totally a bit whiny but isn’t doing a bit of public whining what blogging is really all about? MarsEdit imports all your categories (and lets you add new ones) from WordPress but it doesn’t have any knowledge of hierarchy. All categories are displayed as top level categories and when you add a new one you can’t designate it as a child category of anything. The fact that they are displayed as top level categories has no effect on how WordPress actually works though so just remember which ones are really children and you’re good to go.

Update: Check out the comments where Daniel fixes one of the minor issues I had with MarsEdit. Two last things that bug me just a bit are the fact that I can’t figure out how to set the defaults so that any new post is a draft and that trackbacks are off by default. Since I can’t set a featured image (or schedule publish date) I post the content as a draft then finish off those last two items. Unfortunately I need to remember to set the post status to ‘draft’ for each new post.

That’s It

Sure there are a few minor things in MarsEdit that bug me but overall switching over to a dedicated blogging application has helped me focus when writing so I’ve got way more writing done. It’s not perfect but it’s dang close. Update I seriously can’t say enough about the support provided by Red Sweater. See the comments for Daniel helping me with one of the minor issues I had with MarsEdit but also check out their forums and see how fast and quick Daniel is when answering questions from his users. This is what a software developer should be like.

WordPress Multisite Domain Mapping with Media Temple

While there are lots of tutorials out there that teach you how to setup domain mapping on your WordPress Multisite install there really aren’t any that deal with a particular issue (let’s call it ‘feature’) on Media Temples servers. It’s not really a bug and I’m sure some Unix guy out there can tell my why it’s the right way to do things from a Sys Admin point of view.

Ultimately if you want to setup domain mapping and you’re using a Media Temple GS (it may work on other but I’m on a GS when I write this) go ahead and follow this tutorial from Otto, or buy this plugin and get the ebook.

What neither of them cover is the specifics of setting up your parked domain on Media Temple. Media Temple has a slightly different control panel and it really doesn’t let you park a domain. Once you’ve completed either of the tutorials above or when it tells you to park the domain you’ll need to:

  1. Setup the domain you want to map as you would any other domain on Media Temple through the control panel
  2. SSH into your server and go to ~/domains/. Once there remove the domain you just setup rm -rf yourmappeddomain.ca. Now setup a symlink like ln -s youmaindomain.ca yourmappeddomain.ca.

I found that once I made the symlink I had to wait a few minutes (30 seconds really) for everything to sort itself out on the server.

Here’s the Media Temple article that covers the symlink topic if I wasn’t clear enough.

WordPress Admin Bar – A Wicked WordPress Plugin

I just finished installing a WordPress Mutlisite system and mapping a bunch of domains so I could consolidate a few sites I keep up to date for friends/family that have businesses and needed a quick web presence. While the consolidation and mapping will save me a ton of time (don’t have to update every site anymore).

I was thinking that I’m pretty much running my own version of WordPress.com now but I’m missing one pretty dang sweet feature, that admin bar.

For those unfamiliar with WordPress.com, it provides an admin toolbar across the top of any WordPress.com site (if you’re logged in) that gives you links back to your own site, admin, stuff. It links from both the front and backend of the site.

So to finish off my setup I installed WordPress Admin Bar. The only real draw back I found was that I have to configure it on each site. Really you just have to set it to display while on the admin screens but it would have been nice to skip that step.

Go check it out.

Adding Scripts – WordPress Child Theme Gotcha

While converting a heavily customized premium theme into a proper WordPress child theme I came across a gotcha in WordPress.

If you look at the WordPress Codex information on adding scripts to your theme all of the code samples tell you to find the script by using get_bloginfo('template_directory');

Unfortunately if you’re dealing with a child theme this returns the location of the parent them not the location of the child theme. That means that your file is returning a 404 (it’s not being found).

Again, unfortunately the WordPress Child theme information does not include a remedy for this so after a bit of typing (calling print_r on variations of bloginfo();) I found that bloginfo('stylesheet_url'); returns the location of your child theme properly.

So the code to include your custom JS script would look like:

[php]
wp_register_script(‘custom_script’, get_bloginfo(‘stylesheet_url’).’/path/to/custom.js’, array(‘name_of_script_dependencies’), ‘1.0’);
[/php]

Having Fun with the WordPress post_class()

While I know that the WordPress post_class(); has been around since WordPress 2.7 I recently just stumbled upon it for some recent projects.

Unfortunately, while post_class(); gave me a ton of function that I needed, I still needed to extend it just a bit to suit the project specific needs.

What is post_class();

Stealing directly from the Codex

The post_class(); may include one or more of the following values for the class attribute, dependant on the pageview:

  1. .post-id -> The specific post-id for each post
  2. .post -> The specific post type. A custom post type of show would be .show
  3. .attachment -> on attachment template files
  4. .sticky -> If the post is marked as a sticky post
  5. .hentry -> (hAtom microformat pages)
  6. .category-ID -> The ID of any category on the post
  7. .category-name -> The category-nicename
  8. .tag-name -> The tag-nicename

Basic implementation:

So instead of wrapping your posts in a div with the class of post you should be using code like this:

[php]
<div id="post-” >
[/php]

The actual HTML may look something like this for a post in the “dancing” category:

[html]

[/html]

It’s also worth noting that if you’ve already defined a class in plain HTML then post_class(); won’t work. Any extra classes will need to be added to the post_class(); itself.

Beyond the Codex

So now that I’ve repeated the Codex information on post_class(); how about I add something new to the mix. All of these samples would go in your functions.php file.

First things we’ll do is add an alternating odd/even class to our posts so that we can alternate highlighting.

[php]

[/php]

Now let’s break down the code. First we add_filter to the post_class and we do that by calling a function (notice it’s name spaced you should always do that to minimize conflicts).

Next we establish a global variable of $current_class and set it’s value to odd.

Now we start our function that will accomplish the odd/even switching. We set $classes equal to $current_class then toggle $current_class from odd to even.

Finally we need to return $classes to make sure that we have something to send to post_class(); at the end so we return the new values.

We also have all of these wonderful custom taxonomies now in WordPress 3.0 but if you look at the output of post_class(); you’ll notice that none of your custom taxonomies show up. Sure your custom post types do, and on a regular post the categories and tags do, but on a custom post type you get nothing. While this might be an oversight lets add it for our purposes.

[php]
$term ) {
if( !in_array( $term->slug, $classes ) ) {
$classes[] = $term->slug;
}
}
}
return $classes;
}
}
?>
[/php]

The example above assumes that we have a custom taxonomy of Genre and will add any terms from genre to post_class();. If you had a different custom taxonomy just change ‘genre’ to whatever you’ve named your custom taxonomy.

The final scenario I’ll go over today is to just add some static classes to post_class();. In one of the projects I added the odd/even highlights to post_class(); but if there is already a class on the wrapper nothing will show for post_class();. Unfortunately this theme had a number of odd classes just used to style (like .can_chg_bg WTF!!) that I needed to add to along with the odd/even highlights.

[php]

[/php]

With the example above just duplicate the $classes[] = 'your-class-name'; and change the value to whatever classes you need to add to post_class();.

Other Resources

This is not an exhaustive post on what you can do with post_class(); so you can do some of your own looking with some of the resources below:

Any ideas that I’ve missed? Got some neat post_class(); snippets and use cases to share?