Development on a Shoestring

Archive for the ‘WordPress Plugins’ Category

New beta for the FriendFeed Comments plugin

For anyone who’s game, and especially for anyone who’s been having problems with the FriendFeed Comments plugin, I’ve just checked in a new beta release that you can download.  It’s not available through the WordPress auto-updater yet because it’s not been tested sufficiently.  So if you’d like to help out you can grab it here: http://downloads.wordpress.org/plugin/friendfeed-comments.1.6.0beta.zip

There aren’t any major visible changes.  There’s a couple of tidy up changes eg. I removed some inline styles that I should have moved into the default stylesheet, but the major changes are behind the scenes.  Some people were having issues with the plugin not retrieving the information correctly and it seemed to be an issue for people with a large number of posts & comments.  So this new version now stores the data in a custom table on your WordPress database.  This should make things much more efficient and hopefully less error-prone.

If you do install the new update you must deactivate & re-activate the plugin, then go to the settings page & click ‘Save Changes’ before it will work.  If you don’t the table won’t be created and it won’t work.

If you can help out with the beta testing it would be much appreciated.

Showing trackbacks with Disqus

http://media.disqus.com/images/global/disqus-logo.pngCurrently one of the limitations of using the otherwise great comments service Disqus is that it doesn’t allow you to display trackbacks/pingbacks.  Apparently this will be fixed in a future release of the Disqus WordPress plugin, but for now it’s not working.

The trackbacks you receive are still stored locally in your database, despite them not being displayed, so you can access them. However there isn’t a built-in way to access just the list of trackbacks. Trackbacks are stored as comments in the wp_comments table and are identified by a comment_type of either ‘trackback‘ or ‘pingback‘. (For our purposes here, there’s no real difference between the two. For more info on what the actual difference is, see this page) So, if you wanted to you could write up a bit of PHP that pulled all the trackbacks out of the database & displayed them on your blog, but for a lot of people this is a bit much.

If you look on this page (the FriendFeed Comments Plugin page), you can see a list of the trackbacks that page has received. It’s a very simple list, I’m not displaying the text snippet that usually comes with trackbacks, but that’s just personal preference. If you’d like to be able to display your trackbacks without having to worry about writing code yourself I’ve got a really simple plugin that lets you do this here. The plugin adds 2 functions, get_approved_trackbacks & trackbacks_templateget_approved_trackbacks takes the post id as an argument and returns a list of the trackbacks that have been approved (moderated) for that post. trackbacks_template is essentially an additional template tag to be used in the same way as comments_template() is used on the single.php template file.

So for example, if you wanted to display the trackbacks before the comments, download & install the plugin. Then open up the single.php template file for your site & find the line <?php comments_template(); ?>. Stick <?php trackbacks_template(); ?> on the line above it. This will display the trackbacks as an unordered list inside a div with the id "trackbackslist" with a h3 heading "Trackbacks" above the list. However if you’d like to style it differently, it will also look for a template file called trackbacks.php in your template folder. If it finds that it will use that to render the trackbacks.  This is what I’m doing here so as to not display the trackback text.  By default the plugin will display that too.

Obviously this is an advanced option, and only for those familiar with HTML & PHP.  For those people, the plugin provides a variable called $trackbacks which is an array of comment objects. The code that I’ve used to display the trackbacks by default is contained in a file called ‘trackbacks.php’ in the plugin folder, which you can copy into your template folder to use as a starting point for styling your own list.

Hopefully Disqus will sort out what it’s going to do with trackbacks, according to Daniel from Disqus it’s coming soon.  I’m pretty happy with their service, they’ve been really responsive to any support requests and they’ve had pretty solid uptime.  The lack of trackbacks isn’t really a big deal to me, but I do like to show who’s discussing my posts. As usual please leave comments / bug reports on the plugin’s page.

Overcomplicating the issue

One of the main issues that some people have been having with the FriendFeed Comments Plugin is that sometimes, seemingly randomly, it will fail to match up a post with the information from FriendFeed.  There are a couple of reasons why this does happen, but the problems all centre around the fact that I have to use the post title to match up the details because there’s no other uniquely identifiable piece of information available.

This is of course a problem when people edit the title, either due to a typo or a editorial change.  Also there seems to be some string encoding issues, especially around the 32,000 different characters that can render to look like an apostrophe.    I’ve spent quite a lot of time trying to strip out the special characters and normalise the titles so I can be sure of getting a match between what’s on the blog & what’s coming back from the FriendFeed API.  I even tried just stripping out non-alphanumeric characters, but then I had a complaint from an amazingly patient person who’s site was using Cyrillic.  So what I’ve got now is a rather hodgepodge solution where it tries to strip out as many characters as possible, then does an md5 hash on that to use as the id, and some people are still having issues where, for no apparent reason, the posts won’t match up.

(more…)

I’ve just checked in a new version of the FriendFeed Comments plugin, which you can download here.  If you’ve already got it installed it should be showing up that an update’s available any moment now.

There’s a lot of code tidy ups and debug improvements, but the major change is the addition of the ability to remember your FriendFeed username & API Key when you comment on or like a post.  There’s now a ‘remember’ checkbox under the API Key field (which is now password masked, like it always should have been!).  If you tick that, it will drop a cookie onto your computer which means you don’t have to keep typing in your username & API key for that blog.

An important security note: the cookie doesn’t contain any identifiable information in it.  It just has a hash key value that is used to look up your username & api key in the blog’s database (which is stored in plain text in the blog’s database).  There is no way through the plugin for the site owner to see your API Key, but if they open their database directly, it is possible.  As in any other case, only share your API key with sites that you trust.  If you don’t tick the ‘remember’ box, your username & api key will not be stored anywhere.

As always, try it out here and then give it a go on your site if you like.  Any problems, please let me know.

I’ve been a bit inspired over the last week to do some fairly major updates to the FriendFeed plugin.  Thanks to some helpful suggestions and feedback from a number of people, I’ve added a bunch of new features and fixed some dodgy code that was in the previous versions.

The biggest change is that you can now comment & ‘like’ a post directly from the post itself without having to go to FriendFeed.  This is done using a bit of AJAX (via Prototype). The user puts in their comment, their username & their FriendFeed API key.  The API key is never visible to the site owner, it’s passed directly through to FriendFeed and then discarded.

image

This form is turned on by default, but can be disabled in the admin section if you don’t like it. Also, because of this change, the plugin will now display on every post, whether there are comments or likes on it or not.

The other changes are:

  • You can now edit the ‘headline’ text that displays. ie the "On FriendFeed, this post was liked by x people and commented on y times".  You can now put whatever you want there, and it will replace the tokens {comments} & {likes} with the number of comments & likes.
  • A default stylesheet is now included, to get you started on styling the plugin’s content.  It also can be disabled in the admin page, and you can see what the stylesheet looks like here.
  • The plugin can now be set to have the FriendFeed comments & likes be visible by default.  Currently the default is to hide them and only show them when the user clicks the ’show’ link.
  • Also, based on the points I made in my post about self-cleaning WordPress plugins, the admin page now has a ‘delete plugin’ button.  This is will remove all trace of the plugin from the WordPress database, so you can then deactivate the plugin knowing it hasn’t left anything behind.  Needless to say, only use this if you want to completely remove the plugin, not just disable it temporarily.
  • Numerous bug fixes & tidy-ups.  I’ve replaced my bespoke javascript to hide/show the comments with Prototype too.

So, if it hasn’t already turned up in the Automatic Updates list, grab the new version from here.  As always please let me know what you think & how it can be better.

Writing self-cleaning WordPress plugins

Don’t you just hate it.  You install a program on your computer to try it out, then when you go to un-install it, it leaves files scattered all over your system.  Whether it’s in the application folder that it can’t delete, or in the Application Data folder or system32, it’s not easy to find a program that cleans up after itself properly.  I’ve got more of a chance of getting my kids to tidy up the lounge room after they’ve got all the Lego out.

This issue isn’t just limited to Windows applications though.  I’ve noticed the same problem with a lot of WordPress plugins.  It may just be leaving a couple of config options in the wp_options table, or it may be as much as leaving multiple custom db tables behind or even files in the WordPress install folder.  I’m of the opinion that once you remove a plugin, it should be gone without a trace.

Now, for plugin developers, WordPress provides a simple way to do this.  The register_deactivation_hook() method lets you register a function to be called when your plugin is deactivated.  In there you can put any cleanup code to remove options, tables files, etc.

But…

This is not without it’s problems.  Often plugins require you to enter some complex config information or they may build up a history that you may not want to lose (eg. a spam filter that learns from what you mark as spam).  Sometimes you need to disable plugins temporarily, in fact the WordPress update instructions say that you should deactivate all your plugins prior to upgrading.

Also, the automatic plugin updates system introduced into WordPress deactivates plugins before it installs the updated version.  So if you put the cleanup tasks into the deactivation hook method, all the user’s settings would be gone after updating.  This really isn’t a good option.

What would be better is if the WordPress plugin admin page had 2 buttons for each plugin: deactivate & uninstall.  Deactivate would do what it does now - turn off the plugin, but leave it in place.   Uninstall would completely remove the plugin, including deleting the plugin file & firing a separate uninstallation hook callback.  Developers could then put all their cleanup code in there, with no fear that users were going to lose settings during an upgrade.

What to do for now

I think for the time being it would be best if developers included a ‘remove all data’ button on their plugin’s options page (if it has one).  This button would remove all trace of the plugin (other than deleting the plugin itself) so that the user can then deactivate it.  This button should probably be restricted to admin users and have some form of confirmation on it. I’ve added a button to do this in the latest release of the FriendFeed Comments Plugin.

There’s already a post about this ideas section of WordPress.org, and a discussion about it on Weblog Tools Collection.  I’m hoping that this gets noticed, because it would be great if developers had a simple way of tidying up after themselves.

If this is something that matters to you, please go vote up this idea on WordPress.org.

Advertise Here

Subscribe by email

Enter your email address:

Delivered by FeedBurner


Elsewhere

Liked 28 stories

That's how I roll

Artists blaming iTunes for changing music tastes. I got news for these idiots, iTunes only responded to forces in the marketplace. If you want to sell an album, make one worth buying.

FUCKEN PARTY!!!! [pic]

Here’s a small gallery of awesome monsters and aliens made entirely in LEGO!

Ten commandments for developers

Is It Real or Fake?

Why we bill by the hour

IE8 beta2 released

Stargate: Universe has a Go! New series starts 2009

Celebrate haircare pioneer who overcame discrimination to become a millionare...by discriminating against boys of course.

Theft vs. piracy vs. file sharing? Nonono...

Duke Nukem Forever Is In Testing, 'Several Hours" Playable

ACLU doesn't defend the Civil liberties of just ANYONE...

Your chance of getting out alive [Pic]

Girls Just Wanna Have Fun

Vote up if you are a secret Reptilian Overlord who intends to keep humans in perpetual servitude and wish the global shadow governments would chill the fuck out.

Password must be 6 letters: yes. Must contain a numeral: yes. Must not say your bank is pants: WTF?

Appeal Court Overrules Family Court's Shakedown of Dad

Only Chinese performers were skilled, disciplined and obedient enough to lay on the sort of song and dance display seen on Sunday at the Olympics

It’s time to put a deadline on dropping IE6

Zero Punctuation: Braid

An essay on how "Star Trek" ignored fundamental principles of engineering.

Foam Monster wants his hand back... [PIC]

M.C. Escher worked for Blizzard! [pic]

Ahoy Smegheads! a brand new, 1 hour Red Dwarf episode had been commissioned by BBC Worldwide

Overplaying Cards [comic]

Is anything worth its weight in gold?

The Dirty Secret of Clean Energy- "While generating it is getting easier, moving it to market is not."

Friday 13:51

Whohoo! I just got into the stackoverflow beta!

Tuesday 18:53

Top Rated Posts

Verse of the Day

Lift up your eyes on high and see: who created these? He who brings out their host by number, calling them all by name, by the greatness of his might, and because he is strong in power not one is missing. (Isaiah 40:26, ESV) (Listen)

Networks & References