Exemple #1
0
/**
 * Registers the new Commissions options in Emails
 *
 * @access      private
 * @since       3.0
 * @param 		$settings array the existing plugin settings
 * @return      array
*/
function eddc_settings_emails($settings)
{
    $commission_settings = array(array('id' => 'eddc_header', 'name' => '<strong>' . __('Commission Notifications', 'eddc') . '</strong>', 'desc' => '', 'type' => 'header', 'size' => 'regular'), array('id' => 'edd_commissions_email_subject', 'name' => __('Email Subject', 'eddc'), 'desc' => __('Enter the subject for commission emails.', 'eddc'), 'type' => 'text', 'size' => 'regular', 'std' => __('New Sale!', 'eddc')), array('id' => 'edd_commissions_email_message', 'name' => __('Email Body', 'eddc'), 'desc' => __('Enter the content for commission emails. HTML is accepted. Available template tags:', 'eddc') . '<br />' . eddc_display_email_template_tags(), 'type' => 'rich_editor', 'std' => eddc_get_email_default_body()));
    return array_merge($settings, $commission_settings);
}
/**
 * Email Sale Alert
 *
 * Email an alert about the sale to the user receiving a commission
 *
 * @access      private
 * @since       1.1.0
 * @return      void
 */
function eddc_email_alert($user_id, $commission_amount, $rate, $download_id, $commission_id)
{
    global $edd_options;
    /* send an email alert of the sale */
    $user = get_userdata($user_id);
    $email = $user->user_email;
    // set address here
    $subject = edd_get_option('edd_commissions_email_subject', __('New Sale!', 'eddc'));
    $message = edd_get_option('edd_commissions_email_message', eddc_get_email_default_body());
    // Parse template tags
    $message = eddc_parse_template_tags($message, $download_id, $commission_id, $commission_amount, $rate);
    $message = apply_filters('eddc_sale_alert_email', $message, $user_id, $commission_amount, $rate, $download_id, $commission_id);
    if (class_exists('EDD_Emails')) {
        EDD()->emails->__set('heading', $subject);
        EDD()->emails->send($email, $subject, $message);
    } else {
        $from_name = apply_filters('eddc_email_from_name', $from_name, $user_id, $commission_amount, $rate, $download_id);
        $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email');
        $from_email = apply_filters('eddc_email_from_email', $from_email, $user_id, $commission_amount, $rate, $download_id);
        $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n";
        wp_mail($email, $subject, $message, $headers);
    }
}