[ Content | View menu ]

Announcing Rate My Stuff: A Plugin for WordPress

Written on September 24, 2005

I’m pleased as punch to make my first public WordPress plugin available: Rate My Stuff lets you use a ridiculously simple tag syntax in your posts and pages to create star-based (or any image-based) rating systems like this:

***½

I hope someone else will find this useful. Enjoy!

Filed in: WordPress.

9 Comments

- TrackBack - RSS Comments

  1. Comment by Chris Coleman:

    This is really cool. It’s exactly what I’m looking for. It works great for me in a regular entry field, however I get no luck when it’s in a custom field. Do you know if there’s something in the plugin or wordpress that prevents it? All I get is [rate 4] or whatever when it’s in a custom field.

    September 27, 2005 @ 1:02 pm
  2. Comment by Chris Coleman:

    I should probably also mention that I get the same thing in the title. Not that I want stars in my titles, but I figured it was worth mentioning. Thanks!

    September 28, 2005 @ 6:03 am
  3. Comment by Dave:

    Thanks Chris, glad you like it! I’m not too familiar with WordPress’ internals yet, but the plugin is a filter that is attached to the the_content hook. I know it works on post and page text content. Assuming you pull the custom field out using one of the WP functions (can’t recall which one off-hand), it may not be passed through the filter before the custom field is extracted. Which would be strange, to say the least, because I would expect all data extraction functions to run before passing into the filter chains, but without digging into the WP source I’m not sure.

    Just out of curiosity, why are you placing it into a custom field? Were you just testing, or did you plan to store the rating there? I would think this would call for a different plugin, one that pulled the value in the custom field out for you and then converted it to the images. In that case I would only put the number, i.e. a key/value pair like rating = 4 and let the plugin look for the custom field named rating and display the appropriate number of stars based on the number in the field.

    But that’s just a thought.

    September 28, 2005 @ 4:08 pm
  4. Comment by Chris Coleman:

    Well I’m using the custom fields to do sort of a sidebar/more info box for some entries, and it seems like the right spot for it.

    Here’s a screenshot of how I’m using it: http://www.illtron.net/dropbox/box.png.

    I’m brand new to WordPress and php is total Greek to me, but I’m starting to understand some of this., but I can see that this is the part that inserts it into the content add_filter(’the_content’, ‘rate_my_stuff’);

    Do you know what I might have to change to get it to work in a custom field? (I tried, and it’s easily changeable to the_title)

    September 28, 2005 @ 5:18 pm
  5. Comment by Dave:

    How are you retrieving the custom field? Using the_meta or get_post_meta?

    September 29, 2005 @ 11:03 am
  6. Comment by Chris Coleman:

    I’m using get_post_meta.

    September 29, 2005 @ 9:09 pm
  7. Comment by Dave:

    Check your e-mail. I just sent you an updated plugin that just might meet your needs… :)

    September 30, 2005 @ 10:55 pm
  8. Comment by Chris Coleman:

    Dave, the changes work perfectly! I can’t thank you enough. If I could suggest one addition, I’d say to give the images an alt attribute by default, just to keep everything valid. Maybe an asterisk for each star, ½ for the half and the text “out of 5″ for the different parts. I’d say use the entity ★, but it seems to give Windows browsers a heart attack.

    Thanks again! This is really going to help on the site! I’ll be sure to let you know when we launch.

    October 1, 2005 @ 6:30 pm
  9. Comment by Dave:

    Great! I just re-worked the code to make it more modular, so now you don’t even have to modify the code at all to choose between the two modes — they are now two separate plugins using the same core function. I’m going to release the new version tonight, and I’ll e-mail you the new plugin code.

    October 1, 2005 @ 10:49 pm