function thb_system_send_mail($to) { /** * Verify we have data to send. */ if ($_SERVER['REQUEST_METHOD'] != 'POST' || empty($_POST) || !isset($_POST['thb_system_send_mail_nonce'])) { return; } /** * Verify that the nonce is correct. */ if (!wp_verify_nonce($_POST['thb_system_send_mail_nonce'], 'thb_system_send_mail')) { return; } header('Content-type: application/json'); /** * Email data */ $thb_data = array('contact_email' => '', 'contact_name' => '', 'contact_message' => ''); $thb_data = $_POST + $thb_data; /** * Sanitize the data */ array_walk($thb_data, 'thb_system_xss_protect'); /** * Data validation */ foreach ($thb_data as $d) { if (trim($d) == '') { thb_system_raise_error(__('Please fill in all the required fields.', 'thb_text_domain')); } } /** * Composing the email */ $contact_name = $thb_data['contact_name']; $contact_email = $thb_data['contact_email']; $contact_message = $thb_data['contact_message']; $subject = get_bloginfo('contact_name'); $subject = apply_filters('thb_email_subject', $subject); $thb_contact_message = html_entity_decode(stripslashes(strip_tags($contact_message))); $headers = "From: " . $contact_name . " <" . $contact_email . ">" . "\r\n"; /** * Filters */ remove_all_filters('wp_mail_from'); remove_all_filters('wp_mail_from_name'); // add_filter( 'wp_mail_from','thb_wp_mail_from', 9999 ); // add_filter( 'wp_mail_from_name','thb_wp_mail_from_name', 9999 ); /** * Sending the email */ if (wp_mail($to, $subject, $thb_contact_message, $headers, array())) { thb_system_raise_success(__('Email sent successfully!', 'thb_text_domain')); } else { thb_system_raise_error(__('An error has occurred while sending your email.', 'thb_text_domain')); } }
/** * Import options and skin into the system. * * @param boolean $importOptions * @param boolean $importMods * @param boolean $importDuplicable */ function thb_import($importOptions = true, $importMods = true, $importDuplicable = true) { if (!empty($_FILES)) { foreach ($_FILES as $uploaded_file) { $file = thb_upload($uploaded_file); if (file_exists($file['file']['file'])) { $fileinfo = pathinfo($file['file']['file']); if ($fileinfo['extension'] == 'thb-backup') { $backup = @file_get_contents($file['file']['file']); $data = unserialize(base64_decode($backup)); $success = false; if ($importOptions && isset($data['options'])) { $thb_theme = thb_theme(); $thb_theme->importOptions($data['options']); $success = true; } if ($importMods && isset($data['mods'])) { $theme = get_option('stylesheet'); update_option("theme_mods_{$theme}", $data['mods']); $success = true; } if ($importDuplicable && isset($data['duplicable'])) { thb_duplicable_remove_all(); foreach ($data['duplicable'] as $itemKey => $datas) { foreach ($datas as $dat) { thb_duplicable_add($itemKey, $dat); } // thb_duplicable_add($itemKey, $da) // $row['meta'] = serialize($row['meta']); // $row['value'] = serialize($row['value']); // thb_duplicable_add($row); } $success = true; } if ($success) { $result = thb_system_raise_success(__('Data imported correctly', 'thb_text_domain')); } else { $result = thb_system_raise_error(__('No data imported', 'thb_text_domain')); } } else { $result = thb_system_raise_error(sprintf(__('Wrong file type. Only files with the following extensions are allowed: %s.', 'thb_text_domain'), '.thb-backup')); } unlink($file['file']['file']); } else { $result = thb_system_raise_error(__('Upload failed', 'thb_text_domain')); } thb_system_set_flashdata($result); } } }