Send comment approval notification to post author via hook.

This is part of the project of #33587.

Moving this particular message to the
'wp_set_comment_status' action has the added bonus that the notification is
sent after the comment status has been updated in the database. Previously, a
database error could lead to a case where an approval notification is sent,
but the comment status change fails for some reason.

Props mrmist, NickDuncan.
Fixes #14078.
Built from https://develop.svn.wordpress.org/trunk@34537


git-svn-id: http://core.svn.wordpress.org/trunk@34501 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2015-09-25 05:37:25 +00:00
parent cb586896c6
commit eaaabd4105
2 changed files with 2 additions and 4 deletions

View File

@ -1770,9 +1770,7 @@ function wp_set_comment_status($comment_id, $comment_status, $wp_error = false)
case 'approve': case 'approve':
case '1': case '1':
$status = '1'; $status = '1';
if ( get_option('comments_notify') ) { add_action( 'wp_set_comment_status', 'wp_new_comment_notify_postauthor' );
wp_notify_postauthor( $comment_id );
}
break; break;
case 'spam': case 'spam':
$status = 'spam'; $status = 'spam';

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.4-alpha-34536'; $wp_version = '4.4-alpha-34537';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.