Make WordPress Core

Ticket #761: 761.2.diff

File 761.2.diff, 2.6 KB (added by coffee2code, 12 years ago)

Patch to defer checks until wp_notify_postauthor()

  • wp-includes/comment.php

     
    13711371                if ( '0' == $commentdata['comment_approved'] )
    13721372                        wp_notify_moderator($comment_ID);
    13731373
    1374                 $post = get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment
    1375 
    1376                 if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) )
    1377                         wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
     1374                wp_notify_postauthor( $comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' );
    13781375        }
    13791376
    13801377        return $comment_ID;
     
    14061403                case 'approve':
    14071404                case '1':
    14081405                        $status = '1';
    1409                         if ( get_option('comments_notify') ) {
    1410                                 $comment = get_comment($comment_id);
    1411                                 wp_notify_postauthor($comment_id, $comment->comment_type);
    1412                         }
    14131406                        break;
    14141407                case 'spam':
    14151408                        $status = 'spam';
     
    14341427
    14351428        $comment = get_comment($comment_id);
    14361429
     1430        if ( '1' == $status )
     1431                wp_notify_postauthor( $comment_id, $comment->comment_type );
     1432
    14371433        do_action('wp_set_comment_status', $comment_id, $comment_status);
    14381434        wp_transition_comment_status($comment_status, $comment_old->comment_approved, $comment);
    14391435
  • wp-includes/pluggable.php

     
    980980 * Notify an author of a comment/trackback/pingback to one of their posts.
    981981 *
    982982 * @since 1.0.0
     983 * @uses apply_filters() Calls 'wp_notify_postauthor' hook on get_option('comments_notify') and comment_approved value before processing
    983984 *
    984985 * @param int $comment_id Comment ID
    985986 * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback'
     
    10021003        if ( '' == $author->user_email )
    10031004                return false;
    10041005
     1006        // Possibly notify if get_option( 'comments_notify' ) is true, comment is
     1007        // approved, and filter 'wp_notify_postauthor' doesn't override those values
     1008        $maybe_notify = get_option( 'comments_notify' ) && ( '1' == $comment->comment_approved );
     1009        $maybe_notify = apply_filters( 'wp_notify_postauthor', $maybe_notify, $comment );
     1010        if ( ! $maybe_notify )
     1011                return false;
     1012
    10051013        $comment_author_domain = @gethostbyaddr($comment->comment_author_IP);
    10061014
    10071015        // The blogname option is escaped with esc_html on the way into the database in sanitize_option