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.
wp-content/plugins/ and active in the Plugin Control Panel. Your blog will now allow up to 5 pings within 75 seconds.
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-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.
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
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.