Esempio n. 1
0
$email_content .= "\n\n";
$email_content .= '- - - - - - - - - - - - - -';
$email_content .= "\n\n";
$email_content .= __('Message content:', 'haku');
$email_content .= "\n\n";
$email_content .= '&MESSAGE';
$email_content = str_replace('&NAME', $form_contents_name, $email_content);
$email_content = str_replace('&EMAIL', $form_contents_email, $email_content);
$email_content = str_replace('&SUBJECT', $form_contents_subject, $email_content);
$email_content = str_replace('&MESSAGE', $form_contents_message, $email_content);
/***************/
/*   Options   */
$send_to = get_theme_option('contact_form_sendto') ? get_theme_option('contact_form_sendto') : get_option('admin_email');
$sender = get_theme_option('contact_form_sender') ? get_theme_option('contact_form_sender') : $form_contents_name;
/********************/
/*   Mail subject   */
$subject = get_bloginfo('name') . ' // ';
$subject .= __('Message from:', 'haku') . ' ' . $form_contents_email;
if ($form_contents_subject) {
    $subject .= ' // ' . __('Subject:', 'haku') . ' ' . haku_shorten($form_contents_subject, 5, '...');
}
/***************/
/*   Sending   */
$headers = "From: '" . esc_attr($sender) . "' <" . $form_contents_email . ">\r\n";
$headers .= "Reply-To: " . $form_contents_email . "\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
if (wp_mail($send_to, $subject, $email_content, $headers)) {
    $response = isset($is_ajax) ? '1' : __('Message sent! Thank you!', 'haku');
}
die($response);
function haku_get_excerpt($post_id, $shorten = 10)
{
    global $wpdb;
    $excerpt = $wpdb->get_results($wpdb->prepare("SELECT post_excerpt FROM {$wpdb->posts} WHERE ID = {$post_id} LIMIT 1", $post_id), ARRAY_A);
    $excerpt = $excerpt[0]['post_excerpt'];
    $excerpt = haku_shorten($excerpt, $shorten);
    return $excerpt;
}