Changeset 34250
- Timestamp:
- 09/16/2015 09:59:16 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/comment-functions.php
r34161 r34250 1649 1649 * @param int $comment_ID ID of the comment. 1650 1650 * @param int $comment_approved Whether the comment is approved. 1651 * @return bool True on success, false on failure. 1651 1652 */ 1652 1653 function wp_new_comment_notify_moderator( $comment_ID, $comment_approved ) { 1653 if ( '0' == $comment_approved ) { 1654 wp_notify_moderator( $comment_ID ); 1655 } 1654 // Only send notifications for pending comments. 1655 if ( '0' != $comment_approved ) { 1656 return false; 1657 } 1658 1659 return wp_notify_moderator( $comment_ID ); 1656 1660 } 1657 1661 … … 1662 1666 * 1663 1667 * @param int $comment_ID ID of the comment. 1668 * @return bool True on success, false on failure. 1664 1669 */ 1665 1670 function wp_new_comment_notify_postauthor( $comment_ID ) { … … 1670 1675 * By default, it won't, but filters can override this. 1671 1676 */ 1672 if ( get_option( 'comments_notify' ) && $comment->comment_approved ) { 1673 wp_notify_postauthor( $comment_ID ); 1674 } 1677 if ( ! get_option( 'comments_notify' ) ) { 1678 return false; 1679 } 1680 1681 // Only send notifications for approved comments. 1682 if ( 'spam' === $comment->comment_approved || ! $comment->comment_approved ) { 1683 return false; 1684 } 1685 1686 return wp_notify_postauthor( $comment_ID ); 1675 1687 } 1676 1688 -
trunk/tests/phpunit/tests/comment.php
r34172 r34250 260 260 $this->assertTrue( wp_notify_moderator( $c ) ); 261 261 } 262 263 /** 264 * @ticket 33587 265 */ 266 public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_marked_as_spam() { 267 $p = $this->factory->post->create(); 268 $c = $this->factory->comment->create( array( 269 'comment_post_ID' => $p, 270 'comment_approved' => 'spam', 271 ) ); 272 273 $sent = wp_new_comment_notify_postauthor( $c ); 274 $this->assertFalse( $sent ); 275 } 262 276 }
Note: See TracChangeset
for help on using the changeset viewer.