[wp-hackers] Detecting pings?
Mark Jaquith
mark.wordpress at txfx.net
Mon Nov 29 21:34:13 UTC 2004
Very sorry! I pasted in from PHPXref and there must have been some
invisible html code included... it didn't show up in the e-mail I
composed, but I got suspicious when it took ~25 seconds to send the e-mail.
Michael Heilemann wrote:
> I don't know what you're doing, but I've had a LOT of garbage attached
> to a couple of your mails now. It's very weird!
>
> On 29/11-2004, at 17.27, Mark Jaquith wrote:
>
>> This function yields the answer:
>>
>> 172 function comment_type($commenttxt = 'Comment', $trackbacktxt =
>> 'Trackback', $pingbacktxt = 'Pingback') {
>> 173 global $comment;
>> 174 if (preg_match('|<trackback />|', $comment->comment_content)
>> 175 || ('trackback' == $comment->comment_type)) {
>> 176 echo $trackbacktxt;
>> 177 } elseif (preg_match('|<pingback />|',
>> $comment->comment_content)
>> 178 || ('pingback' == $comment->comment_type)) {
>> 179 echo $pingbacktxt;
>> 180 } else {
>> 181 echo $commenttxt;
>> 182 }
>> 183 }
>> The preg_match stuff is for backwards compatibility... but I don't
>> think it is needed. All of my 1.2 trackbacks and pingbacks have
>> $comment->comment_content set correctly, and this is the upgrade code
>> that seems to do that:
>>
>>
>> 196 // Update comments table to use comment_type
>> 197 $wpdb->query("UPDATE $wpdb->comments SET
>> comment_type='trackback', comment_content = REPLACE(comment_content,
>> '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
>> 198 $wpdb->query("UPDATE $wpdb->comments SET
>> comment_type='pingback', comment_content = REPLACE(comment_content,
>> '<pingback />', '') WHERE comment_content LIKE '<pingback />%'");
>> So really, you could just do logic on $comment->comment_type
>>
>> Note that $comment->comment_type will be empty for regular comments
>> and only contains value "trackback" or "pingback."
>>
>>
>> Michael Heilemann wrote:
>> Not being a programmer, how do I detect pings in between the
>> comments, in WP13? I could use a snippet of code if anyone has a
>> plugin or something that already does this.
>>
>> Aloha, Mike
>> http://binarybonsai.com
>
More information about the hackers
mailing list