function wpucontactforms_submit_contactform__sendmail($form) { $sendmail_intro = apply_filters('wpucontactforms__sendmail_intro', '<p>' . __('Message from your contact form', 'wpucontactforms') . '</p>', $form); $sendmail_subject = apply_filters('wpucontactforms__sendmail_subject', __('Message from your contact form', 'wpucontactforms'), $form); // Send mail $mail_content = $sendmail_intro; $attachments_to_destroy = array(); $more = array('attachments' => array()); // Target Email $target_email = get_option('admin_email'); $wpu_opt_email = get_option('wpu_opt_email'); if (is_email($wpu_opt_email)) { $target_email = $wpu_opt_email; } $target_email = apply_filters('wpucontactforms_email', $target_email, $form->options); foreach ($form->contact_fields as $id => $field) { if ($field['type'] == 'file') { // Store attachment id $attachments_to_destroy[] = $form->contact_fields[$id]['value']; // Add to mail attachments $more['attachments'][] = get_attached_file($form->contact_fields[$id]['value']); continue; } // Emptying values $mail_content .= '<hr /><p><strong>' . $field['label'] . '</strong>:<br />' . $field['value'] . '</p>'; } if (function_exists('wputh_sendmail')) { wputh_sendmail($target_email, $sendmail_subject, $mail_content, $more); } else { wp_mail($target_email, $sendmail_subject, $mail_content, '', $more['attachments']); } // Delete temporary attachments if (apply_filters('wpucontactforms__sendmail_delete_attachments', true)) { foreach ($attachments_to_destroy as $att_id) { wp_delete_attachment($att_id); } } }
} } elseif ($field['required']) { $msg_errors[] = sprintf(__('The field "%s" is required', 'wputh'), $id); } } if (empty($msg_errors)) { // Setting success message $content_contact .= '<p>' . __('Thank you for your message!', 'wputh') . '</p>'; // Send mail $mail_content = '<p>' . __('Message from your contact form', 'wputh') . '</p>'; foreach ($fields as $id => $field) { // Emptying values $mail_content .= '<hr /><p><strong>' . $field['label'] . '</strong>:<br />' . $field['value'] . '</p>'; $fields[$id]['value'] = ''; } wputh_sendmail(get_option('admin_email'), __('Message from your contact form', 'wputh'), $mail_content); } else { $content_contact .= '<p><strong>' . __('Error:', 'wputh') . '</strong><br />' . implode('<br />', $msg_errors) . '</p>'; } } // Showing contact form $content_contact .= '<form action="" method="post"><ul class="cssc-form cssc-form--default float-form">'; foreach ($fields as $id => $field) { $field_type = isset($field['type']) ? $field['type'] : ''; $field_id_name = 'id="' . $id . '" name="' . $id . '"'; $field_val = 'value="' . $field['value'] . '"'; $content_contact .= '<li class="box">'; if (isset($field['label'])) { $content_contact .= '<label for="' . $id . '">' . $field['label'] . '</label>'; } switch ($field_type) {
function post_contact() { // Checking before post if (empty($_POST) || !isset($_POST['wputh_contact_send'])) { return; } // Initial settings $this->msg_errors = array(); $msg_success = ''; // Checking for PHP Conf if (isset($_POST['control_stripslashes']) && $_POST['control_stripslashes'] == '\\"') { foreach ($_POST as $id => $field) { $_POST[$id] = stripslashes($field); } } // Checking bots if (!isset($_POST['hu-man-te-st']) || !empty($_POST['hu-man-te-st'])) { return; } $this->contact_fields = $this->extract_value_from_post($_POST, $this->contact_fields); if (isset($this->contact_fields['contact_message'])) { $contact_message = apply_filters('wputh_contact_message', $this->contact_fields['contact_message']['value']); if (is_array($contact_message)) { foreach ($contact_message as $msg) { $this->msg_errors[] = $msg; } } else { $this->contact_fields['contact_message']['value'] = $contact_message; } } if (empty($this->msg_errors)) { // Setting success message $this->content_contact .= $this->contact__success; $attachments_to_destroy = array(); $this->more = array('attachments' => array()); // Send mail $mail_content = '<p>' . __('Message from your contact form', 'wputh') . '</p>'; foreach ($this->contact_fields as $id => $field) { if ($field['type'] == 'file') { // Store attachment id $attachments_to_destroy[] = $this->contact_fields[$id]['value']; // Add to mail attachments $this->more['attachments'][] = get_attached_file($this->contact_fields[$id]['value']); $this->contact_fields[$id]['value'] = ''; continue; } // Emptying values $mail_content .= '<hr /><p><strong>' . $field['label'] . '</strong>:<br />' . $field['value'] . '</p>'; $this->contact_fields[$id]['value'] = ''; } wputh_sendmail(get_option('admin_email'), __('Message from your contact form', 'wputh'), $mail_content, $this->more); // Delete temporary attachments foreach ($attachments_to_destroy as $att_id) { wp_delete_attachment($att_id); } } else { $this->content_contact .= '<p class="contact-error"><strong>' . __('Error:', 'wputh') . '</strong><br />' . implode('<br />', $this->msg_errors) . '</p>'; } }