Monday - October 25, 2004
bulk actions in wordpress comment moderation

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






# of readers
- home
meta
comics
news links
other links

about me
blog archives
docs
entertainment
experiences
funny lists
humor
intellectual
interests
mefi
music
opinions
photos
web designs
tools
webmaster help

Sign up
Enter your e-mail address to be notified of new posts



Search blog archives

Calendar
October 2004
S M T W T F S
« Sep   Nov »
 12
3456789
10111213141516
17181920212223
24252627282930
31  



Random quote
(View all quotes)
"It's not that I'm so smart, it's just that I stay with problems longer. -- Albert Einstein"










Licensed under Creative Commons
(?) Choose theme:  X X X X X X


W3CCSS
Loaded in 0.4192 seconds