get_options(); $options['sender_name'] = trim(stripslashes($_POST['sender_name'])); $options['sender_email'] = trim(strtolower(stripslashes($_POST['sender_email']))); $module->save_options($options); // Profile setting $module = NewsletterSubscription::instance(); $options = $module->get_options('profile'); $options['privacy_status'] = isset($_POST['field_privacy']) ? 1 : 0; $options['name_status'] = isset($_POST['field_name']) ? 2 : 0; $options['subscribe'] = trim(stripslashes($_POST['field_subscribe'])); if (empty($options['subscribe'])) $options['subscribe'] = 'Subscribe'; $module->save_options($options, 'profile'); die(); } if ($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_GET['action']) && $_GET['action'] == 'test') { $module = Newsletter::instance(); $email = $_POST['test_email']; $status_options = $module->get_options('status'); if (!NewsletterModule::is_email($email)) { echo _e('Please check the email address, it seems wrong.', 'newsletter'); die(); } // Newsletter mail $text = array(); $text['html'] = '
This is an HTML test email sent using the sender data set on Newsletter main setting. This is a link to an external site.
'; $text['text'] = 'This is a textual test email part sent using the sender data set on Newsletter main setting.'; $r = $module->mail($email, 'Newsletter test email at ' . date(DATE_ISO8601), $text); if ($r) { $status_options['mail'] = 1; $module->save_options($status_options, 'status'); echo _e('Check your mailbox for a test message. Check the spam folder as well.', 'newsletter'); die(); } else { $status_options['mail'] = 0; $status_options['mail_error'] = $module->mail_last_error; $module->save_options($status_options, 'status'); echo _e('There was an error. Complete the setup and then use the status panel to check it out.', 'newsletter'); die(); } die(); } $profile_options = NewsletterSubscription::instance()->get_options('profile'); $main_options = Newsletter::instance()->get_options(); $subscription_options = NewsletterSubscription::instance()->get_options(); $logger = Newsletter::instance()->logger; $page_exists = get_option('newsletter_page'); if (empty($page_exists)) { $module = Newsletter::instance(); $logger->info('Dedicated page creation'); // Page creation $page = array(); $page['post_title'] = 'Newsletter'; $page['post_content'] = '[newsletter]'; $page['post_status'] = 'publish'; $page['post_type'] = 'page'; $page['comment_status'] = 'closed'; $page['ping_status'] = 'closed'; $page['post_category'] = array(1); // Insert the post into the database $page_id = wp_insert_post($page); $main_options['page'] = $page_id; Newsletter::instance()->save_options($main_options); $main_options = Newsletter::instance()->get_options(); $page_exists = true; update_option('newsletter_page', $page_id, false); // Test subscriber creation $users = $module->get_test_users(); if (!$users) { global $current_user; $user = array(); $user['email'] = $current_user->user_email; $user['name'] = $current_user->first_name; $user['surname'] = $current_user->last_name; $user['test'] = 1; $user['status'] = TNP_User::STATUS_CONFIRMED; $module->save_user($user); } } else { $logger->info('Dedicated page already exists'); } ?>