function save()
 {
     $_POST['post_type'] = SendPress_Data::email_post_type();
     // Update post 37 (37!)
     $my_post = _wp_translate_postdata(true);
     $system_emails = SendPress_Option::base_get('system-emails');
     $my_post['post_status'] = 'sp-systememail';
     $my_post['post_content'] = SendPress_Data::get_sysemail_content($_POST['email_type']);
     // Update the post into the database
     wp_update_post($my_post);
     update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
     update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
     update_post_meta($my_post['ID'], '_sendpress_status', 'private');
     update_post_meta($my_post['ID'], '_sendpress_system', 'new');
     update_post_meta($my_post['ID'], '_system_email_type', $_POST['email_type']);
     update_post_meta($my_post['ID'], '_system_default', $_POST['default']);
     if ($_POST['default']) {
         //set default system e-mail for this type
         SendPress_Data::set_system_email_default($my_post['ID'], $_POST['email_type']);
     }
     SendPress_Email::set_default_style($my_post['ID']);
     //clear the cached file.
     delete_transient('sendpress_email_html_' . $my_post['ID']);
     if (!in_array($_POST['email_type'], $system_emails)) {
         $system_emails[] = $_POST['email_type'];
     }
     SendPress_Option::base_set('system-emails', $system_emails);
     SendPress_Admin::redirect('Settings_Emailedit', array('emailID' => $my_post['ID']));
     //$this->save_redirect( $_POST  );
 }
 function save($post, $sp)
 {
     $options = SendPress_Option::get('notification_options');
     $options['email'] = $post['toemail'];
     $options['notifications-enable'] = array_key_exists('notifications-enable', $post) ? true : false;
     if ($options['notifications-enable']) {
         $options['subscribed'] = $post['subscribed'];
         $options['unsubscribed'] = $post['unsubscribed'];
         $options['send-to-admins'] = array_key_exists('send-to-admins', $post) ? true : false;
     }
     $options['enable-hipchat'] = array_key_exists('enable-hipchat', $post) ? true : false;
     $options['hipchat-api'] = $post['hipchat-api'];
     if (strlen($options['hipchat-api']) > 0) {
         $options['hipchat-rooms'] = array();
         if (!array_key_exists('hipchat-rooms', $post)) {
             $post['hipchat-rooms'] = array();
         }
         global $hc;
         $hc = new SendPress_HipChat($options['hipchat-api'], 'https://api.hipchat.com');
         try {
             foreach ($hc->get_rooms() as $room) {
                 $options['hipchat-rooms'][$room->room_id] = array_key_exists($room->room_id, $post['hipchat-rooms']) ? true : false;
             }
         } catch (Exception $e) {
             $options['hipchat-room'] = $post['hipchat-room'];
         }
     }
     $options = apply_filters('sendpress_notification_settings_save', $options, $post, $sp);
     SendPress_Option::set('notification_options', $options);
     SendPress_Admin::redirect('Settings_Notifications');
 }
 function save($post, $sp)
 {
     // print_r($post);
     // die();
     $action = isset($post['form_action']) ? $post['form_action'] : 'save';
     switch ($action) {
         case 'copy':
             $postid = SendPress_Data::create_settings_post($post['post_subject'], "", $post['copy_from']);
             //wp_redirect( '?page=sp-settings&view=widgets&id='. $postid );
             SendPress_Admin::redirect('Settings_Widgets', array('id' => $postid));
             break;
         case 'create':
             $postid = SendPress_Data::create_settings_post($post['post_subject'], $post['form_type']);
             //wp_redirect( '?page=sp-settings&view=widgets&id='. $postid );
             SendPress_Admin::redirect('Settings_Widgets', array('id' => $postid));
             break;
         case 'delete':
             self::delete_form_save($post, $sp);
             //wp_redirect( '?page=sp-settings&view=widgets' );
             SendPress_Admin::redirect('Settings_Widgets');
             break;
         default:
             self::save_form($post, $sp);
             break;
     }
 }
 function save()
 {
     if (isset($_POST['delete-this-user']) && $_POST['delete-this-user'] == 'yes') {
         SendPress_Data::delete_subscriber($_POST['subscriberID']);
         if ($_GET['listID']) {
             SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $_GET['listID']));
         } else {
             SendPress_Admin::redirect('Subscribers_All');
         }
     } else {
         global $post;
         $subscriber_info = array('email' => $_POST['email'], 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname']);
         SendPress_Data::update_subscriber($_POST['subscriberID'], $subscriber_info);
         $args = array('post_type' => 'sendpress_list', 'post_status' => array('publish', 'draft'), 'posts_per_page' => 100, 'order' => 'ASC', 'orderby' => 'title');
         $postslist = get_posts($args);
         foreach ($postslist as $post) {
             setup_postdata($post);
             if (isset($_POST[$post->ID . "-status"]) && $_POST[$post->ID . "-status"] > 0) {
                 SendPress_Data::update_subscriber_status($post->ID, $_POST['subscriberID'], $_POST[$post->ID . "-status"]);
             } else {
                 SendPress_Data::remove_subscriber_status($post->ID, $_POST['subscriberID']);
             }
             $notifications = SendPress_Data::get_post_notification_types();
             if (isset($_POST[$post->ID . "-pn"]) && array_key_exists($_POST[$post->ID . "-pn"], $notifications)) {
                 SendPress_Data::update_subscriber_meta($_POST['subscriberID'], 'post_notifications', $_POST[$post->ID . "-pn"], $post->ID);
             }
         }
         wp_reset_postdata();
     }
     SendPress_Admin::redirect('Subscribers_Subscriber', array('subscriberID' => $_POST['subscriberID']));
 }
 function save()
 {
     //$this->security_check();
     $_POST['post_type'] = SendPress_Data::email_post_type();
     // Update post 37 (37!)
     $my_post = _wp_translate_postdata(true);
     /*            
     $my_post['ID'] = $_POST['post_ID'];
     $my_post['post_content'] = $_POST['content'];
     $my_post['post_title'] = $_POST['post_title'];
     */
     $my_post['post_status'] = 'publish';
     // Update the post into the database
     wp_update_post($my_post);
     update_post_meta($my_post['ID'], '_sendpress_subject', $_POST['post_subject']);
     update_post_meta($my_post['ID'], '_sendpress_template', $_POST['template']);
     update_post_meta($my_post['ID'], '_sendpress_status', 'private');
     update_post_meta($my_post['ID'], '_sendpress_system', $_POST['template_system']);
     SendPress_Email::set_default_style($my_post['ID']);
     //clear the cached file.
     delete_transient('sendpress_email_html_' . $my_post['ID']);
     if ($_POST['template_system'] == 'new') {
         SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID']));
     }
     SendPress_Admin::redirect('Emails_Style', array('emailID' => $my_post['ID']));
     //$this->save_redirect( $_POST  );
 }
 function save()
 {
     //$this->security_check();
     $saveid = SPNL()->validate->_int('post_ID');
     update_post_meta($saveid, 'send_date', date('Y-m-d H:i:s'));
     $email_post = get_post($saveid);
     $subject = SendPress_Option::get('current_send_subject_' . $saveid);
     $info = SendPress_Option::get('current_send_' . $saveid);
     $slug = SendPress_Data::random_code();
     $new_id = SendPress_Posts::copy($email_post, $subject, $slug, SPNL()->_report_post_type);
     SendPress_Posts::copy_meta_info($new_id, $saveid);
     $lists = implode(',', $info['listIDS']);
     update_post_meta($new_id, '_send_time', $info['send_at']);
     update_post_meta($new_id, '_send_lists', $lists);
     update_post_meta($new_id, '_stat_type', 'new');
     $count = 0;
     if (get_post_meta($saveid, 'istest', true) == true) {
         update_post_meta($new_id, '_report_type', 'test');
     }
     update_post_meta($new_id, '_sendpress_subject', $subject);
     if (isset($info['testemails']) && $info['testemails'] != false) {
         foreach ($info['testemails'] as $email) {
             $go = array('from_name' => 'Josh', 'from_email' => '*****@*****.**', 'to_email' => $email['email'], 'emailID' => $new_id, 'subscriberID' => 0, 'subject' => $subject, 'listID' => 0);
             SPNL()->add_email_to_queue($go);
             $count++;
         }
     }
     update_post_meta($new_id, '_send_count', $count);
     SendPress_Admin::redirect('Emails_Send_Queue', array('emailID' => $new_id));
 }
 function save()
 {
     $post = get_default_post_to_edit('sp_template', true);
     $post_ID = $post->ID;
     global $current_user;
     $content = '';
     switch ($_POST['starter']) {
         case 'blank':
             $content = '';
             break;
         default:
             $content = 'Default HTML';
             break;
     }
     /*            
     $my_post['ID'] = $_POST['post_ID'];
     $my_post['post_content'] = $_POST['content'];
     $my_post['post_title'] = $_POST['post_title'];
     */
     $post->post_title = $_POST['post_title'];
     $post->post_status = 'sp-custom';
     $post->post_content = $content;
     // Update the post into the database
     wp_update_post($post);
     //SendPress_Email::set_default_style( $my_post['ID'] );
     //clear the cached file.
     SendPress_Admin::redirect('Emails_Tempedit', array('templateID' => $post->ID));
     //$this->save_redirect( $_POST  );
 }
 function save()
 {
     if (isset($_POST['send-date']) && $_POST['send-date'] == 'later') {
         $send_at = $_POST['date-pickit'] . " " . $_POST['send-later-time'];
     } else {
         $send_at = '0000-00-00 00:00:00';
     }
     if (isset($_POST['test-add'])) {
         $csvadd = "email,firstname,lastname\n" . trim($_POST['test-add']);
         $data = SendPress_Data::subscriber_csv_post_to_array($csvadd);
     } else {
         $data = false;
     }
     $listids = isset($_POST['listIDS']) ? $_POST['listIDS'] : array();
     SendPress_Option::set('current_send_' . $_POST['post_ID'], array('listIDS' => $listids, 'testemails' => $data, 'send_at' => $send_at));
     SendPress_Option::set('current_send_subject_' . $_POST['post_ID'], $_POST['post_subject']);
     if (isset($_POST['test_report'])) {
         update_post_meta($_POST['post_ID'], 'istest', true);
     } else {
         update_post_meta($_POST['post_ID'], 'istest', false);
     }
     if (isset($_POST['google-campaign-name'])) {
         update_post_meta($_POST['post_ID'], 'google-campaign-name', $_POST['google-campaign-name']);
     }
     if (isset($_POST['submit']) && $_POST['submit'] == 'save-next') {
         SendPress_Admin::redirect('Emails_Send_Confirm', array('emailID' => $_GET['emailID']));
     } else {
         SendPress_Admin::redirect('Emails_Style', array('emailID' => $_GET['emailID']));
     }
 }
 function save($post, $sp)
 {
     $saveid = $_POST['post_ID'];
     update_post_meta($saveid, 'send_date', date('Y-m-d H:i:s'));
     $email_post = get_post($saveid);
     $subject = SendPress_Option::get('current_send_subject_' . $saveid);
     $info = SendPress_Option::get('current_send_' . $saveid);
     $slug = SendPress_Data::random_code();
     $new_id = SendPress_Posts::copy($email_post, $subject, $slug, $sp->_report_post_type);
     SendPress_Posts::copy_meta_info($new_id, $saveid);
     $lists = implode(',', $info['listIDS']);
     update_post_meta($new_id, '_send_time', $info['send_at']);
     update_post_meta($new_id, '_send_lists', $lists);
     update_post_meta($new_id, '_stat_type', 'new');
     $count = 0;
     if (get_post_meta($saveid, 'istest', true) == true) {
         update_post_meta($new_id, '_report_type', 'test');
     }
     update_post_meta($new_id, '_sendpress_subject', $subject);
     /*
     
             if(isset($info['listIDS'])){
                // foreach($info['listIDS'] as $list_id){
         $_email = SendPress_Data::get_active_subscribers_lists($info['listIDS']); //$sp->get_active_subscribers( $list_id );
     
         foreach($_email as $email){
            
              $go = array(
                 'from_name' => '',
                 'from_email' => '',
                 'to_email' => $email->email,
                 'emailID'=> $new_id,
                 'subscriberID'=> $email->subscriberID,
                 //'to_name' => $email->fistname .' '. $email->lastname,
                 'subject' => '',
                 'listID'=> $email->listid
                 );
            
             $sp->add_email_to_queue($go);
             $count++;
     
         }
     
     
               //  }
             }
     */
     if (isset($info['testemails']) && $info['testemails'] != false) {
         foreach ($info['testemails'] as $email) {
             $go = array('from_name' => 'Josh', 'from_email' => '*****@*****.**', 'to_email' => $email['email'], 'emailID' => $new_id, 'subscriberID' => 0, 'subject' => $subject, 'listID' => 0);
             $sp->add_email_to_queue($go);
             $count++;
         }
     }
     update_post_meta($new_id, '_send_count', $count);
     // update_post_meta($new_id,'_send_data', $info );
     SendPress_Admin::redirect('Emails_Send_Queue', array('emailID' => $new_id));
     //wp_redirect( '?page=sp-queue' );
 }
 function save()
 {
     $saveid = SPNL()->validate->int($_GET['templateID']);
     if ($saveid > 0) {
         update_post_meta($saveid, '_footer_page', $_POST['footer-content']);
         SendPress_Admin::redirect('Emails_Footerpage', array('templateID' => $saveid));
     }
 }
 function save()
 {
     $template = get_post($_POST['post_ID']);
     $template->post_content = stripcslashes($_POST['template-content']);
     $template->post_title = $_POST['post_subject'];
     wp_update_post($template);
     SendPress_Admin::redirect('Emails_Tempedit', array('templateID' => $_GET['templateID']));
 }
 function save($data, $sp)
 {
     $saveid = SPNL()->validate->int($_POST['post_ID']);
     if ($saveid > 0) {
         $bodybg = SPNL()->validate->hex($_POST['body_bg']);
         $bodytext = SPNL()->validate->hex($_POST['body_text']);
         $bodylink = SPNL()->validate->hex($_POST['body_link']);
         $contentbg = SPNL()->validate->hex($_POST['content_bg']);
         $contenttext = SPNL()->validate->hex($_POST['content_text']);
         $contentlink = SPNL()->validate->hex($_POST['sp_content_link_color']);
         $contentborder = SPNL()->validate->hex($_POST['content_border']);
         $upload_image = $_POST['upload_image'];
         $headerbg = SPNL()->validate->hex($_POST['header_bg']);
         $headertextcolor = SPNL()->validate->hex($_POST['header_text_color']);
         $headertext = sanitize_text_field($_POST['header_text']);
         $headerlink = esc_url_raw($_POST['header_link']);
         $imageheaderurl = esc_url_raw($_POST['image_header_url']);
         $subheadertext = sanitize_text_field($_POST['sub_header_text']);
         $activeHeader = $_POST['active_header'];
         update_post_meta($saveid, 'upload_image', $upload_image);
         update_post_meta($saveid, 'body_bg', $bodybg);
         update_post_meta($saveid, 'body_text', $bodytext);
         update_post_meta($saveid, 'body_link', $bodylink);
         update_post_meta($saveid, 'content_bg', $contentbg);
         update_post_meta($saveid, 'content_text', $contenttext);
         update_post_meta($saveid, 'sp_content_link_color', $contentlink);
         update_post_meta($saveid, 'content_border', $contentborder);
         update_post_meta($saveid, 'header_bg', $headerbg);
         update_post_meta($saveid, 'header_text_color', $headertextcolor);
         update_post_meta($saveid, 'header_text', $headertext);
         update_post_meta($saveid, 'header_link', $headerlink);
         update_post_meta($saveid, 'image_header_url', $imageheaderurl);
         update_post_meta($saveid, 'sub_header_text', $subheadertext);
         update_post_meta($saveid, 'active_header', $activeHeader);
         $canspam = sanitize_text_field($_POST['can-spam']);
         $linkedin = '';
         if (isset($_POST['linkedin'])) {
             $linkedin = esc_url_raw($_POST['linkedin']);
         }
         $twitter = '';
         if (isset($_POST['twitter'])) {
             $twitter = esc_url_raw($_POST['twitter']);
         }
         $facebook = '';
         if (isset($_POST['facebook'])) {
             $facebook = esc_url_raw($_POST['facebook']);
         }
         if (isset($_POST['fromname'])) {
             $fromname = sanitize_text_field($_POST['fromname']);
         }
         SendPress_Option::set('canspam', $canspam);
         SendPress_Option::set('linkedin', $linkedin);
         SendPress_Option::set('facebook', $facebook);
         SendPress_Option::set('twitter', $twitter);
     }
     // SendPress_Option::set('unsubscribetext', $unsubtext);
     SendPress_Admin::redirect('Settings_Styles');
 }
 function save()
 {
     $postdata = get_post($_GET['templateID']);
     $new_post = SendPress_Posts::copy($postdata, $_POST['post_title'], '', '');
     SendPress_Posts::copy_meta_info($new_post, $_GET['templateID']);
     update_post_meta($new_post, '_template_type', 'clone');
     update_post_meta($new_post, '_guid', '');
     SendPress_Admin::redirect('Emails_Tempstyle', array('templateID' => $new_post));
 }
 static function delete_subscribers_bulk_all()
 {
     if (isset($_GET['subscriber']) && is_array($_GET['subscriber'])) {
         foreach ($_GET['subscriber'] as $value) {
             SendPress_Data::delete_subscriber($value);
         }
     }
     SendPress_Admin::redirect('Subscribers_All');
 }
 function save($post, $sp)
 {
     $value = $_POST['submit'];
     if ($value == 'delete') {
         SendPress_Data::remove_from_queue($_POST['post_ID']);
         update_post_meta($_POST['post_ID'], '_canceled', true);
     }
     SendPress_Admin::redirect('Reports');
 }
    function html($sp)
    {
        global $post_ID, $post;
        $list = '';
        if (isset($_GET['emailID'])) {
            $emailID = SPNL()->validate->int($_GET['emailID']);
            $post = get_post($emailID);
            $post_ID = $post->ID;
        }
        update_post_meta($post->ID, '_send_last', 0);
        $info = get_post_meta($post->ID, '_send_data', true);
        $lists = get_post_meta($post->ID, '_send_lists', true);
        $subject = $post->post_title;
        $list = explode(",", $lists);
        $view = isset($_GET['view']) ? $_GET['view'] : '';
        if (isset($_GET['finished'])) {
            $time = get_post_meta($post->ID, '_send_time', true);
            if ($time == '0000-00-00 00:00:00') {
                SendPress_Admin::redirect('Queue');
            } else {
                SendPress_Admin::redirect('Reports');
            }
        }
        $subs = SendPress_Data::get_active_subscribers_count($list);
        update_post_meta($post->ID, '_send_last_count', $subs);
        update_post_meta($post->ID, '_sendpress_report', 'new');
        ?>
        <div id="taskbar" class="lists-dashboard rounded group"> 

    
</div><input type="hidden" id="post_ID" name="post_ID" value="<?php 
        echo $post->ID;
        ?>
" /><input type="hidden" id="reporttoqueue" name="reporttoqueue" value="<?php 
        echo $lists;
        ?>
" />
<div class='well' id="confirm-queue-add">
    <h2><strong><?php 
        _e('Adding Subscribers to Queue', 'sendpress');
        ?>
</strong></h2><br>
   <!-- <p>email:  <?php 
        echo stripslashes(esc_attr(htmlspecialchars($subject)));
        ?>
</p>-->
    <div class="progress progress-striped active">
        <div class="progress-bar sp-queueit" style="width: 0%;"></div>
    </div>
    <span id="queue-total">0</span> of <span id="list-total"><?php 
        echo $subs;
        ?>
</span>
</div>

        <?php 
    }
 function save()
 {
     $name = $_POST['name'];
     $public = 0;
     if (isset($_POST['public']) && $_POST['sync_role'] == 'none') {
         $public = $_POST['public'];
     }
     $list_id = SendPress_Data::create_list(array('name' => $name, 'public' => $public));
     update_post_meta($list_id, 'sync_role', $_POST['sync_role']);
     SendPress_Admin::redirect('Subscribers');
 }
 function save($post, $sp)
 {
     if (isset($post['allow_tracking'])) {
         SendPress_Option::set('allow_tracking', 'yes');
         SendPress_Option::set('feedback', 'yes');
     } else {
         SendPress_Option::set('allow_tracking', 'no');
         SendPress_Option::set('feedback', 'no');
     }
     if (isset($post['old_permalink'])) {
         SendPress_Option::set('old_permalink', true);
     } else {
         SendPress_Option::set('old_permalink', false);
     }
     if (isset($post['skip_mailto'])) {
         SendPress_Option::set('skip_mailto', true);
     } else {
         SendPress_Option::set('skip_mailto', false);
     }
     if (isset($post['enable_email_template_edit'])) {
         SendPress_Option::set('enable_email_template_edit', true);
     } else {
         SendPress_Option::set('enable_email_template_edit', false);
     }
     if (isset($post['prerelease_templates'])) {
         SendPress_Option::set('prerelease_templates', 'yes');
     } else {
         SendPress_Option::set('prerelease_templates', 'no');
     }
     SendPress_Option::set('queue-per-call', $post['queue-per-call']);
     SendPress_Option::set('sync-per-call', $post['sync-per-call']);
     SendPress_Option::set('autocron-per-call', $post['autocron-per-call']);
     SendPress_Option::set('wpcron-per-call', $post['wpcron-per-call']);
     SendPress_Option::set('queue-history', $post['queue-history']);
     if (isset($post['sp_widget_shortdoces'])) {
         SendPress_Option::set('sp_widget_shortdoces', $post['sp_widget_shortdoces']);
     }
     $widget_options = array();
     $widget_options['widget_options']['load_css'] = 0;
     $widget_options['widget_options']['load_ajax'] = 0;
     $widget_options['widget_options']['load_scripts_in_footer'] = 0;
     if (isset($_POST['load_css'])) {
         $widget_options['widget_options']['load_css'] = $_POST['load_css'];
     }
     if (isset($_POST['load_ajax'])) {
         $widget_options['widget_options']['load_ajax'] = $_POST['load_ajax'];
     }
     if (isset($_POST['load_scripts_in_footer'])) {
         $widget_options['widget_options']['load_scripts_in_footer'] = $_POST['load_scripts_in_footer'];
     }
     SendPress_Option::set($widget_options);
     SendPress_Admin::redirect('Settings_Advanced');
 }
 public function update_template()
 {
     $templateID = SPNL()->validate->int($_GET['templateID']);
     $post = get_post($templateID);
     $post_ID = $post->ID;
     $post_id = wp_update_post(array('ID' => $post_ID, 'post_title' => $_POST['post_title'], 'post_content' => $_POST['content_area_one_edit']));
     update_post_meta($post_id, '_guid', 'cd8ab467-e236-49d3-bd6c-e84db055ae9a');
     update_post_meta($post_id, '_footer_page', $_POST["footer_content_edit"]);
     update_post_meta($post_id, '_header_content', $_POST["header_content_edit"]);
     update_post_meta($post_id, '_header_padding', 'pad-header');
     SendPress_Admin::redirect('emails&view=temp');
 }
 function save($post, $sp)
 {
     if (isset($_POST['templates'])) {
         SendPress_Data::remove_all_templates();
         SendPress_Template_Manager::update_template_content();
     }
     if (isset($_POST['settings'])) {
         SendPress_Data::remove_all_settings();
         //SendPress_Data::create_settings_post_signup_form();
     }
     SendPress_Admin::redirect('Settings_Dbfix');
 }
 function create_subscriber()
 {
     $email = $_POST['email'];
     $fname = $_POST['firstname'];
     $lname = $_POST['lastname'];
     $listID = $_POST['listID'];
     $status = $_POST['status'];
     if (is_email($email)) {
         $result = SendPress_Data::add_subscriber(array('firstname' => $fname, 'email' => $email, 'lastname' => $lname));
         SendPress_Data::update_subscriber_status($listID, $result, $status, false);
     }
     SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $listID));
 }
 function save()
 {
     if (isset($_POST['listID'])) {
         $list_id = $_POST['listID'];
         $postpage = $_POST['post-page'];
         $postpageid = $_POST['post-page-id'];
         $postredirect = $_POST['post-redirect'];
         update_post_meta($list_id, 'post-page', $postpage);
         update_post_meta($list_id, 'post-page-id', $postpageid);
         update_post_meta($list_id, 'post-redirect', $postredirect);
     } else {
         $list_id = $_GET['listID'];
     }
     SendPress_Admin::redirect('Subscribers_Listform', array('listID' => $list_id));
 }
 function save()
 {
     $list_id_clean = SPNL()->validate->int($_GET['listID']);
     $file = trim(SendPress_Data::read_file_to_str(get_post_meta($list_id_clean, 'csv_import', true)));
     $subscribers = SendPress_Data::csv_to_array($file);
     $total = count($subscribers);
     $map = array();
     $i = 0;
     foreach ($subscribers[0] as $key => $val) {
         /* try to automatically match columns */
         $map[$_POST['colmatch' . $i]] = $i;
         $i++;
     }
     $file_chunks = array_chunk($subscribers, 200);
     $subscribers = null;
     global $wpdb;
     $chunks_count = 0;
     $wpdb->query('set session wait_timeout=600');
     foreach ($file_chunks as $key_chunk => $csv_chunk) {
         $result = SendPress_Data::import_csv_array($csv_chunk, $map, $list_id_clean);
         if ($result !== false) {
             $chunks_count++;
         } else {
             // there was an error we try 3
             $try = 0;
             while ($result === false && $try < 3) {
                 $result = SendPress_Data::import_csv_array($csv_chunk, $map, $list_id_clean);
                 if ($result !== false) {
                     break;
                 }
                 $try++;
             }
             if ($result === false) {
                 //                   return false;
             }
         }
         unset($file_chunks[$key_chunk]);
     }
     unlink($file);
     SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $list_id_clean));
 }
 function save()
 {
     $listid = $_POST['listID'];
     $name = $_POST['name'];
     $public = 0;
     if (isset($_POST['public']) && $_POST['sync_role'] == 'none') {
         $public = $_POST['public'];
     }
     SendPress_Data::update_list($listid, array('name' => $name, 'public' => $public));
     $roles_list = array();
     $test_list = 0;
     if (isset($_POST['test_list'])) {
         $public = $_POST['test_list'];
     }
     update_post_meta($listid, '_test_list', $_POST['test_list']);
     update_post_meta($listid, 'sync_role', $_POST['sync_role']);
     update_post_meta($listid, 'meta-key', $_POST['meta-key']);
     update_post_meta($listid, 'meta-compare', $_POST['meta-compare']);
     update_post_meta($listid, 'meta-value', $_POST['meta-value']);
     SendPress_Admin::redirect('Subscribers');
 }
 function save()
 {
     SendPress_Option::set('send_optin_email', $_POST['optin']);
     SendPress_Option::set('optin_subject', $_POST['subject']);
     SendPress_Option::set('confirm-page', $_POST['confirm-page']);
     SendPress_Option::set('confirm-page-id', $_POST['confirm-page-id']);
     SendPress_Option::set('confirm-notification-template', $_POST['confirm-notification-template']);
     SendPress_Option::set('manage-page', $_POST['manage-page']);
     SendPress_Option::set('manage-page-id', $_POST['manage-page-id']);
     SendPress_Option::set('try-theme', $_POST['try-theme']);
     $optin = SendPress_Data::get_template_id_by_slug('double-optin');
     /*
     $dpost = get_post($optin);
     $dpost->post_content = $_POST['body'];
     $dpost->post_title = $_POST['subject'];
     */
     $my_post = array('ID' => $optin, 'post_content' => $_POST['body'], 'post_title' => $_POST['subject']);
     wp_update_post($my_post);
     update_post_meta($optin, '_sendpress_template', $_POST['confirm-notification-template']);
     SendPress_Admin::redirect('Settings_Activation');
 }
 function save()
 {
     $_POST['post_type'] = SendPress_Data::email_post_type();
     // Update post 37 (37!)
     $my_post = _wp_translate_postdata(true);
     /*            
     $my_post['ID'] = $_POST['post_ID'];
     $my_post['post_content'] = $_POST['content'];
     $my_post['post_title'] = $_POST['post_title'];
     */
     $my_post['post_status'] = 'sp-autoresponder';
     // Update the post into the database
     wp_update_post($my_post);
     update_post_meta($my_post['ID'], '_sendpress_subject', sanitize_text_field($_POST['post_subject']));
     update_post_meta($my_post['ID'], '_sendpress_template', SPNL()->validate->int($_POST['template']));
     update_post_meta($my_post['ID'], '_sendpress_status', 'private');
     update_post_meta($my_post['ID'], '_sendpress_system', 'new');
     SendPress_Email::set_default_style($my_post['ID']);
     //clear the cached file.
     delete_transient('sendpress_email_html_' . $my_post['ID']);
     SendPress_Admin::redirect('Emails_Edit', array('emailID' => $my_post['ID']));
     //$this->save_redirect( $_POST  );
 }
 function save()
 {
     $listid = SPNL()->validate->int($_POST['listID']);
     if ($listid > 0) {
         $name = sanitize_text_field($_POST['name']);
         $public = 0;
         if (isset($_POST['public']) && $_POST['sync_role'] == 'none') {
             $public = SPNL()->validate->int($_POST['public']);
         }
         SendPress_Data::update_list($listid, array('name' => $name, 'public' => $public));
         $roles_list = array();
         $test_list = 0;
         if (isset($_POST['test_list'])) {
             $public = $_POST['test_list'];
         }
         update_post_meta($listid, '_test_list', $_POST['test_list']);
         update_post_meta($listid, 'sync_role', $_POST['sync_role']);
         update_post_meta($listid, 'meta-key', $_POST['meta-key']);
         update_post_meta($listid, 'meta-compare', $_POST['meta-compare']);
         update_post_meta($listid, 'meta-value', $_POST['meta-value']);
         update_post_meta($listid, 'opt-in-id', $_POST['opt-in-id']);
     }
     SendPress_Admin::redirect('Subscribers');
 }
 function tracking($get, $sp)
 {
     SendPress_Option::set('allow_tracking', $get['allow_tracking']);
     SendPress_Admin::redirect('Overview');
 }
 function tracking()
 {
     //$this->security_check();
     SendPress_Option::set('allow_tracking', SPNL()->validate->_string('allow_tracking'));
     SendPress_Admin::redirect('Overview');
 }
 function remove_subscribers($get, $sp)
 {
     SendPress_Data::remove_all_subscribers($get['listID']);
     SendPress_Admin::redirect('Subscribers_Subscribers', array('listID' => $get['listID']));
 }