WordPress.org

Plugin Directory

wiki:CricketMoods

Cricket Moods

Latest version: Download 3.6

Description

Cricket Moods is a flexible "mood tag" WordPress plugin. It allows an author to add one or more "moods" to every post. Each mood can be associated with an image file. The result would be that the author could have an animated happy smiley face next to the words I'm Happy for every post she wishes.

Cricket Moods presents you with a list of available moods when you go to create or edit a post. There is no need for you to remember your list of moods. Using an option panel in WordPress' administrative menus, you can rename your moods or even change a mood's graphic without modifying every post that uses that mood.

Despite this plugin's name and my continual reference to "moods", this plugin can be used for more than just moods. For example, instead of displaying your current mood, you could give your readers the current weather where you are. You could rename the mood tags to things like "Sunny", "Overcast", and "Raining Cats and Dogs." You could then upload little cloud and sun images and use those with the tags instead of the pre-defined mood smilies. You could even leave the tag text or the tag images blank to have either just text or just images. I'd love to hear about creative uses of this plugin!

New in Cricket Moods 3.0 is the ability for every user (contributor and higher) to keep their own personal list of moods.


Installation

You can get the plugin as a zip archive, or you can get a possibly experimental (possibly non-working) version directly from the subversion repository. There are two steps to install:

  1. Place cricket-moods.php into /wp-content/plugins.
  2. Activate the Cricket Moods plugin from the Plugin Management panel of WordPress.

Upgrading

This version of Cricket Moods does not support upgrading from Cricket Moods 1.x. Upgrades from Cricket Moods 2.x are automagic. No additional steps are necessary to upgrade from any 3.x version.


Usage

By default, Cricket Moods will automatically print each post's moods just above each post's content. With the default theme it would look something like the following:
source:/cricket-moods/trunk/screenshot-1.png

Using the "Cricket Moods" panel under "Options" in the WordPress administrative area, you can add, modify, and delete moods as you see fit. Leaving the "Mood Name" blank will cause Cricket Moods not to display any text with that mood's image for a purely pictorial representation of your mood. Conversely, you can leave the "Image File" blank and no smilie or other image will be shown with that mood. Deleting a mood will also remove any references to that mood from your blog posts.

Advanced Usage

If you want your moods to be displayed somewhere other than the default location, you must place cm_the_moods() somewhere inside The Loop and disable AutoPrint in the "Cricket Moods" options. When called with no parameters, cm_the_moods() only prints the mood image followed by the mood name, an ampersand, and any more moods followed by ampersands. For example, on a post with the moods Stressed and Bored it will print:

<img src="/wp-images/smilies/aiwebs_001.gif" alt="Stressed emoticon" /> Stressed &amp; <img src="/wp-images/smilies/icon_neutral.gif" alt="Bored emoticon" /> Bored

If there are no moods defined for the current post, it will print nothing.

cm_the_moods()

cm_the_moods() can take three parameters:

<?php cm_the_moods('separator', 'before', 'after'); ?>
separator
(string) Text to place in between multiple moods. Default is ' & '.
before
(string) Text to place before the first mood. Default is nothing.
after
(string) Text to place after the last mood. Default is nothing.

A good way to implement this would be:

<?php cm_the_moods(' and ', '<p>My mood is: ', '.</p>'); ?>

This function checks to see if the current post has any moods before attempting to print the moods; therefore, it is not necessary to wrap it in an if(cm_has_moods()) statement.

cm_has_moods()

You can also use cm_has_moods() to determine if the current post or a specific post has moods associated with it. It will return true or false accordingly.

cm_has_moods() can take one parameter:

<?php cm_has_moods(post_id); ?>
post_id
(integer) The ID of the post you are inquiring about. Default is the ID of the current post.

cm_has_moods() must be used inside The Loop if post_id is not provided.


Frequently Asked Questions

Why does the plugin deactivate as soon as I activate it?

You are trying to use Cricket Moods 3.0 with a version of WordPress it doesn't support. You must be using WordPress 2.0.5 or higher for Cricket Moods to work. If you are stuck with an older version of WordPress, Cricket Moods 2.x is still available for you.

Can each user have their own list of moods?

Yes! This is a new feature of version 3.0.

Is there a limit to the number of moods I can have?

Not that I know of. I certainly didn't program one in.


Known Issues

  • Things get a little fuzzy when you change the author of an existing post with

mood tags. If the two authors do not have the exact same mood list, the associated moods may seem to unexpectedly change or not show at all. It is recommended that you disassociate all the moods from a post before changing the post's author.

  • Editing the post of another user will cause *that* user's moods to be

displayed, not yours. This is an unavoidable feature.


To Do

  • Fix bugs (gotta find 'em!).
  • Add support for more than one category of text/image tags.
  • Listen to user suggestions

About the Author

This is my first WordPress plugin. Coding PHP is just a hobby.

Feel free to e-mail me at <kccricket> <at> <gmail.com>. You can find more information and other (more instantaneous) contact methods at my website.

Last modified 9 years ago Last modified on 09/10/07 04:59:54

Attachments (4)

Download all attachments as: .zip