{"id":644,"date":"2006-08-23T09:35:59","date_gmt":"2006-08-23T06:35:59","guid":{"rendered":"http:\/\/www.mummila.net\/nuudelisoppa\/index.php\/?p=644"},"modified":"2006-08-23T09:35:59","modified_gmt":"2006-08-23T06:35:59","slug":"recent-comments-plugin-and-trackback-titles","status":"publish","type":"post","link":"https:\/\/mummila.net\/nuudelisoppa\/2006\/08\/23\/recent-comments-plugin-and-trackback-titles\/","title":{"rendered":"Recent Comments Plugin and trackback titles"},"content":{"rendered":"<p>I&#8217;m using the excellent <a href=\"http:\/\/blog.jodies.de\/archiv\/2004\/11\/13\/recent-comments\/\">Recent Comments plugin by Krischan Jodies<\/a> on my <a>other blog<\/a>. It&#8217;s been working perfectly until I got the first pingback without a &raquo; (a &amp;raquo;) in the <code>$comment-&gt;comment_author<\/code> field. That caused it to echo &#8220;Anonymous&#8221; instead of the actual title of blog doing the pingback.<\/p>\n<p>Strangely, of the macros defined by Recent Comments, <code>%trackback_title<\/code> 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 <code>%comment_author<\/code> with <code>%trackback_title<\/code> wouldn&#8217;t help.<\/p>\n<p>So I edited the plugin to fix this. <code>$comment_author<\/code> is set on line 659:<\/p>\n<blockquote>\n<p><pre><code>659\t\t\t$comment_author =\n\t\t\t\ttrim(substr($comment_author,0,strpos($comment_author,'&raquo;')));<\/code><\/pre>\n<\/p>\n<\/blockquote>\n<p>Apparently, if the title doesn&#8217;t have a &amp;raquo; in it, this nullifies <code>comment_author<\/code>, causing the soon to follow <code>if (! $comment_author)<\/code> test to fail and subsequently <code>$comment_author<\/code> being set to &#8220;Anonymous&#8221;.<\/p>\n<p>So I wrapped the trimming clause (the one on line 659 in the original) inside a conditional, which tests for the presence of &amp;raquo;:<\/p>\n<blockquote>\n<p><pre><code>659\t\t\tif (strpos($comment_author,'&raquo;') !== false) {\n660\t\t\t\t$comment_author =\n\t\t\t\t\ttrim(substr($comment_author,0,strpos($comment_author,'&raquo;')));\n661\t\t\t}<\/code><\/pre>\n<\/p>\n<\/blockquote>\n<p>Now the title of the page doing the pingback is preserved in <code>%comment_author<\/code>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m using the excellent Recent Comments plugin by Krischan Jodies on my other blog. It&#8217;s been working perfectly until I got the first pingback without a &raquo; (a &amp;raquo;) in the $comment-&gt;comment_author field. That caused it to echo &#8220;Anonymous&#8221; instead of the actual title of blog doing the pingback. Strangely, of the macros defined by [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[9387,30,29],"class_list":["post-644","post","type-post","status-publish","format-standard","hentry","tag-blog","tag-bugsglitches","tag-hacks-tweaks"],"_links":{"self":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/644","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/comments?post=644"}],"version-history":[{"count":0,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/posts\/644\/revisions"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/media?parent=644"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/categories?post=644"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/nuudelisoppa\/wp-json\/wp\/v2\/tags?post=644"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}