CliqueClack Code

Rather than continue to post new Wordpress plugins over on my sadly-lacking personal site, I’m going to publish this one here. Hopefully people will find it as useful as the CliqueClack writers do!

What it does: This plugin will add a new button to the post and page editing TinyMCE toolbar (though only in visual/rich editing mode). Highlight text and click the main button and it will make that text a tag link to your blog, or you can click the submenu to choose from your site’s category links or links to authors (only those who are currently set as “contributor” or higher).

To install: Activate in the plugins admin screen. No options available.

If you wish to make all users available for liking in the “Authors” submenu, you’ll need to change one simple line in one of the source files.

You can download this plugin at the official Wordpress plugin repository.

I’m happy to hear any suggestions and hopefully help with any issues you all might have. Enjoy!

(On a side note, I get that this site looks all decrepit when compared to our other CliqueClack sites, but I’ve got plans to revamp it sometime soon.)

I’m going to start using Amazon S3’s CloudFront distribution service to better distribute and parralelize calls to images and such on my websites. However, since I use Joe Tan’s Amazon S3 for Wordpress plugin, I couldn’t easily make use of CloudFront with Wordpress uploads. So, as I usually do when I’m impatient, I altered the original code to not only allow for CloudFront, but if you supply multiple CNAMEs you assigned to your CloudFront distribution, it will randomize what hostname it returns when you add the image to your post!

Essentially I just added options for a CloudFront distribution hostname and then a spot for adding a CNAME (or multiple CNAMEs). When you upload your file, it should return a random CNAME for you, if any are entered.

Anyway, rather than paste all the diff code here, you can take a look at the diff file here. If you can’t figure it out, let me know and I’ll post the actual changed files. For me, it works as I’d hoped. Use at YOUR OWN RISK and, really, this is meant for people who are impatient like me and know at least how to code PHP a little. Hopefully Joe Tan will find this info useful and will update his plugin formally.

Alright, so this isn’t all about coding, but it’s in the same wheelhouse.

Because it’s that time of year, where our inboxes are getting clobbered with Black Friday, Cyber Monday, Widget Tuesday deals, it’s been hard to ignore how cheap technology has gotten since just a few years ago, nevermind 10+ years ago. Oh, I could go on and on about my first computer with the green CRT screen and the whopping 128K RAM card, but I risk putting you to sleep already.

Consider hard drives, for example. The technology is getting so much better and cheaperĀ  — and quickly! — that the “remember when 1TB drives cost a mint” was just back around the corner. Now 1.5TB drives are almost sub-$100, meaning you could build what was once a $10,000 RAID array incredibly cheaply … for your home!

Read the rest of this entry »

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 »