WordPress.org

Make WordPress Core

Ticket #10931: 10931-2.diff

File 10931-2.diff, 2.1 KB (added by greuben, 3 years ago)
  • wp-comments-post.php

     
    8787 
    8888$commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID'); 
    8989 
     90$commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
     91$commentdata['comment_agent']     = substr($_SERVER['HTTP_USER_AGENT'], 0, 254); 
     92$commentdata['comment_date']     = current_time('mysql'); 
     93$commentdata['comment_date_gmt'] = current_time('mysql', 1); 
     94 
     95$comment_approved = wp_allow_comment($commentdata); 
     96if( !$user->ID && get_user_by( 'email', $comment_author_email ) && 'spam' !== $comment_approved ) 
     97        $comment_approved = 0; 
     98 
     99$commentdata['comment_approved'] = $comment_approved; 
     100 
    90101$comment_id = wp_new_comment( $commentdata ); 
    91102 
    92103$comment = get_comment($comment_id); 
  • wp-includes/comment.php

     
    13221322        $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : 0; 
    13231323        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : ''; 
    13241324        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0; 
    1325  
    1326         $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] ); 
    1327         $commentdata['comment_agent']     = substr($_SERVER['HTTP_USER_AGENT'], 0, 254); 
    1328  
    1329         $commentdata['comment_date']     = current_time('mysql'); 
    1330         $commentdata['comment_date_gmt'] = current_time('mysql', 1); 
    1331  
     1325         
    13321326        $commentdata = wp_filter_comment($commentdata); 
    13331327 
    1334         $commentdata['comment_approved'] = wp_allow_comment($commentdata); 
    1335  
    13361328        $comment_ID = wp_insert_comment($commentdata); 
    13371329 
    13381330        do_action('comment_post', $comment_ID, $commentdata['comment_approved']);