diff --git a/wp-includes/comment.php b/wp-includes/comment.php index e82e730a28..d4aea45cb8 100644 --- a/wp-includes/comment.php +++ b/wp-includes/comment.php @@ -1414,13 +1414,17 @@ function wp_new_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); + 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'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) - wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); + if ( get_option('comments_notify') && $commentdata['comment_approved'] ) { + $post = get_post( $commentdata['comment_post_ID'] ); + // Don't notify if it's your own comment + if ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) { + wp_notify_postauthor( $comment_ID ); + } + } } return $comment_ID; @@ -1453,8 +1457,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false) case '1': $status = '1'; if ( get_option('comments_notify') ) { - $comment = get_comment($comment_id); - wp_notify_postauthor($comment_id, $comment->comment_type); + wp_notify_postauthor( $comment_id ); } break; case 'spam': diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index bb18077393..a083079045 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1005,10 +1005,14 @@ if ( ! function_exists('wp_notify_postauthor') ) : * @since 1.0.0 * * @param int $comment_id Comment ID - * @param string $comment_type Optional. The comment type either 'comment' (default), 'trackback', or 'pingback' + * @param string $deprecated Not used * @return bool False if user email does not exist. True on completion. */ -function wp_notify_postauthor( $comment_id, $comment_type = '' ) { +function wp_notify_postauthor( $comment_id, $deprecated = null ) { + if ( null !== $deprecated ) { + _deprecated_argument( __FUNCTION__, '3.8' ); + } + $comment = get_comment( $comment_id ); if ( empty( $comment ) ) return false; @@ -1038,7 +1042,7 @@ function wp_notify_postauthor( $comment_id, $comment_type = '' ) { // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); - if ( empty( $comment_type ) ) $comment_type = 'comment'; + $comment_type = $comment->comment_type ? $comment->comment_type : 'comment'; switch ( $comment_type ) { case 'trackback':