From 58293723706181790011ed7d7080a4ece34cf3d0 Mon Sep 17 00:00:00 2001 From: Dylan Kuhn Date: Fri, 27 Jan 2017 13:55:42 -0800 Subject: [PATCH] Only display author upgrade message in local comment emails, fixes #92 --- core/email-batches/comment-email-batch.php | 2 +- tests/test-comment-email-batch.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/core/email-batches/comment-email-batch.php b/core/email-batches/comment-email-batch.php index b2b804a..1db8701 100644 --- a/core/email-batches/comment-email-batch.php +++ b/core/email-batches/comment-email-batch.php @@ -267,7 +267,7 @@ protected function add_recipient( WP_User $recipient ) { 'subscriber_comment_intro_text' => $this->subscriber_comment_intro_text( $recipient ), ); - if ( $recipient->ID == $this->prompt_post->get_wp_post()->post_author ) { + if ( ! Prompt_Core::is_api_transport() and $recipient->ID == $this->prompt_post->get_wp_post()->post_author ) { $values['post_author_message'] = html( 'div class="author_message" style="padding: 10px; background: #FFFBCC; font-weight: bold; margin: 15px 0; border-top: 1px dashed #ddd; border-bottom: 1px dashed #ddd; font-size: 11px;"', html( diff --git a/tests/test-comment-email-batch.php b/tests/test-comment-email-batch.php index 6c00ef5..153424a 100644 --- a/tests/test-comment-email-batch.php +++ b/tests/test-comment-email-batch.php @@ -68,6 +68,7 @@ function testDefaultRecipient() { $values['subject'], 'Expected subject to contain post title.' ); + $this->assertArrayNotHasKey( 'post_author_message', $values ); } function testPostAuthorRecipient() { @@ -87,6 +88,24 @@ function testPostAuthorRecipient() { $this->assertArrayHasKey( 'post_author_message', $values ); } + function testPostAuthorApiRecipient() { + Prompt_Core::$options->set( 'email_transport', Prompt_Enum_Email_Transports::API ); + Prompt_Core::$options->set( 'auto_subscribe_authors', true ); + + $author = $this->factory->user->create_and_get(); + $post_id = $this->factory->post->create( array( 'post_author' => $author->ID ) ); + $comment = $this->factory->comment->create_and_get( array( 'comment_post_ID' => $post_id ) ); + + $batch = new Prompt_Comment_Email_Batch( $comment ); + + $values = $batch->get_individual_message_values(); + $this->assertCount( 1, $values ); + + $values = $values[0]; + $this->assertEquals( $author->user_email, $values['to_address'], 'Expected author to address.' ); + $this->assertArrayNotHasKey( 'post_author_message', $values ); + } + function testPersonalizedSubject() { $post_id = $this->factory->post->create(); $parent_author = $this->factory->user->create_and_get();