CliqueClack Code

Because of Amazon Web Services’ new API rules, all requests need to be signed. The current version (as of this writing) of the Amazon Reloaded for Wordpress plugin isn’t updated yet to accommodate for the change, and the author understandably doesn’t have time to update the plugin yet. Honestly, it’s going to take adding new options and security for storing Amazon WS account information and secret key, something the current version doesn’t handle yet.

For now, though, since I need the use of this plugin, I’ve hacked in changes that work. The “real” fix for this would be to add options for storing the keys in the database, of course. Thanks to Alan Capesius for the code snippet for signing the URL.

I’ve uploaded the PHP source file with the changes I’ve made. Keep in mind I did not change any of the credits nor the version number of the plugin, so replacing what you have will be overwritten when a new official version comes out and you choose to update. You will also need to apply to get your own Amazon AWS keys.

Thanks Nick Ohrn for a invaluable plugin!

One of the issues I’d been running into with the “Clack Us!” buttons you see on each of these posts is that Wordpress seemed to be applying the urlencode PHP function onto the title twice. For example, I was doing something like this:

$title = urlencode( get_the_title() );
echo "http://twitter.com/home?status=" . $title . "+" . $shorturl;

That sort of worked, except it was encoding things like & as & which would appear literally in the status message on Twitter. Ugly and messy and wrong.

What’s happening is Wordpress is applying the wptexturize function on get_the_title, so I’m getting it already encoded properly for HTML, though not for a URL. Instead, you need to grab the raw title and run urlencode on that:

$title = urlencode( $post->post_title );

That seems to do the trick just as I wanted.

For a while now I’ve noticed that, when copying formatted text from a web page and then pasting it into the Wordpress TinyMCE editor within the same domain, the URL gets pasted as a relative URL. This means that, if the link was:

<a href="http://www.cliqueclack.com/tv/category/tv-shows/">

when pasted, it would appear in a new post as:

<a href="../tv/category/tv-shows/">

This is because, to Firefox, the /wp-admin/ aread of Wordpress is a level deeper than /tv/, and it tried to be helpful by making it a relative URL. This is “helpful” because, should you change your domainname, it will carry over with you without having to change the link. Where it’s not helpful, though, is when you are on a page within the site and happen upon that post — it’s not going to appear at that relative link anymore; it will only work if you see the link while on the front page.

Read the rest of this entry »