Guest User

Untitled

a guest
Jul 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?
  2.  
  3. function wp_new_comment( $commentdata ) {
  4. $commentdata = apply_filters('preprocess_comment', $commentdata);
  5.  
  6. $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
  7. $commentdata['user_ID'] = (int) $commentdata['user_ID'];
  8.  
  9. $commentdata['comment_parent'] = absint($commentdata['comment_parent']);
  10. $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
  11. $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
  12.  
  13. $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
  14. $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
  15.  
  16. $commentdata['comment_date'] = current_time('mysql');
  17. $commentdata['comment_date_gmt'] = current_time('mysql', 1);
  18.  
  19. $commentdata = wp_filter_comment($commentdata);
  20.  
  21. $commentdata['comment_approved'] = wp_allow_comment($commentdata);
  22.  
  23. $comment_ID = wp_insert_comment($commentdata);
  24.  
  25. do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
  26.  
  27. if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
  28. if ( '0' == $commentdata['comment_approved'] )
  29. wp_notify_moderator($comment_ID);
  30.  
  31. $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
  32.  
  33. if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] )
  34. wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
  35. }
  36.  
  37. return $comment_ID;
  38. }
Add Comment
Please, Sign In to add comment