Skip to content

Commit

Permalink
refactor(admin-email): use send_preview_email fn to setup preview ema…
Browse files Browse the repository at this point in the history
…il data

ref #3517
  • Loading branch information
ravinderk committed Jul 24, 2018
1 parent b0db7ed commit 5bf0d8a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions includes/admin/emails/abstract-email-notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -684,8 +684,12 @@ public function get_email_attachments( $form_id = null ) {
*
* @since 2.0
* @access public
*
* @param bool $send Flag to check if send email or not.
*
* @return bool
*/
public function send_preview_email() {
public function send_preview_email( $send = true) {
// Get form id
$form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;

Expand Down Expand Up @@ -720,7 +724,9 @@ public function send_preview_email() {
Give()->emails->from_address = give_get_meta( $form_id, '_give_from_email', true );
}

return Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments );
return $send
? Give()->emails->send( $this->get_preview_email_recipient( $form_id ), $subject, $message, $attachments )
: false;
}


Expand Down
2 changes: 1 addition & 1 deletion includes/admin/emails/class-email-notifications.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public function preview_email() {
$form_id = empty( $_GET['form_id'] ) ? null : absint( $_GET['form_id'] );

// Call setup email data to apply filter and other thing to email.
$email->setup_email_data();
$email->send_preview_email( false );

// Decode message.
$email_message = $email->preview_email_template_tags( $email->get_email_message( $form_id ) );
Expand Down

0 comments on commit 5bf0d8a

Please sign in to comment.