/** * Email the download link(s) and payment confirmation to the admin accounts for testing. * * @since 1.5 * @global $edd_options Array of all the EDD Options * @return void */ function edd_email_test_purchase_receipt() { global $edd_options; $default_email_body = __("Dear", "edd") . " {name},\n\n"; $default_email_body .= __("Thank you for your purchase. Please click on the link(s) below to download your files.", "edd") . "\n\n"; $default_email_body .= "{download_list}\n\n"; $default_email_body .= "{sitename}"; $email = isset($edd_options['purchase_receipt']) ? $edd_options['purchase_receipt'] : $default_email_body; $message = edd_get_email_body_header(); $message .= apply_filters('edd_purchase_receipt', edd_email_preview_templage_tags($email), 0, array()); $message .= edd_get_email_body_footer(); $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name'); $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email'); $subject = apply_filters('edd_purchase_subject', isset($edd_options['purchase_subject']) ? trim($edd_options['purchase_subject']) : __('Purchase Receipt', 'edd'), 0); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; $headers = apply_filters('edd_test_purchase_headers', $headers); wp_mail(edd_get_admin_notice_emails(), $subject, $message, $headers); }
/** * Applies the Chosen Email Template * * @since 1.0.8.2 * @param string $body The contents of the receipt email * @param int $payment_id The ID of the payment we are sending a receipt for * @param array $payment_data An array of meta information for the payment * @return string $email Formatted email with the template applied */ function edd_apply_email_template($body, $payment_id, $payment_data) { global $edd_options; $template_name = isset($edd_options['email_template']) ? $edd_options['email_template'] : 'default'; $template_name = apply_filters('edd_email_template', $template_name, $payment_id); if ($template_name == 'none') { if (is_admin()) { $body = edd_email_preview_templage_tags($body); } return $body; // Return the plain email with no template } ob_start(); do_action('edd_email_template_' . $template_name); $template = ob_get_clean(); if (is_admin()) { $body = edd_email_preview_templage_tags($body); } $body = apply_filters('edd_purchase_receipt_' . $template_name, $body); $email = str_replace('{email}', $body, $template); return $email; }
/** * Send test email * * @todo remove edd_email_preview_templage_tags() function check when EDD supports it * @since 1.0 */ function edd_ppe_test_purchase_receipt($receipt_id = 0) { global $pagenow, $typenow; $receipt = edd_ppe_get_receipt($receipt_id); // default email subject $default_email_subject = __("Thanks for purchasing {download_name}", "edd-ppe"); // default email body $default_email_body = __("Dear", "edd-ppe") . " {name},\n\n"; $default_email_body .= __("Thank you for purchasing {download_name}. Please click on the link(s) below to download your files.", "edd-ppe") . "\n\n"; $default_email_body .= "{download_list}\n\n"; $default_email_body .= "{sitename}"; // use new EDD 2.1 Email class if (class_exists('EDD_Emails')) { // we're on the main screen of edd receipts, get relevant subject and body for test email if (isset($_GET['page']) && 'edd-receipts' == $_GET['page'] && 'download' == $typenow && in_array($pagenow, array('edit.php'))) { $subject = $receipt->post_excerpt ? $receipt->post_excerpt : $default_email_subject; $body = $receipt->post_content ? $receipt->post_content : $default_email_body; } // run subject through email_preview_subject_template_tags() function $subject = apply_filters('edd_ppe_purchase_receipt_subject', edd_ppe_email_preview_subject_template_tags($subject, $receipt_id), 0, array()); // run subject through the standard EDD email tag function $subject = edd_do_email_tags($subject, 0); // message $message = apply_filters('edd_ppe_purchase_body', $receipt->post_content ? $receipt->post_content : $default_email_body); $message = edd_email_preview_template_tags($body, 0); // add download name as email heading. Off by default // will introduce a checkbox in admin to turn all headings on rather than turn them on now which may mess up emails if (apply_filters('edd_ppe_email_heading', false)) { EDD()->emails->__set('heading', get_the_title($product_id)); } EDD()->emails->send(edd_get_admin_notice_emails(), $subject, $message); } else { // we're on the main screen of edd receipts, get relevant subject and body for test email if (isset($_GET['page']) && 'edd-receipts' == $_GET['page'] && 'download' == $typenow && in_array($pagenow, array('edit.php'))) { $subject = $receipt->post_excerpt ? $receipt->post_excerpt : $default_email_subject; $body = $receipt->post_content ? $receipt->post_content : $default_email_body; } // run subject through email_preview_subject_template_tags() function $subject = apply_filters('edd_ppe_purchase_receipt_subject', edd_ppe_email_preview_subject_template_tags($subject, $receipt_id), 0, array()); $message = edd_get_email_body_header(); // will remove the edd_email_preview_templage_tags() function when new EDD version is released $message .= apply_filters('edd_purchase_receipt', function_exists('edd_email_preview_template_tags') ? edd_email_preview_template_tags($body) : edd_email_preview_templage_tags($body), null, null); $message .= edd_get_email_body_footer(); $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name'); $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email'); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; $headers = apply_filters('edd_test_purchase_headers', $headers); wp_mail(edd_get_admin_notice_emails(), $subject, $message, $headers); } }