For a while, I’ve been a bit annoyed with WordPress losing pings (those automatic links on your blog when someone links to you) that should be coming to my posts. I noticed that when I or an external blog link to more than one of my posts only one ping would register in my comments. For example, if someone writes that:
Scott has written WordPress plugins to make it easier to write about code, generate monster avatars and generate unique geometric shapes for each commentor.
I would want a ping to appear on each of those linked posts, both to thank the linking blog for writing about me and to provide useful information to the reader (and to increase my comment counts). Yet WordPress only puts a ping on the first linked page.
It took me a little while to figure out why WordPress kept losing my pings since I wasn’t even sure if it was a problem on the sending or receiving end but it turns out WordPress is filtering pings because it thinks the comments are coming too fast. I’ll put the details below but if you just want to make sure all the pings intended for your blog actually reach it then here is the plugin for you.
Current Version:
Installation instructions:
Unzip wp_pingpreserver.zip
. Upload wp_pingpreserver.php
to wp-content/plugins/
and active in the Plugin Control Panel. Your blog will now allow up to 5 pings within 75 seconds.
Technical Details
The average user won’t need to read this but I thought I would post the details of the problem in case anyone wanted to fix it in the core WordPress files. It turns out that the function wp_throttle_comment_flood
from wp-include/comment.php
is automatically added as a default filter (in /wp-includes/default-filters.php
). This function checks if the last comment from the commentor’s IP address was within 15 seconds and if so rejects the comment. This is obviously a problem with pings when 2 or 3 comments will be coming from the same IP within seconds.
Unfortunately, the comment_flood_filter
passes in very little information (only the time of the current and previous comment) and the function wp_throttle_comment_flood
does not allow plugins to signal that a comment should be accepted. So for this plugin to work it has to remove_action
wp_throttle_comment_flood
and replace it with it’s own function. Also since no information about the comment is available in the scope of the function (that I could find), I had to resort to checking to see if the $_SERVER['PHP_SELF']
variable contained the string “xmlrpc.php”.
Anyway it’s a bit of a hack but it seems to be working. Please let me know if you have any problems or suggestions.
ScottS-M | 08-Aug-07 at 4:05 pm | Permalink
Hmm. I had thought it was working but I didn’t get pings on the 2nd and 3rd post I linked to. I’ll update once I figure out what is going on now.
ScottS-M | 08-Aug-07 at 5:51 pm | Permalink
OK it’s working now. I was using a thrown together pinger to test things and apparently it sends pings slightly different than WordPress does. But it’s all fixed now by checking a different variable to determine if a comment is a ping.
RT Cunningham | 16-Aug-07 at 4:28 am | Permalink
I have tested this on my own blog and it works as advertised. Now I just have to write an article to get the word out to more people so they can install it on their blogs. I tested pinging three times on another blog and one of the pings went into lala land, and the other two pinged the wrong articles. Hopefully, the recipient will heed my advice and plug this in.