public function send_recipient_email($name = '', $email = '', $gift_message = '', $payment_id = 0) { if (!class_exists('RCP_Discounts')) { return false; } global $edd_options; $db = new RCP_Discounts(); $site_name = get_bloginfo('name'); $discount = $db->get_by('code', md5($name . $email . $payment_id)); $subject = sprintf(__('Gift Certificate to %s', 'rcp-gifts'), $site_name); $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'); $body = '<p>' . __("Hello!", "rcp-gifts") . '</p>'; $body .= '<p>' . sprintf(__("Someone has gifted you a membership to %s", "rcp-gifts"), $site_name) . '</p>'; if (!empty($gift_message) && __('Enter the a message to send to the recipient', 'rcp-gifts') != $gift_message) { $body .= '<p>' . __("The following message was included with the gift: ", "rcp-gifts") . '</p>'; $body .= '<blockquote>' . $gift_message . '</blockquote>'; } $body .= '<p>' . sprintf(__("Enter %s during registration to redeem your gift.", "rcp-gifts"), $discount->code) . '</p>'; $body .= '<p>' . sprintf(__("Visit %s to claim your membership gift.", "rcp-gifts"), '<a href="' . home_url() . '">' . home_url() . '</a>') . '</p>'; $emails = new EDD_Emails(); $emails->__set('from_address', $from_email); $emails->__set('from_name', $from_name); $emails->send($email, $subject, $body); }
/** * Gets all the email templates that have been registerd. The list is extendable * and more templates can be added. * * As of 2.0, this is simply a wrapper to EDD_Email_Templates->get_templates() * * @since 1.0.8.2 * @return array $templates All the registered email templates */ function edd_get_email_templates() { $templates = new EDD_Emails(); return $templates->get_templates(); }
/** * Sends an email to the specified user with a URL to verify their account * * @access public * @since 2.4.4 * @return void */ function edd_send_user_verification_email($user_id = 0) { if (empty($user_id)) { return; } if (!edd_user_pending_verification($user_id)) { return; } $user_data = get_userdata($user_id); if (!$user_data) { return; } $verify_url = edd_get_user_verification_url($user_id); $name = $user_data->display_name; $url = edd_get_user_verification_url($user_id); $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')); $subject = apply_filters('edd_user_verification_email_subject', __('Verify your account', 'easy-digital-downloads'), $user_id); $heading = apply_filters('edd_user_verification_email_heading', __('Verify your account', 'easy-digital-downloads'), $user_id); $message = sprintf(__("Hello %s,\n\nYour account with %s needs to be verified before you can access your purchase history. <a href='%s'>Click here</a> to verify your account.\n\nLink missing? Visit the following URL: %s", 'easy-digital-downloads'), $name, $from_name, $url, $url); $message = apply_filters('edd_user_verification_email_message', $message, $user_id); $emails = new EDD_Emails(); $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('heading', $heading); $emails->send($user_data->user_email, $subject, $message); }
/** * Notifications * Sends the user an email with their logins details and also sends the site admin an email notifying them of a signup * * @since 1.1 */ public function email_notifications($user_id = 0, $user_data = array()) { global $edd_options; $user = get_userdata($user_id); $user_email_disabled = edd_get_option('edd_auto_register_disable_user_email', ''); $admin_email_disabled = edd_get_option('edd_auto_register_disable_admin_email', ''); // The blogname option is escaped with esc_html on the way into the database in sanitize_option // we want to reverse this for the plain text arena of emails. $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $message = sprintf(__('New user registration on your site %s:', 'edd-auto-register'), $blogname) . "\r\n\r\n"; $message .= sprintf(__('Username: %s', 'edd-auto-register'), $user->user_login) . "\r\n\r\n"; $message .= sprintf(__('E-mail: %s', 'edd-auto-register'), $user->user_email) . "\r\n"; if (!$admin_email_disabled) { @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'edd-auto-register'), $blogname), $message); } // user registration if (empty($user_data['user_pass'])) { return; } // message $message = $this->get_email_body_content($user_data['first_name'], sanitize_user($user_data['user_login'], true), $user_data['user_pass']); // subject line $subject = apply_filters('edd_auto_register_email_subject', sprintf(__('[%s] Your username and password', 'edd-auto-register'), $blogname)); // get from name and email from EDD options $from_name = edd_get_option('from_name', get_bloginfo('name')); $from_email = edd_get_option('from_email', get_bloginfo('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 = apply_filters('edd_auto_register_headers', $headers); $emails = new EDD_Emails(); $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('headers', $headers); // Email the user if (!$user_email_disabled) { $emails->send($user_data['user_email'], $subject, $message); } }
/** * Generates HTML for preview of email on edit email screen * * @access public * @return void */ function edd_pup_ajax_preview() { // Nonce security check if (empty($_REQUEST['nonce']) || !wp_verify_nonce($_REQUEST['nonce'], 'edd-pup-preview-email')) { _e('Nonce failure: error generating preview.', 'edd-pup'); die; } // Save the email before generating a preview $email_id = edd_pup_sanitize_save($_POST); // Instruct browser to redirect for continued editing of email if triggered on Add New Email page parse_str($_POST['url'], $url); if ($url['view'] == 'add_pup_email') { echo absint($email_id); die; } // Necessary for preview HTML set_transient('edd_pup_preview_email_' . get_current_user_id(), $email_id, 60); if (0 != $email_id) { $email = get_post($email_id); // Use $template_name = apply_filters( 'edd_email_template', $template_name, $payment_id ); add_filter('edd_email_template', 'edd_pup_template'); if (version_compare(get_option('edd_version'), '2.1') >= 0) { $edd_emails = new EDD_Emails(); $preview = $edd_emails->build_email(edd_email_preview_template_tags($email->post_content)); } else { $preview = edd_apply_email_template($email->post_content, null, null); } // Add max-width for plaintext emails so they don't run off the page if ('none' == edd_pup_template()) { $preview = '<div style="max-width: 640px;">' . $preview . '</div>'; } echo $preview; } else { _e('There was an error generating a preview.', 'edd-pup'); } die; }