Send comment notification emails via a hooked function.
Previously, `wp_notify_postauthor()` and `wp_notify_moderator()` were called directly from `wp_new_comment()`, making it difficult to modify or suppress default notification emails. Props dshanske, thomaswm. See #33587. Built from https://develop.svn.wordpress.org/trunk@34106 git-svn-id: http://core.svn.wordpress.org/trunk@34074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
373d73f781
commit
c614849786
|
@ -1629,21 +1629,42 @@ 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 );
|
||||
}
|
||||
|
||||
// wp_notify_postauthor() checks if notifying the author of their own comment.
|
||||
// By default, it won't, but filters can override this.
|
||||
if ( get_option( 'comments_notify' ) && $commentdata['comment_approved'] ) {
|
||||
wp_notify_postauthor( $comment_ID );
|
||||
}
|
||||
}
|
||||
|
||||
return $comment_ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a comment moderation notification to the comment moderator.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $comment_ID ID of the comment.
|
||||
* @param int $comment_approved Whether the comment is approved.
|
||||
*/
|
||||
function wp_new_comment_notify_moderator( $comment_ID, $comment_approved ) {
|
||||
if ( '0' == $comment_approved ) {
|
||||
wp_notify_moderator( $comment_ID );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a notification of a new comment to the post author.
|
||||
*
|
||||
* @since 4.4.0
|
||||
*
|
||||
* @param int $comment_ID ID of the comment.
|
||||
*/
|
||||
function wp_new_comment_notify_postauthor( $comment_ID ) {
|
||||
$comment = get_comment( $comment_ID );
|
||||
|
||||
/*
|
||||
* `wp_notify_postauthor()` checks if notifying the author of their own comment.
|
||||
* By default, it won't, but filters can override this.
|
||||
*/
|
||||
if ( get_option( 'comments_notify' ) && $comment->comment_approved ) {
|
||||
wp_notify_postauthor( $comment_ID );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the status of a comment.
|
||||
*
|
||||
|
|
|
@ -334,6 +334,10 @@ add_action( 'split_shared_term', '_wp_check_split_terms_in_menus', 10, 4 );
|
|||
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_postauthor' );
|
||||
|
||||
/**
|
||||
* Filters formerly mixed into wp-includes
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.4-alpha-34105';
|
||||
$wp_version = '4.4-alpha-34106';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue