Adding the WP-PostRatings Plugin
August 12th, 2006 at 6:36 pm (Delve Into Lunacy, Projects)
· 673 views
·
·
Well, I finally got the WP-PostRatings plugin (the little star ratings above this text) working the way I wanted it to. Who would have thought simply wanting to get it to show up in the location where it is now would turn into a major pain in the ass. I guess it would probably help if I wasn’t learning PHP and WordPress tags and functions at the same time.
I made the following modifications to the plugin:
** Change the layout of the ratings image and text from the default.
** Modify the various tooltips to show different information.
** Add new styles to the style sheet to match the current theme.
** Modify the default star image files so they are a hair smaller. I stumbled across a nice feature when doing this one. I didn’t want to get rid of the default images so I placed the modified image files in a new folder in the "images" directory. At this point I was about to start writing a bunch of If-Then statements to have it switch which images it was using based on the theme name. For some reason I went to the Ratings Options page beforehand (no real need to since I already had it set up the way I wanted it) and what do you know…it picked up the new folder and made it another option to select. So no coding on that one like I figured I’d have to do.
** Add in code so that it will always check to see what the name of the current theme is and if it’s not a specific one then it reverts back to the original code. This will be handy so that when I create my own theme later on I just have to add a couple new items to the style sheet and throw in a new section for the If-Then statements that are checking the theme name. Since I tend to bounce between a couple themes for a while until I settle on a final one this will save me from having to constantly comment / uncomment things in the plugin files.
** I wanted to modify the tooltips on items where you had already voted to say "You gave this post a rating of X". After getting the code working though I realized that the cookies (which is where I was pulling it from) only get a "1" passed to them no matter what the actual rating value was. I was already ready to be done with editing this thing so I decided to pass on modifying what gets written to the cookies. Might go back someday and make this change, but I doubt it.
Note On Compatibility: I’ve done testing and it does appear to work fine on IE6, IE7 and Firefox. For some reason though, Opera always shows the "Loading" image from the moment the page is displayed. Oh well. I don’t use or even like Opera, so I’m not going to bother with trying to fix it for the one jackass that feels the need to be different by using that browser.

(8 votes, average: 4.63 out of 5)



