예제 #1
0
/**
 * Email the ticket details to the customer.
 *
 * @since	1.0
 * @param	int		$ticket_id		Ticket ID
 * @param	bool	$admin_notice	Whether to send the admin email notification or not (default: true)
 * @return	void
 */
function kbs_email_ticket_received($ticket_id, $admin_notice = true)
{
    $ticket_data = kbs_get_ticket_meta($ticket_id);
    $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_ticket_from_address', $from_email, $ticket_id, $ticket_data);
    $to_email = '';
    //kbs_get_ticket_user_email( $ticket_id );
    $subject = kbs_get_option('ticket_subject', sprintf(__('Support %s Details', 'kb-support'), kbs_get_ticket_label_singular()));
    $subject = apply_filters('kbs_ticket_subject', wp_strip_all_tags($subject), $ticket_id);
    $subject = kbs_do_email_tags($subject, $ticket_id);
    $heading = kbs_get_option('ticket_heading', sprintf(__('Support %s Details', 'kb-support'), kbs_get_ticket_label_singular()));
    $heading = apply_filters('kbs_ticket_heading', $heading, $ticket_id, $ticket_data);
    $attachments = apply_filters('kbs_ticket_attachments', array(), $ticket_id, $ticket_data);
    $message = kbs_do_email_tags(kbs_get_email_body_content($ticket_id, $ticket_data), $ticket_id);
    $emails = KBS()->emails;
    $emails->__set('from_name', $from_name);
    $emails->__set('from_email', $from_email);
    $emails->__set('heading', $heading);
    $headers = apply_filters('kbs_ticket_headers', $emails->get_headers(), $ticket_id, $ticket_data);
    $emails->__set('headers', $headers);
    $emails->send($to_email, $subject, $message, $attachments);
    if ($admin_notice && !kbs_admin_notices_disabled($ticket_id)) {
        do_action('kbs_admin_ticket_notice', $ticket_id, $ticket_data);
    }
}
예제 #2
0
/**
 * Update the ticket meta.
 *
 * @since	1.0
 * @param	int	$ticket_id		The ticket ID
 * @param	arr	$data			The ticket meta data to update. $key => $value.
 * @return	arr	The ticket meta.
 */
function kbs_update_ticket_meta($ticket_id, $data)
{
    $meta = kbs_get_ticket_meta($ticket_id);
    $current_meta = $meta;
    foreach ($data as $key => $value) {
        if (is_array($value)) {
            $meta[$key] = array_map('absint', $value);
        } else {
            $meta[$key] = $value;
        }
    }
    /**
     * Fires immediately before updating ticket meta
     *
     * @since	1.0
     * @param	int	$ticket_id		The ticket ID
     * @param	arr	$meta			The updated meta data.
     * @param	arr	$current_meta	The existing meta data.
     */
    do_action('kbs_pre_ticket_meta_update', $ticket_id, $meta, $current_meta);
    update_post_meta($ticket_id, '_ticket_data', $meta);
    /**
     * Fires immediately after updating ticket meta
     *
     * @since	1.0
     * @param	int	$ticket_id		The ticket ID
     * @param	arr	$meta			The updated meta data.
     */
    do_action('kbs_post_ticket_meta_update', $ticket_id, $meta);
}