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)
 {
     // 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()
 {
     //$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, $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 html($sp)
    {
        global $sendpress_html_templates;
        //print_r($sendpress_html_templates[$_GET['templateID']]);
        $postdata = get_post($_GET['templateID']);
        //print_r( $postdata );
        ?>
    <form method="post" name="post" >
    <input type="hidden" value="<?php 
        echo $_GET['templateID'];
        ?>
" name="templateID" />
     
   	<div class="pull-right">
     <a href="<?php 
        echo SendPress_Admin::link('Emails_Tempstyle', array('templateID' => $_GET['templateID']));
        ?>
"><?php 
        _e('Back to Template', 'sendpress');
        ?>
</a>&nbsp;&nbsp;&nbsp;<button class="btn btn-primary " type="submit" value="save" name="submit"><i class="icon-white icon-ok"></i> <?php 
        echo __('Save', 'sendpress');
        ?>
</button>
   	</div>
   <h2><?php 
        echo $postdata->post_title;
        ?>
 <?php 
        _e('Template Footer', 'sendpress');
        ?>
</h2><br>
     <div class="tab-pane fade in active" id="home"><?php 
        wp_editor(get_post_meta($postdata->ID, '_footer_content', true), 'footer-content');
        ?>
</div>

		<?php 
        SendPress_Data::nonce_field();
        ?>
     </form><br><br><?php 
        _e('Default Content', 'sendpress');
        ?>
<textarea class="form-control" rows="3">
<?php 
        echo SendPress_Tag_Footer_Content::content();
        ?>
</textarea>
<br>



<?php 
        echo spnl_get_emails_tags_list();
        $this->popup();
        ?>


<?php 
    }
 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']));
 }
 /** ************************************************************************
  * Recommended. This method is called when the parent class can't find a method
  * specifically build for a given column. Generally, it's recommended to include
  * one method for each column you want to render, keeping your package class
  * neat and organized. For example, if the class needs to process a column
  * named 'title', it would first see if a method named $this->column_title() 
  * exists - if it does, that method will be used. If it doesn't, this one will
  * be used. Generally, you should try to use custom column methods as much as 
  * possible. 
  * 
  * Since we have defined a column_title() method later on, this method doesn't
  * need to concern itself with any column with a name of 'title'. Instead, it
  * needs to handle everything else.
  * 
  * For more detailed insight into how columns are handled, take a look at 
  * WP_List_Table::single_row_columns()
  * 
  * @param array $item A singular item (one full row's worth of data)
  * @param array $column_name The name/slug of the column to be processed
  * @return string Text or HTML to be placed inside the column <td>
  **************************************************************************/
 function column_default($item, $column_name)
 {
     $settings = SendPress_Data::get_post_meta_object($item->ID);
     switch ($column_name) {
         case 'name':
             return $item->post_title;
             break;
         case 'type':
             return ucwords(str_replace('_', ' ', $settings['_form_type']));
             break;
         case 'shortcode':
             return '[sp-form formid=' . $item->ID . ']';
             break;
         case 'actions':
             //$type = get_post_meta($item->ID, "_template_type", true);
             $a = '<div class="inline-buttons" style="text-align:right;">';
             $a .= '<a class="btn btn-default" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID, 'create' => 1)) . '">' . __('Clone', 'sendpress') . '</a> <a class="btn btn-primary" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID)) . '">' . __('Edit', 'sendpress') . '</a>' . '</a> <a class="btn btn-danger" href="' . SendPress_Admin::link('Settings_Widgets', array('id' => $item->ID, 'delete' => 1)) . '">' . __('Delete', 'sendpress') . '</a>';
             $a .= '</div>';
             return $a;
             break;
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
 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($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()
 {
     $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($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['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 html()
        {
            SendPress_Tracking::event('Emails Tab');
            //SendPress_Template_Manager::update_template_content();
            //Create an instance of our package class...
            $testListTable = new Jaiminho_Email_Local_Table();
            //Fetch, prepare, sort, and filter our data...
            $testListTable->prepare_items();
            ?>
	
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" method="get">
		<div id="taskbar" class="lists-dashboard rounded group"> 

		<h2><?php 
            _e('Templates', 'sendpress');
            ?>
</h2>
		<small><?php 
            _e('Help', 'sendpress');
            ?>
: <a target="_blank" href="http://docs.sendpress.com/article/58-setting-up-a-newsletter-template/"><?php 
            _e('Getting Started with Templates', 'sendpress');
            ?>
</a></small>
	</div>
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="page" value="<?php 
            echo SPNL()->validate->page();
            ?>
" />
	    <!-- Now we can render the completed list table -->
	    <?php 
            $testListTable->display();
            ?>
	    <?php 
            wp_nonce_field($this->_nonce_value);
            ?>
	</form><br>
	<!--a href="<?php 
            echo SendPress_Admin::link('Emails_Temp', array('action' => 'install'));
            ?>
" class="btn btn-primary">Install Starter Templates</a-->
	<a href="<?php 
            echo SendPress_Admin::link('Emails_Temp', array('action' => 'install'));
            ?>
" class="btn btn-primary">Install Starter Templates</a>
	<?php 
        }
    function html($sp)
    {
        ?>
		<?php 
        $template = get_post($_GET['templateID']);
        ?>

		
		
		<h2><?php 
        _e('You are about to delete template', 'sendpress');
        ?>
: <?php 
        echo $template->post_title;
        ?>
</h2>
		<br>
				<a class="btn btn-danger" href="<?php 
        echo SendPress_Admin::link('Emails_Temp', array('templateID' => $_GET['templateID'], 'action' => 'delete'));
        ?>
"><?php 
        _e('Delete Template', 'sendpress');
        ?>
</a>
			
				<a class="btn btn-default" href="<?php 
        echo SendPress_Admin::link('Emails_Temp');
        ?>
"><?php 
        _e('Cancel', 'sendpress');
        ?>
</a>
			

		
		
		<?php 
        //wp_editor($post->post_content,'textversion');
        ?>

		 <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
<br><br>
		 </form>
		 
		<?php 
    }
 function html($sp)
 {
     $count = SendPress_Data::get_bad_post_count();
     echo __("We see", "sendpress") . " " . $count . " " . __("bad posts.", "sendpress");
     $link = SendPress_Admin::link('Settings_Fixposts', array('action' => 'posts-repair'));
     echo "<br><br><a href='{$link}' class='btn btn-primary' >" . __('Attempt to Delete These', 'sendpress') . "</a>";
     /*
     echo "<h2>Attempting to install or repair missing data</h2><br>";
     
     SendPress_Data::install();
     
     echo "<pre>";
     echo SendPress_DB_Tables::check_setup_support();
     echo "</pre>";
     */
 }
    function html($sp)
    {
        global $sendpress_html_templates;
        //print_r($sendpress_html_templates[$_GET['templateID']]);
        $templateID = SPNL()->validate->int($_GET['templateID']);
        $postdata = get_post($templateID);
        //print_r( $postdata );
        ?>
    <form method="post" name="post" >
    <input type="hidden" value="<?php 
        echo $templateID;
        ?>
" name="templateID" />
     
   	<div class="pull-right">
     <a href="<?php 
        echo SendPress_Admin::link('Emails_Tempstyle', array('templateID' => $templateID));
        ?>
"><?php 
        _e('Back to Template', 'sendpress');
        ?>
</a>&nbsp;&nbsp;&nbsp;<button class="btn btn-primary " type="submit" value="save" name="submit"><i class="icon-white icon-ok"></i> <?php 
        echo __('Save', 'sendpress');
        ?>
</button>
   	</div>
   <h2><?php 
        echo $postdata->post_title;
        ?>
 <?php 
        _e('Template Page Header', 'sendpress');
        ?>
</h2><br>
     <div class="tab-pane fade in active" id="home"><?php 
        wp_editor(get_post_meta($postdata->ID, '_header_page', true), 'header-content');
        ?>
</div>

		<?php 
        SendPress_Data::nonce_field();
        ?>
     </form>

<?php 
        $this->popup();
    }
    function html($sp)
    {
        global $post_ID, $post;
        $view = isset($_GET['view']) ? $_GET['view'] : '';
        $list = '';
        if (isset($_GET['emailID'])) {
            $emailID = SPNL()->validate->int($_GET['emailID']);
            $post = get_post($emailID);
            $post_ID = $post->ID;
        }
        ?>
		<form method="post" id="post">
	<br class="clear">
    <!--
<div style="float:right;" >
	<a href="<?php 
        echo SendPress_Admin::link('Settings_Styles');
        ?>
" class="btn btn-default btn-large" ><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a> <a href="#" id="save-update" class="btn btn-primary btn-large"><i class="icon-white icon-ok"></i> <?php 
        _e('Save', 'sendpress');
        ?>
</a>
</div>
-->

<br class="clear">

		<?php 
        define('SENDPRESS_STYLER_PAGE', true);
        require_once SENDPRESS_PATH . 'inc/forms/email-style.2.0.php';
        ?>
		
<br class="clear">

<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
		</form>
	<?php 
    }
 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');
 }
 /** ************************************************************************
  * Recommended. This method is called when the parent class can't find a method
  * specifically build for a given column. Generally, it's recommended to include
  * one method for each column you want to render, keeping your package class
  * neat and organized. For example, if the class needs to process a column
  * named 'title', it would first see if a method named $this->column_title() 
  * exists - if it does, that method will be used. If it doesn't, this one will
  * be used. Generally, you should try to use custom column methods as much as 
  * possible. 
  * 
  * Since we have defined a column_title() method later on, this method doesn't
  * need to concern itself with any column with a name of 'title'. Instead, it
  * needs to handle everything else.
  * 
  * For more detailed insight into how columns are handled, take a look at 
  * WP_List_Table::single_row_columns()
  * 
  * @param array $item A singular item (one full row's worth of data)
  * @param array $column_name The name/slug of the column to be processed
  * @return string Text or HTML to be placed inside the column <td>
  **************************************************************************/
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'firstname':
         case 'lastname':
             return $item->{$column_name};
         case 'status':
             return $item->{$column_name};
         case 'gravatar':
             return get_avatar($item->email, 30);
         case 'joindate':
             return date_i18n(get_option('date_format'), strtotime($item->join_date));
         case 'actions':
             $a = '<div class="inline-buttons">';
             $a .= '<a class="btn btn-primary" href="' . SendPress_Admin::link('Subscribers_Subscriber', array('subscriberID' => $item->subscriberID)) . '"><span class="glyphicon glyphicon-pencil"></span> ' . __('Edit', 'sendpress') . '</a> ';
             $a .= '</div>';
             return $a;
         default:
             return print_r($item, true);
             //Show the whole array for troubleshooting purposes
     }
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        $testListTable = new SendPress_Queue_Errors_Table();
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        $sp->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        ?>

	<h2><?php 
        _e('Error history for the last 2 Weeks', 'sendpress');
        ?>
.</h2>

	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="email-filter" action="<?php 
        echo SendPress_Admin::link('Queue_Errors');
        ?>
" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	     <input type="hidden" name="page" value="<?php 
        echo SPNL()->validate->page($_REQUEST['page']);
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<br>
	
<?php 
    }
 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 html($sp)
    {
        //SendPress_Option::set('pro_plugins','');
        SendPress_Tracking::event('Pro Tab');
        ?>
        <div class="pro-header" >
            <form method="post" id="post" style="float:right;">
            <?php 
        $sppro = new SendPress_Module_Pro();
        $sppro->buttons('sendpress-pro/sendpress-pro.php');
        ?>
 
            <input type="hidden" name="plugin_path" value="sendpress-pro/sendpress-pro.php" />
            <input class="action" type="hidden" name="action" value="module-activate-sendpress-pro" />
            <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
        </form>
    <h1 style="font-size:35px;">SendPress Pro
    <?php 
        if (defined('SENDPRESS_PRO_VERSION')) {
            echo "<small>v" . SENDPRESS_PRO_VERSION . "</small>";
        }
        ?>
    </h1>
    <?php 
        if (is_plugin_active('sendpress-pro/sendpress-pro.php')) {
            ?>
        <p class="lead">Thanks for using <b>SendPress Pro</b>.</p>
    <?php 
        } else {
            ?>
 
        <p class="lead">Take your emails to the next level. <b>SendPress Pro</b> allows you to build an email marketing system tailored to your needs. All within WordPress with no need for an external system.</p>
    <?php 
        }
        ?>
    </div>
                <?php 
        $modules = apply_filters('sendpress_pro_modules', array('sendgrid', 'mailjet', 'customsmtp', 'amazonses', 'mandrill', 'elastic', 'empty', 'empty', 'empty'));
        echo '<div class="sendpress-addons">';
        $p = new SendPress_Module_Pro();
        $p->index(0);
        $p->render($this);
        $i = 1;
        echo "<h2 class='clear' style='padding-left: 18px; padding-top: 30px; padding-bottom: 10px;'>Sending Options</h2>";
        foreach ($modules as $mod) {
            $mod_class = $this->get_module_class($mod);
            if ($mod_class) {
                $mod_class = new $mod_class();
                $mod_class->index($i);
                $mod_class->render($this);
                $i++;
            }
        }
        echo '<br class="clear"><br></div>';
        ?>
        <!--
        <h2 class="clear" style="padding-left: 18px; padding-top: 30px; padding-bottom: 10px;">Addons</h2>
        <div class="sendpress-module  mod-first"><div class="inner-module">
        <h4>WordPress Emails</h4>
            <form method="post" id="post">
            <div class="description">
                Wrap WordPress system emails in a SendPress template and send them via your sending settings.
                <br><br>
                
            </div>
            <?php 
        $d = get_option('sendpress_wp_mail', false);
        $sp = is_plugin_active('sendpress-pro/sendpress-pro.php');
        ?>


            <div class="inline-buttons">
            <?php 
        if ($sp) {
            if ($d === false) {
                ?>
                    <a class=" btn-success btn-activate btn" href="<?php 
                echo SendPress_Admin::link('Pro', array('action' => 'wp-mail', 'enable' => true));
                ?>
">Activate</a>
                <?php 
            } else {
                ?>
                    <a class="btn btn-default " href="<?php 
                echo SendPress_Admin::link('Pro', array('action' => 'wp-mail', 'enable' => false));
                ?>
">Deactivate</a>&nbsp;<a class="btn btn-default module-deactivate-plugin" href="#">Settings</a>
                <?php 
            }
            ?>
            <?php 
        } else {
            ?>
                <a class="btn disabled btn-default btn-activate" href="#">Activate</a>
            <?php 
        }
        ?>
            </div>         
            
            </div>
        </div>
        -->
          <br class="clear">
        <br><br>

        <?php 
    }
    function html($sp)
    {
        $list = '';
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            //$listinfo = $this->getDetail( $this->lists_table(),'listID', $_GET['listID'] );
            $listinfo = get_post($_GET['listID']);
            $list = '&listID=' . $_REQUEST['listID'];
            $listname = 'for ' . $listinfo->post_title;
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Subscribers_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        ?>
	<div id="taskbar" class="lists-dashboard rounded group"> 
		<div id="button-area">  
			
			<a class="btn btn-primary btn-large" href="?page=<?php 
        echo $_REQUEST['page'];
        ?>
&view=add<?php 
        echo $list;
        ?>
"><?php 
        _e('Add Subscriber', 'sendpress');
        ?>
</a>
		</div>
		<h2><?php 
        _e('Subscribers', 'sendpress');
        ?>
 <?php 
        if (isset($listname)) {
            echo $listname;
        }
        ?>
 </h2>
	</div>
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form id="movies-filter" method="get">
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="page" value="<?php 
        echo $_REQUEST['page'];
        ?>
" />
	    <?php 
        if (isset($_GET['listID']) && $_GET['listID'] > 0) {
            ?>
	    <input type="hidden" name="listID" value="<?php 
            echo $_GET['listID'];
            ?>
" />
	    <?php 
        }
        ?>
	    <input type="hidden" name="view" value="<?php 
        echo $_GET['view'];
        ?>
" />

	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo $_GET['page'];
        ?>
" name="page" />
		
		<input type='hidden' value="unlink-lisk" name="action" />
		<?php 
        if (isset($_GET['listID'])) {
            ?>
		<input type='hidden' name="listid" value="<?php 
            echo $_GET['listID'];
            ?>
" />
		<?php 
        }
        ?>

		<br>
		<a class="btn btn-danger " data-toggle="modal" href="#sendpress-empty-list" ><i class="icon-warning-sign "></i> <?php 
        _e('Remove All Subscribers from List', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
<div class="modal  fade" id="sendpress-empty-list" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal">×</button>
				<h3><?php 
        _e('Really? Remove All Subscribers from this list.', 'sendpress');
        ?>
</h3>
			</div>
			<div class="modal-body">
				<p><?php 
        _e('This will remove all subscribers from the list', 'sendpress');
        ?>
.</p>
			</div>
			<div class="modal-footer">
			<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('No! I was Joking', 'sendpress');
        ?>
</a><a href="<?php 
        echo SendPress_Admin::link('Subscribers_Subscribers') . $list;
        ?>
&action=remove-subscribers" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Remove All Subscribers', 'sendpress');
        ?>
</a>
			</div>
		</div>
	</div>
</div>
	<?php 
    }