function sendWpmail($formId)
 {
     $excludedFromPost = array('action', 'tf_action', 'form_id', 'submit');
     $forms = $this->model->get_forms();
     $form = $forms[$formId];
     $from = str_replace(array('[', ']'), '', $form['email_from']);
     if ($this->request->isset_POST(TF_THEME_PREFIX . '_' . $from) && filter_var($this->request->POST(TF_THEME_PREFIX . '_' . $from), FILTER_VALIDATE_EMAIL)) {
         $form['email_from'] = $this->request->POST(TF_THEME_PREFIX . '_' . $from);
     }
     $message = $form['email_template'];
     if (trim($message) != '') {
         foreach ($this->request->POST() as $key => $value) {
             $key = tf_option_id_without_prefix($key);
             $message = str_replace('[' . $key . ']', $value, $message);
         }
     } else {
         $message = '';
         foreach ($this->request->POST() as $key => $value) {
             foreach ($form['input'] as $input) {
                 if (!in_array($key, $excludedFromPost) && $key != TF_THEME_PREFIX . '_') {
                     if ($key == TF_THEME_PREFIX . '_' . $input['shortcode']) {
                         $message .= '<strong>' . $input['label'] . ':</strong> ' . $value . '<br />';
                     }
                 }
             }
         }
     }
     $headers = "From:" . $form['email_from'] . "><" . $form['email_from'] . ">";
     add_filter('wp_mail_content_type', create_function('', 'return "text/html";'));
     if (wp_mail($form['email_to'], $form['email_subject'], $message, $headers)) {
         return array('mess' => $form['succes_mess'], 'error' => false);
     } else {
         return array('mess' => $form['fail_mess'], 'error' => true);
     }
 }
Ejemplo n.º 2
0
 function new_reservation_admin_email_content($form, $post_content, $nr)
 {
     $content = __('There is a new reservation on ', 'tfuse') . get_bloginfo('name');
     if (isset($form['admin_email_template']) && $form['admin_email_template'] != '') {
         $content = urldecode($form['admin_email_template']);
         $content = str_replace('[resnumber]', encode_id($nr), $content);
         foreach ($post_content as $key => $value) {
             $content = str_replace('[' . tf_option_id_without_prefix($key) . ']', $value, $content);
         }
     } else {
         foreach ($form['input'] as $input) {
             if (isset($post_content[TF_THEME_PREFIX . '_' . $input["shortcode"]])) {
                 $content .= '<strong>' . __($input['label'], 'tfuse') . ':</strong> ' . $post_content[TF_THEME_PREFIX . '_' . $input["shortcode"]] . '<br />';
             }
         }
     }
     return urldecode($content);
 }