[wp-hackers] Detecting pings?

Mark Jaquith mark.wordpress at txfx.net
Mon Nov 29 16:27:52 UTC 2004


This function yields the answer:

> 172  function comment_type <cid:part1.07080507.06070404 at txfx.net>($commenttxt <cid:part2.00060104.03040202 at txfx.net> = 'Comment', $trackbacktxt <cid:part3.05000505.00050605 at txfx.net> = 'Trackback', $pingbacktxt <cid:part4.02010707.00060202 at txfx.net> = 'Pingback') {
> 173      global $comment <cid:part5.02040800.03070707 at txfx.net>;
> 174      if (preg_match <cid:part6.09050402.09060905 at txfx.net>('|<trackback />|', $comment <cid:part5.02040800.03070707 at txfx.net>->comment_content <cid:part8.08040604.09010302 at txfx.net>)
> 175          || ('trackback' == $comment <cid:part5.02040800.03070707 at txfx.net>->comment_type <cid:part10.07020703.07030202 at txfx.net>)) {
> 176          echo $trackbacktxt <cid:part3.05000505.00050605 at txfx.net>;
> 177      } elseif (preg_match <cid:part6.09050402.09060905 at txfx.net>('|<pingback />|', $comment <cid:part5.02040800.03070707 at txfx.net>->comment_content <cid:part8.08040604.09010302 at txfx.net>)
> 178          || ('pingback' == $comment <cid:part5.02040800.03070707 at txfx.net>->comment_type <cid:part10.07020703.07030202 at txfx.net>)) {
> 179          echo $pingbacktxt <cid:part4.02010707.00060202 at txfx.net>;
> 180      } else {
> 181          echo $commenttxt <cid:part2.00060104.03040202 at txfx.net>;
> 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 <cid:part19.03080601.06000308 at txfx.net>->query <cid:part20.06090003.03060309 at txfx.net>("UPDATE $wpdb <cid:part19.03080601.06000308 at txfx.net>->comments <cid:part22.04010802.08040503 at txfx.net> SET comment_type='trackback', comment_content = REPLACE(comment_content, '<trackback />', '') WHERE comment_content LIKE '<trackback />%'");
> 198      $wpdb <cid:part19.03080601.06000308 at txfx.net>->query <cid:part20.06090003.03060309 at txfx.net>("UPDATE $wpdb <cid:part19.03080601.06000308 at txfx.net>->comments <cid:part22.04010802.08040503 at txfx.net> 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
>
>
> _______________________________________________
> hackers mailing list
> hackers at wordpress.org
> http://wordpress.org/mailman/listinfo/hackers_wordpress.org
>
>
>

-------------- next part --------------
Skipped content of type multipart/related


More information about the hackers mailing list