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-includes/comment-functions.php

    r2239 r2258  
    569569
    570570
    571 /* wp_set_comment_status:
    572    part of otaku42's comment moderation hack
    573    changes the status of a comment according to $comment_status.
    574    allowed values:
    575    hold   : set comment_approve field to 0
    576    approve: set comment_approve field to 1
    577    delete : remove comment out of database
    578    
    579    returns true if change could be applied
    580    returns false on database error or invalid value for $comment_status
    581  */
    582571function wp_set_comment_status($comment_id, $comment_status) {
    583572    global $wpdb;
     
    590579            $query = "UPDATE $wpdb->comments SET comment_approved='1' WHERE comment_ID='$comment_id' LIMIT 1";
    591580        break;
     581        case 'spam':
     582            $query = "UPDATE $wpdb->comments SET comment_approved='spam' WHERE comment_ID='$comment_id' LIMIT 1";
     583        break;
    592584        case 'delete':
    593585            $query = "DELETE FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1";
     
    606598
    607599
    608 /* wp_get_comment_status
    609    part of otaku42's comment moderation hack
    610    gets the current status of a comment
    611 
    612    returned values:
    613    "approved"  : comment has been approved
    614    "unapproved": comment has not been approved
    615    "deleted   ": comment not found in database
    616 
    617    a (boolean) false signals an error
    618  */
    619600function wp_get_comment_status($comment_id) {
    620     global $wpdb;
    621    
    622     $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
    623     if ($result == NULL) {
    624         return "deleted";
    625     } else if ($result == "1") {
    626         return "approved";
    627     } else if ($result == "0") {
    628         return "unapproved";
    629     } else {
    630         return false;
    631     }
     601    global $wpdb;
     602   
     603    $result = $wpdb->get_var("SELECT comment_approved FROM $wpdb->comments WHERE comment_ID='$comment_id' LIMIT 1");
     604    if ($result == NULL) {
     605        return 'deleted';
     606    } else if ($result == '1') {
     607        return 'approved';
     608    } else if ($result == '0') {
     609        return 'unapproved';
     610    } else if ($result == 'spam') {
     611        return 'spam';
     612    } else {
     613        return false;
     614    }
    632615}
    633616
Note: See TracChangeset for help on using the changeset viewer.