I’ve been getting a steady stream of comment spam for the past few days, and WordPress’ built in moderation is doing a superb job. Very few of them have gotten through so far, while normal people are still able to leave comments without me having to moderate them.
My only complaint is that after a comment goes into moderation, I have to click the delete radio button for each one and if I get hit by 20-30 at a time, it’s more time than I want to spend cleaning up comment spam.
To save myself time, I wrote a Javascript function and added it to wp-admin/moderation.php to allow me to select the approve, delete or do nothing radio button for all moderated comments. In case anyone else wants to use it, I’ve included the code below. Simply add the block right above the following text (line number 143 in my installation):
<?php _e(’<p>The following comments are in the moderation queue:</p>’) ?>
Here is the code to add.
<script type="text/javascript">
<!--
function bulkSelect( action )
{
form = document.approval;
for ( i = 0; i < form.elements.length; i++ )
{
if ( form.elements[ i ].type == "radio" &&
form.elements[ i ].value == action )
{
form.elements[ i ].checked = true;
}
}
}
//-->
</script>
Select
<a href="javascript:bulkSelect('approve')">approve</a> |
<a href="javascript:bulkSelect('delete')">delete</a> |
<a href="javascript:bulkSelect('later')">do nothing</a> on all comments