From 03ec7cc10784c18ead7452d04728b5abdf902fca Mon Sep 17 00:00:00 2001 From: Boone Gorges Date: Wed, 16 Sep 2015 22:25:07 +0000 Subject: [PATCH] Improve consistency of comment notification callback signatures. Both `wp_new_comment_notify_moderator()` and `wp_new_comment_notify_postauthor()` now accept a single argument: `$comment_ID`. Props SergeyBiryukov. Fixes #33587. git-svn-id: https://develop.svn.wordpress.org/trunk@34252 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/comment-functions.php | 9 +++++---- src/wp-includes/default-filters.php | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/comment-functions.php b/src/wp-includes/comment-functions.php index 2de0322865..155e7b4da0 100644 --- a/src/wp-includes/comment-functions.php +++ b/src/wp-includes/comment-functions.php @@ -1646,13 +1646,14 @@ function wp_new_comment( $commentdata ) { * * @since 4.4.0 * - * @param int $comment_ID ID of the comment. - * @param int $comment_approved Whether the comment is approved. + * @param int $comment_ID ID of the comment. * @return bool True on success, false on failure. */ -function wp_new_comment_notify_moderator( $comment_ID, $comment_approved ) { +function wp_new_comment_notify_moderator( $comment_ID ) { + $comment = get_comment( $comment_ID ); + // Only send notifications for pending comments. - if ( '0' != $comment_approved ) { + if ( '0' != $comment->comment_approved ) { return false; } diff --git a/src/wp-includes/default-filters.php b/src/wp-includes/default-filters.php index 4081be43c1..f9fd9c47c9 100644 --- a/src/wp-includes/default-filters.php +++ b/src/wp-includes/default-filters.php @@ -336,7 +336,7 @@ add_action( 'split_shared_term', '_wp_check_split_nav_menu_terms', 10, 4 ); add_action( 'wp_split_shared_term_batch', '_wp_batch_split_terms' ); // Email notifications. -add_action( 'comment_post', 'wp_new_comment_notify_moderator', 10, 2 ); +add_action( 'comment_post', 'wp_new_comment_notify_moderator' ); add_action( 'comment_post', 'wp_new_comment_notify_postauthor' ); add_action( 'after_password_reset', 'wp_password_change_notification' ); add_action( 'register_new_user', 'wp_send_new_user_notifications' );