So although I’ve said before that I was working on my first plugin, I’m actually going to release my first plugin. it’s the first one I’m letting out into the wild – not the first one I’ve written
So here it is – my jQuery Expandable Comment Replies.
It actually started with an idea i had last week. You’ll notice I’ve had a redesign over the last week – that’s because I finally realized I could make my own site be how I really wanted it to be, and if I wanted to add some cool stuff (like the jQuery scroller on the index page) then by golly, I could. So I did
But as I was tweaking things, I noticed my comments were flat. I’d been looking on other sites for inspiration – and it’s funny – the thing that got me was YouTube. Not because they have cool-looking comments – but because they had replies that could expand. I thought this was something really cool to have, because to me, comment replies (even if they remain on-topic) can sometimes get away, and on occasion, detract from the topic at hand.
Believe me, I’m the queen of going off on a tangent, but sometimes working my way through a bunch of replies that go off on all kinds of tangents is just not a fun thing.
The issue was I had to somehow group my replies. Now, I know this already comes in by default for the OL/LI listing of comments, but because I’m also using cufón on my site, I was requires to have valid code using a Strict Doctype. (the <p> element within a <li> tag is NOT valid – nor are many other things I was using to try and style my comments. Therefor validity was broken and my cufón stopped working!)
So what to do. The unfortunate thing with the callback method that can be used to redo your comment layout is that the wp_list_comments function provides it’s own Loop – so when you use the callback feature, whatever you put in there is already within a Loop. So when I’d try to put in my outder grouping div, it would apply to every single comment – it wasn’t grouping how I needed it.
(By the way, you can get a GREAT tutorial on the callback feature on Jeremy Cark’s site, and you’ll see the discussion I was having with him – and my ultimate “Ureka!” – in his comments over there :))
Initially, the only way I could pull it off was by editing core WP code – a big fat no-no. but after a week of trying, I finally gave up and did it. But I love puzzles – so I HAD to figure it out. And so I did.
Thus, the plugin, which you can download here.
I’ve got this set up so it’s as easy as possible for you to use it. I’ve included the jQuery 1.3.2 library, so if you already have it installed, you probably want to ignore the “scripts” folder I’ve got in there. But if you aren’t using jQuery, then you must have the library installed for this to work – so upload the “scripts” folder to your theme directory.
The next step is to edit your comments.php file – you want to replace
bb_list_comments. Notice I did not include the brackets – that’s because this plugin is already set to work with whatever setup you currently have. So if you have stuff inside the brackets, you want to keep it in place.
Lastly, you want to activate the plugin. That’s pretty much all there is to it.
You can see the effect by visiting some of the other pages in my site (this one, for example). You will see one of the comments has a link that says “Show/Hide Replies”. Click that, and you’ll see the expansion.
As usual (when it comes to my stuff) it’s handed out on an as-is basis. If you find any bugs, definitely let me know – but otherwise you’re pretty much on your own. (I am helpful though – if I can help you, most likely I will – because I’m nice like that – but please don’t force support on me. I do have a life!)