Recent Comments Plugin and trackback titles

I’m using the excellent Recent Comments plugin by Krischan Jodies on my other blog. It’s been working perfectly until I got the first pingback without a » (a ») in the $comment->comment_author field. That caused it to echo “Anonymous” instead of the actual title of blog doing the pingback.

Strangely, of the macros defined by Recent Comments, %trackback_title seems to have the correct title already for the one ping coming from outside my site, but for in-site pings it displays the title of the post being pinged, so replacing %comment_author with %trackback_title wouldn’t help.

So I edited the plugin to fix this. $comment_author is set on line 659:

659			$comment_author =
				trim(substr($comment_author,0,strpos($comment_author,'»')));

Apparently, if the title doesn’t have a » in it, this nullifies comment_author, causing the soon to follow if (! $comment_author) test to fail and subsequently $comment_author being set to “Anonymous”.

So I wrapped the trimming clause (the one on line 659 in the original) inside a conditional, which tests for the presence of »:

659			if (strpos($comment_author,'»') !== false) {
660				$comment_author =
					trim(substr($comment_author,0,strpos($comment_author,'»')));
661			}

Now the title of the page doing the pingback is preserved in %comment_author.