I use Rob Miller’s excellent Now-Reading plugin to track all the books I’ve read and am reading here at CoffeeBear. After my recent site upgrade I decided to tweak the single book template for my library. I noticed that the latest version of Now-Reading allows you to note who read a given book on multiuser sites. As my wife occassionally posts here I wanted my reads to be marked as mine, but the default output of the function Rob implemented only displays the user’s login name. Seriously Rob, what were you thinking? If you did not want to give end users the option to select how they want their name to print out why wouldn’t you go with display_name?

I looked at the code Rob used and with a little help from the Practical PHP I hacked together my own function based on Rob’s. By default print_reader2 works the exactly the same as print_reader1 but by feeding it an additional parameter, you get your choice of what to use to display as reader’s name:

  • 0: Prints out the user_login aka the username you use to log into WordPress.
  • 1: Prints user_nicename, appears to simply be an all lower case version of the user’s nickname2.
  • 2: Prints display_name, from the “Display name publicly as” field in your WordPress profile.
  • 3: Prints first_name, from the “First name” field in your WordPress profile.
  • 4: Prints nickname, from the “Nickname” field in your WordPress profile.
function print_reader2( $echo=true, $reader_id = 0, $display = 0 ) {
	global $userdata;

	$username='';

	switch($display) {
		case "1": if (!$reader_id) { get_currentuserinfo(); $username = $userdata->user_nicename; } else { $user_info = get_userdata($reader_id); $username = $user_info->user_nicename; }; break;
		case "2": if (!$reader_id) { get_currentuserinfo(); $username = $userdata->display_name; } else { $user_info = get_userdata($reader_id); $username = $user_info->display_name; }; break;
		case "3": if (!$reader_id) { get_currentuserinfo(); $username = $userdata->first_name; } else { $user_info = get_userdata($reader_id); $username = $user_info->first_name; }; break;
		case "4": if (!$reader_id) { get_currentuserinfo(); $username = $userdata->nickname; } else { $user_info = get_userdata($reader_id); $username = $user_info->nickname; }; break;
		default: if (!$reader_id) { get_currentuserinfo(); $username = $userdata->user_login; } else { $user_info = get_userdata($reader_id); $username = $user_info->user_login;};
   }
	if ($echo)
		echo $username;
	return $username;
}

Side note: WordPress 2.5.1 got released today and it includes a security fix, be sure to update your blogs!

1 At least, I think it does. I’m not a programmer and I only know enough PHP to be dangerous to myself.
2 The WordPress Codex does not appear to define what this field is used for or why it exists, so that’s just my guess.

Text-Link-Ads is a nice service which I use to help pay the bills for running this site. They just released a new version of their WordPress plugin which I use to put their adverts on this site, so I installed it but in doing so it overwrote a couple of changes I’d made to the old plugin. I had made those changes as I like the service and I definitely like the additional income1, but I don’t like how the plugin makes the ad links less than obviously ads. So my changes in the plugin add a specific class which I can then style via CSS. Since I don’t want to have to keep redoing my customizations from scratch each time they release the plugin; I’m posting the code changes I make here.

Under function outputHtmlAds(), I changed the following line of code from:
echo "\n<ul>\n";</ul>

to:
echo "\n<ul class=\"tla_sponsor_link\">\n";</ul>

Also under function returnPostAd($postId), I changed:
return "\n\n<em>".$prefixes[$prefixIndex].":</em> $ad->before_text <a href=\"$ad->url\">$ad->text</a> $ad->after_text";

to:
return "\n\n<div class=\"tla_sponsor_link\"><em>".$prefixes[$prefixIndex].":</em> $ad->before_text <a href=\"$ad->url\">$ad->text</a> $ad->after_text</div>";

Side note: TLA, you guys should change the Our Blog to be called something else as the link doesn’t actually take users to your blog.

1 I don’t make enough from these ads to get rich mind you. Just enough to cover the costs of running CoffeeBear.net and maybe a cup of good coffee from my local coffee shop.

I used to love playing video games and would waste entire days doing nothing else, but over the last couple of years I’ve started slipping away from that hobby. The expense of keeping my computer updated to handle the latest games combined with the pain I’d get in my wrists just kind of killed the fun. Particularly since I wasn’t seeing a lot of new games to keep up my interest. Well, if the game behind this trailer plays anywhere close to as good as it looks; then I’ll be back to burning the midnight oil to lay waste to the enemy. *grin*

You see, one of my all-time favorite video games was the original Team Fortress mod for Half-Life. The class choices, mayhem and fun were an unbeatable combination1. Then as other mods were developed further; Valve announced they were going to go all out on making TF2. This was 5 years ago and was the last we heard from Valve about it. At least the last we heard until this month when they released the official trailer for TF2. The new character models are wicked cool and oddly enough something about the trailer reminds me of No One Lives Forever (another great video game).

Just wow! I cannot think of any better description of how cool this trailer looks. Go on, hit the link and watch it yourself!

1 At least I’ve always thought so, but others have preferred that POS called Counter-Strike.

Towel Day Self Portait

If so, you better have your towel with you today! As today, is Towel Day.

For those not familiar, Douglas Adams was one of the funniest writers of our time. He wrote a wonderful series of radio plays which were converted in a a series of books and a TV show and later into a really awful movie. This was The Hitchhiker’s Guide to the Galaxy. In this, Mr. Adams wrote:

A towel, it says, is about the most massively useful thing an interstellar hitch hiker can have. Partly it has great practical
value – you can wrap it around you for warmth as you bound across the cold moons of Jaglan Beta; you can lie on it on the brilliant marble-sanded beaches of Santraginus V, inhaling the heady sea vapours; you can sleep under it beneath the stars which shine so redly on the desert world of Kakrafoon; use it to sail a mini raft down the slow heavy river Moth; wet it for use in hand-to-hand-combat; wrap it round your head to ward off noxious fumes or to avoid the gaze of the Ravenous Bugblatter Beast of Traal (a mindboggingly stupid animal, it assumes that if you can’t see it, it can’t see you – daft as a bush, but very ravenous); you can wave your towel in emergencies as a distress signal, and of course dry yourself off with it if it still seems to be clean enough.

More importantly, a towel has immense psychological value. For some reason, if a strag (strag: non-hitch hiker) discovers that a hitch hiker has his towel with him, he will automatically assume that he is also in possession of a toothbrush, face flannel, soap, tin of biscuits, flask, compass, map, ball of string, gnat spray, wet weather gear, space suit etc., etc. Furthermore, the strag will then happily lend the hitch hiker any of these or a dozen other items that the hitch hiker might accidentally have “lost”. What the strag will think is that any man who can hitch the length and breadth of the galaxy, rough it, slum it, struggle against terrible odds, win through, and still knows where his towel is is clearly a man to be reckoned with.

After Mr. Adams’s death some lunatics decided to create Towel Day as a tribute to his genius. I only heard about it this year (about a week ago to be more precise) and decided to join in on the fun. And the fact that I’m telecommuting to work today had absolutely nothing to do with that decision. *grin*

During a recent business trip, I found out some co-workers and friends of mine had put together a comedic short film. The film tells the story of a young woman with some relationship troubles going to a professional philosopher to find the answer. I thought it was pretty funny. And as there is a copy of it over at Google Video, which will autogenerate the HTML code necessary to embed the video on my own site; I figured I’d add it here. Click the more link below to watch the video.

(more…)