/** * Email Download Purchase Receipt * * Email the download link(s) and payment confirmation to the buyer. * * @access private * @since 1.0 * @return void */ function edd_email_purchase_receipt($payment_id, $admin_notice = true) { global $edd_options; $payment_data = edd_get_payment_meta($payment_id); $user_info = maybe_unserialize($payment_data['user_info']); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $message = edd_get_email_body_header(); $message .= edd_get_email_body_content($payment_id, $payment_data); $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 = isset($edd_options['purchase_subject']) && strlen(trim($edd_options['purchase_subject'])) > 0 ? edd_email_template_tags($edd_options['purchase_subject'], $payment_data, $payment_id) : __('Purchase Receipt', 'edd'); $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"; // allow add-ons to add file attachments $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); wp_mail($payment_data['email'], $subject, $message, $headers, $attachments); if ($admin_notice) { /* send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data); $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $download_list .= html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $admin_message .= __('Thank you', 'edd'); $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data); $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data); $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments); } }
private function mail_results($result) { global $edd_options; /* Send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $admin_message = edd_get_email_body_header(); $admin_message .= __('Hello! A payment was just triggered to mass pay all vendors their due commission.', 'eddc') . PHP_EOL . PHP_EOL; $admin_message .= sprintf(__('Payment status: %s.', 'eddc'), $result['status']) . PHP_EOL; $admin_message .= sprintf(__('Payment message: %s.', 'eddc'), $result['msg']) . PHP_EOL; if (!empty($result['total'])) { $admin_message .= sprintf(__('Payment total: %s.', 'eddc'), $result['total']); } $admin_message .= edd_get_email_body_footer(); $admin_subject = __('EDD Commissions: Mass payments for vendors update', 'eddc'); $admin_subject = apply_filters('eddc_admin_commissions_payout_notification_subject', $admin_subject, $result); $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'); $admin_headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $admin_headers .= "Reply-To: " . $from_email . "\r\n"; $admin_headers .= "MIME-Version: 1.0\r\n"; $admin_headers .= "Content-Type: text/html; charset=utf-8\r\n"; $admin_headers .= apply_filters('eddc_admin_commissions_payout_notification_headers', $admin_headers, $result); $sent = wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers); return $sent; }
function submit_submission_form($id = 0, $values = array(), $args = array()) { if (is_admin() && (!isset($_REQUEST['_wpnonce']) || !wp_verify_nonce($_REQUEST['_wpnonce'], 'fes-form-submission-form'))) { return; } global $edd_options; check_ajax_referer('fes-form-submission-form'); @header('Content-Type: application/json; charset=' . get_option('blog_charset')); $form_id = isset($_POST['form_id']) ? intval($_POST['form_id']) : 0; $db_form_id = EDD_FES()->helper->get_option('fes-submission-form', false); if ($form_id != $db_form_id) { $response = array('success' => false, 'redirect_to' => get_permalink($_POST['page_id']), 'message' => __('Access Denied: ' . $form_id . ' != ' . $db_form_id, 'edd_fes'), 'is_post' => true); echo json_encode($response); exit; } if (!$id && isset($_REQUEST['post_id']) && absint($_REQUEST['post_id'])) { $id = absint($_REQUEST['post_id']); } $user_id = get_current_user_id(); $is_vendor = EDD_FES()->vendors->vendor_is_vendor($user_id); $is_admin = EDD_FES()->vendors->vendor_is_admin($user_id); // if they are not a vendor, admin, or in the backend if (!$is_admin && !is_admin() && !$is_vendor) { $response = array('success' => false, 'redirect_to' => get_permalink($_POST['page_id']), 'message' => __('Access Denied', 'edd_fes'), 'is_post' => true); echo json_encode($response); exit; } if ($id) { $post = get_post($id); $post_author = $post->post_author; // if they are not admin, in the admin, or the author of the post if (!$is_admin && !is_admin() && $id !== 0 && $post_author !== $user_id) { $response = array('success' => false, 'redirect_to' => get_permalink($_POST['page_id']), 'message' => __('Access Denied', 'edd_fes'), 'is_post' => true); echo json_encode($response); exit; } } $form_vars = $this->get_input_fields($form_id); $form_settings = get_post_meta($form_id, 'fes-form_settings', true); list($post_vars, $taxonomy_vars, $meta_vars) = $form_vars; // don't check captcha on post edit if (!$id) { // check recaptcha if ($this->search_array($post_vars, 'input_type', 'recaptcha')) { $this->validate_re_captcha(); } } $error = apply_filters('fes_submit_post_validate', '', $form_id); if (!empty($error)) { $this->signal_error($error); } $pending = false; $new = true; $post_id = $id; if (!empty($post->post_status) && 'publish' != $post->post_status) { $status = $post->post_status; } else { $status = 'publish'; } // already existing product if ($id && is_object(get_post($id))) { $new = false; $post_id = $id; if (!EDD_FES()->helper->get_option('fes-auto-approve-edits', false)) { $pending = true; $status = 'pending'; } } else { if (!EDD_FES()->helper->get_option('fes-auto-approve-submissions', false)) { $pending = true; $status = 'pending'; } } $post_author = get_current_user_id(); $postarr = array('post_type' => 'download', 'post_status' => $status, 'post_author' => $post_author, 'post_title' => isset($_POST['post_title']) ? sanitize_text_field(trim($_POST['post_title'])) : '', 'post_content' => isset($_POST['post_content']) ? wp_kses($_POST['post_content'], fes_allowed_html_tags()) : '', 'post_excerpt' => isset($_POST['post_excerpt']) ? wp_kses($_POST['post_excerpt'], fes_allowed_html_tags()) : ''); if (isset($_POST['category'])) { $category = $_POST['category']; $postarr['post_category'] = is_array($category) ? $category : array($category); } if (isset($_POST['tags'])) { $postarr['tags_input'] = explode(',', $_POST['tags']); } $postarr = apply_filters('fes_add_post_args', $postarr, $form_id, $form_settings, $form_vars); if ($new) { $post_id = wp_insert_post($postarr); } else { $postarr['ID'] = $post_id; wp_update_post($postarr); } if ($post_id) { self::update_post_meta($meta_vars, $post_id); // set the post form_id for later usage update_post_meta($post_id, '_fes-form_id', $form_id); // find our if any images in post content and associate them if (!empty($postarr['post_content'])) { $dom = new DOMDocument(); $dom->loadHTML($postarr['post_content']); $images = $dom->getElementsByTagName('img'); if ($images->length) { foreach ($images as $img) { $url = $img->getAttribute('src'); $url = str_replace(array('"', "'", "\\"), '', $url); $attachment_id = fes_get_attachment_id_from_url($url, $post_author); if ($attachment_id) { fes_associate_attachment($attachment_id, $post_id); } } } } foreach ($taxonomy_vars as $taxonomy) { if (isset($_POST[$taxonomy['name']])) { if (is_object_in_taxonomy('download', $taxonomy['name'])) { $tax = $_POST[$taxonomy['name']]; // if it's not an array, make it one if (!is_array($tax)) { $tax = array($tax); } if ($taxonomy['type'] == 'text') { $hierarchical = array_map('trim', array_map('strip_tags', explode(',', $_POST[$taxonomy['name']]))); wp_set_object_terms($post_id, $hierarchical, $taxonomy['name']); } else { if (is_taxonomy_hierarchical($taxonomy['name'])) { wp_set_post_terms($post_id, $_POST[$taxonomy['name']], $taxonomy['name']); } else { if ($tax) { $non_hierarchical = array(); foreach ($tax as $value) { $term = get_term_by('id', $value, $taxonomy['name']); if ($term && !is_wp_error($term)) { $non_hierarchical[] = $term->name; } } wp_set_post_terms($post_id, $non_hierarchical, $taxonomy['name']); } } // hierarchical } // is text } // is object tax } // isset tax } $options = isset($_POST['option']) ? $_POST['option'] : ''; $files = isset($_POST['files']) ? $_POST['files'] : ''; $prices = array(); $edd_files = array(); if (isset($options) && $options != '') { foreach ($options as $key => $option) { $prices[] = array('name' => isset($option['description']) ? sanitize_text_field($option['description']) : '', 'amount' => isset($option['price']) ? $option['price'] : ''); } if (!empty($files)) { foreach ($files as $key => $url) { $edd_files[$key] = array('name' => basename($url), 'file' => $url, 'condition' => $key); } } } elseif (!empty($files)) { // For when there are no prices or option names allowed, https://github.com/chriscct7/edd-fes/issues/417 foreach ($files as $key => $url) { $edd_files[$key] = array('name' => basename($url), 'file' => $url, 'condition' => $key); } } do_action('fes_submission_form_save_custom_fields', $post_id); if (count($prices) === 1 || count($prices) === 0) { if (!isset($prices[0]['amount'])) { $prices[0]['amount'] = ""; } update_post_meta($post_id, '_variable_pricing', 0); update_post_meta($post_id, 'edd_price', $prices[0]['amount']); update_post_meta($post_id, 'edd_variable_prices', $prices); // Save variable prices anyway so that price options are saved } else { update_post_meta($post_id, '_variable_pricing', 1); update_post_meta($post_id, 'edd_variable_prices', $prices); if (EDD_FES()->helper->get_option('fes-allow-multiple-purchase-mode', false)) { update_post_meta($post_id, '_edd_price_options_mode', '1'); } } if (!empty($files)) { $edd_files = apply_filters('fes_pre_files_save', $edd_files, $post_id); update_post_meta($post_id, 'edd_download_files', $edd_files); } if (EDD_FES()->integrations->is_commissions_active() && $new === true) { $commission = array('amount' => eddc_get_recipient_rate(0, $post_author), 'user_id' => $post_author, 'type' => 'percentage'); update_post_meta($post_id, '_edd_commission_settings', $commission); update_post_meta($post_id, '_edd_commisions_enabled', '1'); } do_action('fes_submit_submission_form_bottom', $post_id); $redirect_to = get_permalink(EDD_FES()->helper->get_option('fes-vendor-dashboard-page', false)); if (EDD_FES()->vendors->vendor_can_edit_product($post_id)) { $redirect_to = add_query_arg(array('task' => 'edit-product'), $redirect_to); $redirect_to = add_query_arg(array('post_id' => $post_id), $redirect_to); } else { $redirect_to = add_query_arg(array('task' => 'dashboard'), $redirect_to); } // Unset edd session EDD()->session->set('edd_fes_post_id', ''); if ($new) { if ($pending) { // email admin $to = apply_filters('fes_submission_form_pending_to_admin', edd_get_admin_notice_emails(), $post_id); $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('fes_submission_form_to_admin_subject', __('New Submission Received', 'edd_fes')); $message = EDD_FES()->helper->get_option('fes-admin-new-submission-email', ''); $type = "post"; $id = $post_id; $args = array('permissions' => 'fes-admin-new-submission-email-toggle'); EDD_FES()->emails->send_email($to, $from_name, $from_email, $subject, $message, $type, $id, $args); // email user $user = new WP_User($user_id); $to = $user->user_email; $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('fes_submission_new_form_to_vendor_subject', __('Submission Received', 'edd_fes')); $message = EDD_FES()->helper->get_option('fes-vendor-new-submission-email', ''); $type = "post"; $id = $post_id; $args = array('permissions' => 'fes-vendor-new-submission-email-toggle'); EDD_FES()->emails->send_email($to, $from_name, $from_email, $subject, $message, $type, $id, $args); do_action('fes_submission_form_new_pending', $post_id); } else { do_action('fes_submission_form_new_published', $post_id); } } else { // submission heading to pending if ($pending) { // email admin $to = apply_filters('fes_submission_form_published_to_admin', edd_get_admin_notice_emails(), $post_id); $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('fes_submission_form_edit_to_admin_subject', __('New Submission Edit Received', 'edd_fes')); $message = EDD_FES()->helper->get_option('fes-admin-new-submission-edit-email', ''); $type = "post"; $id = $post_id; $args = array('permissions' => 'fes-admin-new-submission-edit-email-toggle'); EDD_FES()->emails->send_email($to, $from_name, $from_email, $subject, $message, $type, $id, $args); do_action('fes_submission_form_edit_pending', $post_id); } else { do_action('fes_submission_form_edit_published', $post_id); } } $response = array('success' => true, 'redirect_to' => $redirect_to, 'message' => __('Success!', 'edd_fes'), 'is_post' => true); $response = apply_filters('fes_add_post_redirect', $response, $post_id, $form_id); echo json_encode($response); exit; } else { $this->signal_error(__('Something went wrong! Error 1049: Post ID not set. Possibly Database lock in place.', 'edd_fes')); } }
/** * Sends the Admin Sale Notification Email * * @since 1.4.2 * @param int $payment_id Payment ID (default: 0) * @param array $payment_data Payment Meta and Data * @return void */ function edd_admin_email_notice($payment_id = 0, $payment_data = array()) { $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('edd_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = edd_get_option('from_name', get_bloginfo('admin_email')); $from_email = apply_filters('edd_purchase_from_address', $from_email, $payment_id, $payment_data); $subject = edd_get_option('sale_notification_subject', sprintf(__('New download purchase - Order #%1$s', 'edd'), $payment_id)); $subject = apply_filters('edd_admin_sale_notification_subject', wp_strip_all_tags($subject), $payment_id); $subject = edd_do_email_tags($subject, $payment_id); $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_admin_sale_notification_headers', $headers, $payment_id, $payment_data); $attachments = apply_filters('edd_admin_sale_notification_attachments', array(), $payment_id, $payment_data); $message = edd_get_sale_notification_body_content($payment_id, $payment_data); $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('headers', $headers); $emails->__set('heading', __('New Sale!', 'edd')); $emails->send(edd_get_admin_notice_emails(), $subject, $message, $attachments); }
/** * Our custom admin email function * * @since 1.0.0 * @param int $id The ID of a payment if user email, or the wallet user if admin email * @param int $item The wallet line item we are sending this for * @return void */ function edd_wallet_send_admin_email($id = 0, $item = null) { $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_email = edd_get_option('from_email', get_bloginfo('admin_email')); $payment_data = edd_get_payment_meta($id); $from_name = apply_filters('edd_purchase_from_name', $from_name, $id, $payment_data); $from_email = apply_filters('edd_purchase_from_address', $from_email, $id, $payment_data); $subject = edd_get_option('wallet_admin_deposit_notification_subject', __('New deposit', 'edd-wallet')); $subject = apply_filters('edd_wallet_admin_deposit_notification_subject', wp_strip_all_tags($subject), $id); $subject = edd_wallet_do_email_tags($subject, $id); $message = edd_get_option('wallet_admin_deposit_notification', __('Hello', 'edd-wallet') . "\n\n" . __('A deposit has been made.', 'edd-wallet') . "\n\n" . __('Deposited to: {fullname}', 'edd-wallet') . "\n" . __('Amount: {value}', 'edd-wallet') . "\n\n" . __('Thank you', 'edd-wallet')); $message = edd_wallet_do_email_tags($message, $id); $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('heading', __('New Deposit!', 'edd-wallet')); $emails->send(edd_get_admin_notice_emails(), $subject, $message); }
private function notify_admins($email_id = 0, $author = OBJECT) { $subject = __('New Product Update Email Submitted', 'edd-fes-product-updates'); $message = sprintf(__('A new product update email has been submitted by a %s. Click <a href="%s">here</a> to review the email.', 'edd-fes-product-updates'), $author->display_name, admin_url('edit.php?post_type=download&page=edd-prod-updates&view=edit_pup_email&id=' . $email_id)); EDD()->emails->send(edd_get_admin_notice_emails(), $subject, $message); }
/** * 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); } }
/** * Admin notification */ function edd_pre_approval_emails_send_admin_email($payment_id = 0, $payment_data = array()) { $payment_id = absint($payment_id); // get payment data from payment ID $payment_data = edd_get_payment_meta($payment_id); if (empty($payment_id)) { return; } if (!edd_get_payment_by('id', $payment_id)) { return; } $from_name = edd_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('edd_purchase_from_name', $from_name, $payment_id, $payment_data); $from_email = edd_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('edd_purchase_from_address', $from_email, $payment_id, $payment_data); $subject = sprintf(__('New pledge - Order #%1$s', 'edd-pre-approval-emails'), $payment_id); $subject = wp_strip_all_tags($subject); $subject = edd_do_email_tags($subject, $payment_id); $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 .= "Content-Type: text/html; charset=utf-8\r\n"; $headers = apply_filters('edd_admin_pledge_notification_headers', $headers, $payment_id, $payment_data); $attachments = apply_filters('edd_admin_pledge_notification_attachments', array(), $payment_id, $payment_data); $message = edd_pre_approval_emails_get_admin_email_body($payment_id, $payment_data); if (class_exists('EDD_Emails')) { $emails = EDD()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('headers', $headers); $emails->__set('heading', __('New Pledge!', 'edd-pre-approval-emails')); $emails->send(edd_get_admin_notice_emails(), $subject, $message, $attachments); } }
/** * Sends a notice to site admins about the pending sale * * @since 1.1 * @return void */ function edd_cg_send_admin_notice($payment_id = 0) { /* Send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $user_info = edd_get_payment_meta_user_info($payment_id); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $amount = edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id))); $admin_subject = apply_filters('eddcg_admin_purchase_notification_subject', __('New pending purchase', 'eddcg'), $payment_id); $admin_message = __('Hello', 'eddcg') . "\n\n" . sprintf(__('A %s purchase has been made', 'eddcg'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'eddcg'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = edd_get_payment_meta_downloads($payment_id); if (is_array($downloads)) { foreach ($downloads as $download) { $title = get_the_title($download['id']); if (isset($download['options'])) { if (isset($download['options']['price_id'])) { $title .= ' - ' . edd_get_price_option_name($download['id'], $download['options']['price_id'], $payment_id); } } $download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n"; } } $order_url = admin_url('edit.php?post_type=download&page=edd-payment-history&edd-action=view-order-details&id=' . $payment_id); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'eddcg') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'eddcg') . " " . html_entity_decode($amount, ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('This is a pending purchase awaiting payment.', 'eddcg') . "\n\n"; $admin_message .= sprintf(__('View Order Details: %s.', 'eddcg'), $order_url) . "\n\n"; $admin_message = apply_filters('eddcg_admin_purchase_notification', $admin_message, $payment_id); $admin_headers = apply_filters('eddcg_admin_purchase_notification_headers', array(), $payment_id); $attachments = apply_filters('eddcg_admin_purchase_notification_attachments', array(), $payment_id); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $attachments); }
/** * Sends the Admin Sale Notification Email * * @since 1.4.2 * @param int $payment_id Payment ID (default: 0) * @param array $payment_data Payment Meta and Data * @return void */ function edd_admin_email_notice($payment_id = 0, $payment_data = array()) { /* Send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $user_info = maybe_unserialize($payment_data['user_info']); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data); $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $title = get_the_title($id); if (isset($download['options'])) { if (isset($download['options']['price_id'])) { $title .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id); } } $download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $admin_message .= __('Thank you', 'edd'); $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data); $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data); $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments); }