{"id":72,"date":"2007-08-08T15:45:05","date_gmt":"2007-08-08T19:45:05","guid":{"rendered":"http:\/\/scott.sherrillmix.com\/blog\/programmer\/web\/wp_pingpreserver\/"},"modified":"2008-01-21T22:42:29","modified_gmt":"2008-01-22T02:42:29","slug":"wp_pingpreserver","status":"publish","type":"post","link":"http:\/\/scott.sherrillmix.com\/blog\/blogger\/wp_pingpreserver\/","title":{"rendered":"WP_PingPreserver"},"content":{"rendered":"

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:<\/p>\r\n

Scott has written WordPress plugins to make it easier to write about code<\/a>, generate monster avatars<\/a> and generate unique geometric shapes for each commentor<\/a>.<\/p><\/blockquote> \r\n

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.<\/p>\r\n\r\n

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.<\/p>\r\n\r\n\r\n\r\n

Current Version:<\/h3>

WP_PingPreserver v0.4<\/a><\/p>\r\n\r\n

Installation instructions:<\/h3>

Unzip wp_pingpreserver.zip<\/code>. Upload wp_pingpreserver.php<\/code> to wp-content\/plugins\/<\/code> and active in the Plugin Control Panel. Your blog will now allow up to 5 pings within 75 seconds.<\/p>\r\n\r\n

Technical Details<\/h3>\r\n

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<\/code> from wp-include\/comment.php<\/code> is automatically added as a default filter (in \/wp-includes\/default-filters.php<\/code>). 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.<\/p>\r\n

Unfortunately, the comment_flood_filter<\/code> passes in very little information (only the time of the current and previous comment) and the function wp_throttle_comment_flood<\/code> does not allow plugins to signal that a comment should<\/em> be accepted. So for this plugin to work it has to remove_action<\/code> wp_throttle_comment_flood<\/code> 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[&#039;PHP_SELF&#039;]<\/code> variable contained the string “xmlrpc.php”.<\/p>\r\n

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.<\/p>\r\n\r\n\r\n

Change Log:<\/h3>\r\n