/** * Sends the Admin Ticket Notification Email * * @since 1.0 * @param int $ticket_id Ticket ID (default: 0) * @param arr $ticket_data Ticket Meta and Data * @return void */ function kbs_admin_email_notice($ticket_id = 0, $ticket_data = array()) { $ticket_id = absint($ticket_id); if (empty($ticket_id)) { return; } /*if( ! kbs_get_payment_by( 'id', $ticket_id ) ) { return; }*/ $from_name = kbs_get_option('from_name', wp_specialchars_decode(get_bloginfo('name'), ENT_QUOTES)); $from_name = apply_filters('kbs_ticket_from_name', $from_name, $ticket_id, $ticket_data); $from_email = kbs_get_option('from_email', get_bloginfo('admin_email')); $from_email = apply_filters('kbs_admin_ticket_from_address', $from_email, $ticket_id, $ticket_data); $subject = kbs_get_option('ticket_notification_subject', sprintf(__('New %1Ss logged - Case #%1$s', 'kb-support'), kbs_get_ticket_label_singular(), $ticket_id)); $subject = apply_filters('kbs_admin_ticket_notification_subject', wp_strip_all_tags($subject), $ticket_id); $subject = kbs_do_email_tags($subject, $ticket_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('kbs_admin_ticket_notification_headers', $headers, $ticket_id, $ticket_data); $attachments = apply_filters('kbs_admin_ticket_notification_attachments', array(), $ticket_id, $ticket_data); $message = kbs_get_ticket_notification_body_content($ticket_id, $ticket_data); $emails = KBS()->emails; $emails->__set('from_name', $from_name); $emails->__set('from_email', $from_email); $emails->__set('headers', $headers); $emails->__set('heading', __('New Sale!', 'kb-support')); $emails->send(kbs_get_admin_notice_emails(), $subject, $message, $attachments); }
/** * Ticket Notification Template Body * * @since 0.1 * @param int $ticket_id Ticket ID * @param arr $ticket_data Ticket Data * @return str $email_body Body of the email */ function kbs_get_ticket_notification_body_content($ticket_id = 0, $ticket_data = array()) { $user_info = maybe_unserialize($ticket_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 = $email; } $default_email_body = __('Hello', 'kb-support') . "\n\n" . sprintf(__('A Support %s has been received', 'kb-support'), kbs_get_ticket_label_plural()) . ".\n\n"; $default_email_body .= sprintf(__('%s sold:', 'kb-support'), kbs_get_ticket_label_plural()) . "\n\n"; $default_email_body .= $download_list . "\n\n"; $default_email_body .= __('Submitted by: ', 'kb-support') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $default_email_body .= __('Thank you', 'kb-support'); $email = kbs_get_option('ticket_notification', false); $email = $email ? stripslashes($email) : $default_email_body; $email_body = kbs_email_template_tags($email, $ticket_data, $ticket_id, true); $email_body = kbs_do_email_tags($email, $ticket_id); $email_body = apply_filters('kbs_email_template_wpautop', true) ? wpautop($email_body) : $email_body; return apply_filters('kbs_ticket_notification', $email_body, $ticket_id, $ticket_data); }