Skip to content

Commit

Permalink
Only display author upgrade message in local comment emails, fixes #92
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhobo committed Jan 27, 2017
1 parent c2f115d commit 5829372
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion core/email-batches/comment-email-batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
19 changes: 19 additions & 0 deletions tests/test-comment-email-batch.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ function testDefaultRecipient() {
$values['subject'],
'Expected subject to contain post title.'
);
$this->assertArrayNotHasKey( 'post_author_message', $values );
}

function testPostAuthorRecipient() {
Expand All @@ -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();
Expand Down

0 comments on commit 5829372

Please sign in to comment.