diff --git src/wp-includes/comment.php src/wp-includes/comment.php
index a84f0a7..2a94ec1 100644
|
|
function wp_new_comment_notify_postauthor( $comment_ID ) { |
1802 | 1802 | } |
1803 | 1803 | |
1804 | 1804 | // Only send notifications for approved comments. |
1805 | | if ( ! isset( $comment->comment_approved ) || 'spam' === $comment->comment_approved || ! $comment->comment_approved ) { |
| 1805 | if ( ! isset( $comment->comment_approved ) || '1' != $comment->comment_approved ) { |
1806 | 1806 | return false; |
1807 | 1807 | } |
1808 | 1808 | |
diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php
index 844e4d1..8386881 100644
|
|
class Tests_Comment extends WP_UnitTestCase { |
293 | 293 | $this->assertTrue( wp_notify_moderator( $c ) ); |
294 | 294 | } |
295 | 295 | |
| 296 | public function test_wp_new_comment_notify_postauthor_should_send_email_when_comment_is_approved() { |
| 297 | $c = self::factory()->comment->create( array( |
| 298 | 'comment_post_ID' => self::$post_id, |
| 299 | ) ); |
| 300 | |
| 301 | $sent = wp_new_comment_notify_postauthor( $c ); |
| 302 | $this->assertTrue( $sent ); |
| 303 | } |
| 304 | |
| 305 | public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_is_unapproved() { |
| 306 | $c = self::factory()->comment->create( array( |
| 307 | 'comment_post_ID' => self::$post_id, |
| 308 | 'comment_approved' => '0', |
| 309 | ) ); |
| 310 | |
| 311 | $sent = wp_new_comment_notify_postauthor( $c ); |
| 312 | $this->assertFalse( $sent ); |
| 313 | } |
| 314 | |
296 | 315 | /** |
297 | 316 | * @ticket 33587 |
298 | 317 | */ |
… |
… |
class Tests_Comment extends WP_UnitTestCase { |
307 | 326 | } |
308 | 327 | |
309 | 328 | /** |
| 329 | * @ticket 35006 |
| 330 | */ |
| 331 | public function test_wp_new_comment_notify_postauthor_should_not_send_email_when_comment_has_been_trashed() { |
| 332 | $c = self::factory()->comment->create( array( |
| 333 | 'comment_post_ID' => self::$post_id, |
| 334 | 'comment_approved' => 'trash', |
| 335 | ) ); |
| 336 | |
| 337 | $sent = wp_new_comment_notify_postauthor( $c ); |
| 338 | $this->assertFalse( $sent ); |
| 339 | } |
| 340 | |
| 341 | /** |
310 | 342 | * @ticket 12431 |
311 | 343 | */ |
312 | 344 | public function test_wp_new_comment_with_meta() { |