Sunday 15 November 2009

Wordpress Comments plugins

This morning I did a bit more testing of comment plugins for Wordpress. I tried LMB^Box Comment Quicktags, but found first that the javascript file wasn't being included because the path to the file in the php script was wrong. Then after changing the location to point to the correct place so the javascript was included, it still didn't do anything.

I gave the tinyMCE Comments plugin another go, and looking at the code on the author's website, I found out that to get the HTML editing button you just needed to include the button named 'code' - I had thought this meant a button to insert <code> tags, which is why I hadn't tried it before.

After Church I did a bit more Wordpress Comment testing, and found I was getting an XML parsing error, so I tried to work out why I was getting the error and what was causing it. I figured out that it was caused by the Wordpress Quote Comments plugin having a " character in the inline javascript (bad, bad) that it was generating.

After dinner I played on Pure a bit, then me, Moccle, L, Grandad, and Brian went out for a walk.

After the walk I carried on looking at the comments in Wordpress, and found that the problem with the Quotes Comments plugin was on line 63 of quote-comments.php, where it includes the comment author's name. Changing it to escape the author's name esc_attr(get_comment_author()) fixed the problem with the non-entity " by encoding it to an entity &quot;.

After fixing that, I found that when you click the quote button, it will enter the quote into the comment box, but the cursor will be inside the blockquote, and you can't click below (after) the blockquote. So any comment you wrote would be as part of the quote of the other comment. I fixed this by changing the javascript to add an empty paragraph after the blockquote.

But when you view the HTML in the tinyMCE comment box, you could see there was now one empty paragraph before the quote, and two empty paragraphs after the quote. But the tinyMCE editor wouldn't let you click inside the first or second empty paragraphs, just the last empty paragraph.

The X-Valid plugin does have an option to remove empty tags, but unfortunately it seems that somewhere along the line line breaks were getting inserted into the empty paragraphs, making them no longer empty, and so the X-Valid plugin doesn't remove them.

For this reason, and because I also don't like the inline javascript that the Quote Comments plugin was adding, I decided to disable it for the moment. In fact, it seems that most Wordpress plugins are happy to insert inline CSS/style attributes and javascript all over the place. They also have a habit of inserting javascript files in the head of the page - browsers download javascript files in serial, so having javascript files in your page head means that your page can't carry on loading until its finished downloading all the javascript files first. Not good.

If I get some time and don't have anything more important or interesting to do, then I'll probably write my own quote plugin (and maybe re-write the other plugins I'm using as well) at some time in the future.

In the evening I did some more website work and watched half of Batman The Movie with Mauser and L.

The weather today was nice and sunny nearly all day. The sunset wasn't up to much though - just a slight orange tinge to the sky, and over very quickly.

Food
Breakfast: Bowl of chocolate crunch oat cereal; cup o' tea.
Dinner: Chicken Korma; rice. Pudding was a piece of Vienetta. Coffee; 2x pieces of Sainsbury's caramel chocolate.
Tea: 2x cheese on toasts; apple; pear; ½ piece of flap jack; Rocky; cup o' tea.
Supper: Dark chocolate digestive.

No comments: