Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function wp_new_comment( $commentdata ) {
- $commentdata = apply_filters('preprocess_comment', $commentdata);
- $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
- $commentdata['user_ID'] = (int) $commentdata['user_ID'];
- $commentdata['comment_parent'] = absint($commentdata['comment_parent']);
- $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
- $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
- $commentdata['comment_author_IP'] = preg_replace( '/[^0-9a-fA-F:., ]/', '',$_SERVER['REMOTE_ADDR'] );
- $commentdata['comment_agent'] = $_SERVER['HTTP_USER_AGENT'];
- $commentdata['comment_date'] = current_time('mysql');
- $commentdata['comment_date_gmt'] = current_time('mysql', 1);
- $commentdata = wp_filter_comment($commentdata);
- $commentdata['comment_approved'] = wp_allow_comment($commentdata);
- $comment_ID = wp_insert_comment($commentdata);
- do_action('comment_post', $comment_ID, $commentdata['comment_approved']);
- if ( 'spam' !== $commentdata['comment_approved'] ) { // If it's spam save it silently for later crunching
- if ( '0' == $commentdata['comment_approved'] )
- wp_notify_moderator($comment_ID);
- $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
- if ( get_option('comments_notify') && $commentdata['comment_approved'] && $post->post_author != $commentdata['user_ID'] )
- wp_notify_postauthor($comment_ID, $commentdata['comment_type']);
- }
- return $comment_ID;
- }
Add Comment
Please, Sign In to add comment