Make WordPress Core


Ignore:
Timestamp:
02/11/2005 01:52:19 AM (20 years ago)
Author:
saxmatt
Message:

Excellent spam moderation patch from CarLBanks - http://mosquito.wordpress.org/view.php?id=835

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/moderation.php

    r2233 r2258  
    55$parent_file = 'edit.php';
    66
    7 $wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'feelinglucky');
     7$wpvarstoreset = array('action', 'item_ignored', 'item_deleted', 'item_approved', 'item_spam', 'feelinglucky');
    88for ($i=0; $i<count($wpvarstoreset); $i += 1) {
    99    $wpvar = $wpvarstoreset[$i];
     
    3939    $item_deleted = 0;
    4040    $item_approved = 0;
    41    
     41    $item_spam = 0;
     42
    4243    foreach($comment as $key => $value) {
    4344    if ($feelinglucky && 'later' == $value)
     
    4950                ++$item_ignored;
    5051                break;
    51            
    5252            case 'delete':
    5353                wp_set_comment_status($key, 'delete');
    5454                ++$item_deleted;
    5555                break;
    56            
     56            case 'spam':
     57                wp_set_comment_status($key, 'spam');
     58                ++$item_spam;
     59                break;
    5760            case 'approve':
    5861                wp_set_comment_status($key, 'approve');
    59                 if (get_settings('comments_notify') == true) {
     62                if ( get_settings('comments_notify') == true ) {
    6063                    wp_notify_postauthor($key);
    6164                }
     
    6669
    6770    $file = basename(__FILE__);
    68     header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved");
     71    header("Location: $file?ignored=$item_ignored&deleted=$item_deleted&approved=$item_approved&spam=$item_spam");
    6972    exit();
    7073
     
    7881    echo "<div class='updated'>\n<p>";
    7982    $approved = (int) $_GET['approved'];
    80     $deleted = (int) $_GET['deleted'];
    81     $ignored = (int) $_GET['ignored'];
     83    $deleted  = (int) $_GET['deleted'];
     84    $ignored  = (int) $_GET['ignored'];
     85    $spam     = (int) $_GET['spam'];
    8286    if ($approved) {
    8387        if ('1' == $approved) {
     
    9498        }
    9599    }
     100    if ($spam) {
     101        if ('1' == $spam) {
     102        echo __("1 comment marked as spam <br />") . "\n";
     103        } else {
     104        echo sprintf(__("%s comments marked as spam <br />"), $spam) . "\n";
     105        }
     106    }
    96107    if ($ignored) {
    97108        if ('1' == $ignored) {
     
    140151echo " <a href=\"post.php?action=deletecomment&amp;p=".$comment->comment_post_ID."&amp;comment=".$comment->comment_ID."\" onclick=\"return confirm('" . sprintf(__("You are about to delete this comment by \'%s\'\\n  \'Cancel\' to stop, \'OK\' to delete."), $comment->comment_author) . "')\">" . __('Delete just this comment') . "</a> | "; ?>  <?php _e('Bulk action:') ?>
    141152    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-approve" value="approve" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-approve"><?php _e('Approve') ?></label>
     153    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-spam" value="spam" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-spam"><?php _e('Spam') ?></label>
    142154    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-delete" value="delete" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-delete"><?php _e('Delete') ?></label>
    143155    <input type="radio" name="comment[<?php echo $comment->comment_ID; ?>]" id="comment[<?php echo $comment->comment_ID; ?>]-nothing" value="later" checked="checked" /> <label for="comment[<?php echo $comment->comment_ID; ?>]-nothing"><?php _e('Defer until later') ?></label>
     
    174186    }
    175187}
    176 document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>');
     188function markAllAsSpam() {
     189    for (var i=0; i< document.approval.length; i++) {
     190        if (document.approval[i].value == "spam") {
     191            document.approval[i].checked = true;
     192        }
     193    }
     194}
     195document.write('<ul><li><a href="javascript:markAllForApprove()"><?php _e('Mark all for approval'); ?></a></li><li><a href="javascript:markAllAsSpam()"><?php _e('Mark all as spam'); ?></a></li><li><a href="javascript:markAllForDelete()"><?php _e('Mark all for deletion'); ?></a></li><li><a href="javascript:markAllForDefer()"><?php _e('Mark all for later'); ?></a></li></ul>');
    177196// ]]>
    178197</script>
Note: See TracChangeset for help on using the changeset viewer.