function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->id)) {
         $lists = SendPress_Data::get_list_ids_for_subscriber($info->id);
         //$lists = explode(',',$info->listids);
         foreach ($lists as $list) {
             $status = SendPress_Data::get_subscriber_list_status($list->listID, $info->id);
             if ($status->statusid == 1) {
                 SendPress_Data::update_subscriber_status($list->listID, $info->id, '2');
             }
         }
         SPNL()->db("Subscribers_Tracker")->open($info->report, $info->id, 4);
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
 function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     //$user = SendPress_Option::get( 'mandrilluser' );
     //$pass = SendPress_Option::get( 'mandrillpass' );
     $from_email = SendPress_Option::get('fromemail');
     //$hdr = new SendPress_SendGrid_SMTP_API();
     $m = SendPress_Option::get_sender('sendpress');
     //$hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email) );
     //$phpmailer->AddCustomHeader(sprintf( 'X-SMTPAPI: %s', $hdr->asJSON() ) );
     $info = array("X-SP-METHOD" => "WPED.co", "X-SP-LIST" => $list_id, "X-SP-REPORT" => $report_id, "X-SP-SUBSCRIBER" => $sid, "X-SP-DOMAIN" => home_url());
     $url = 'https://gateway.wped.co/send/';
     //$url = 'http://spnl.dev/';
     $verify_ssl = true;
     if (isset($m['verifyssl']) && $m['verifyssl'] == 'donotverify') {
         $verify_ssl = false;
         $url = 'http://api.wped.co/send';
     }
     $message = array('to' => array(array('email' => $to)), 'subject' => $subject, 'html' => $html, 'text' => $text, 'from_email' => $from_email, 'from_name' => SendPress_Option::get('fromname'), 'headers' => $info, 'inline_css' => true, 'subaccount' => $m['sendpress-key'], 'metadata' => array('sender' => 'SPNL', 'return' => home_url()));
     $response = wp_remote_post($url, array('method' => 'POST', 'timeout' => 45, 'redirection' => 5, 'httpversion' => '1.0', 'blocking' => true, 'headers' => array('Content-Type' => 'application/json'), 'body' => json_encode($message), 'sslverify' => $verify_ssl, 'cookies' => array()));
     if (is_wp_error($response)) {
         $error_message = $response->get_error_message();
         SPNL()->log->add('WPED Sending', $error_message, 0, 'sending');
         return false;
     } else {
         return true;
     }
     return false;
 }
 function prerender()
 {
     $ip = $_SERVER['REMOTE_ADDR'];
     //print_r($info);
     $info = $this->data();
     if (isset($info->listids)) {
         $lists = explode(',', $info->listids);
         foreach ($lists as $list_id) {
             if ($list_id > 0) {
                 $status = SendPress_Data::get_subscriber_list_status($list_id, $info->id);
                 if (!isset($status) || $status->status != '2') {
                     SendPress_Data::update_subscriber_status($list_id, $info->id, '2');
                 }
             }
         }
     }
     if (SendPress_Option::get('confirm-page') == 'custom') {
         $page = SendPress_Option::get('confirm-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 wp_safe_redirect(esc_url_raw($plink));
                 exit;
             }
         }
     }
 }
 static function external($template_id, $email_id, $subscriber_id, $example)
 {
     $canspam = SendPress_Option::get('canspam');
     if ($canspam != '' && $canspam != false) {
         return nl2br($canspam);
     }
     return '';
 }
    function html($sp)
    {
        ?>
  <?php 
        if (SendPress_Option::get('import_error', false) == true) {
            ?>
	<div class="alert alert-danger">
  <?php 
            _e('We had a problem saving your upload', 'sendpress');
            ?>
.
  </div>
  <?php 
        }
        ?>
  <div id="taskbar" class="lists-dashboard rounded group"> 
	<h2><?php 
        _e('Import CSV to ', 'sendpress');
        echo get_the_title($_GET['listID']);
        ?>
</h2>
	</div>
<div class="boxer">
	<div class="boxer-inner">
	<!-- Forms are NOT created automatically, so you need to wrap the table in one to use features like bulk actions -->
	<form method="post" enctype="multipart/form-data" accept-charset="utf-8" >
		<!-- For plugins, we also need to ensure that the form posts back to our current page -->
	    <input type="hidden" name="listID" value="<?php 
        echo SPNL()->validate->int($_GET['listID']);
        ?>
" />
	   	<table>
	   	<tr>
    <td class="left_label"> <?php 
        echo $label;
        ?>
    </td>
    <td>
        <input type="file" name="uploadfiles[]" id="uploadfiles" size="35" class="uploadfiles" />
        <input class="button-primary" type="submit" name="uploadfile" id="uploadfile_btn" value="Upload"  />
     
    </td>
  </tr> 
 	</table>
   
<?php 
        SendPress_Option::set('import_error', false);
        SendPress_Data::nonce_field();
        ?>
	   </form>
</div>
</div>
<?php 
    }
 function module_deactivate_sendpress_pro()
 {
     $path = $_POST['plugin_path'];
     $pro_options = SendPress_Option::get('pro_plugins');
     if (!preg_match('/sendpress-pro.php/i', $path)) {
         if (preg_match('/sendpress-pro/i', $path)) {
             //make sure the plugin loads from sendpress pro
             $pro_options[$path] = false;
             SendPress_Option::set('pro_plugins', $pro_options);
         }
     } else {
         deactivate_plugins($path);
     }
 }
Пример #7
0
 function sendpress($phpmailer)
 {
     // Set the mailer type as per config above, this overrides the already called isMail method
     $phpmailer->Mailer = 'smtp';
     // We are sending SMTP mail
     $phpmailer->IsSMTP();
     // Set the other options
     $phpmailer->Host = 'smtp.sendgrid.net';
     $phpmailer->Port = 25;
     // If we're using smtp auth, set the username & password
     $phpmailer->SMTPAuth = TRUE;
     $phpmailer->Username = SendPress_Option::get('sp_user');
     $phpmailer->Password = SendPress_Option::get('sp_pass');
     return $phpmailer;
 }
 static function send_mail_cron()
 {
     //@ini_set('max_execution_time',0);
     global $wpdb;
     $count = SendPress_Option::get('emails-per-hour');
     $count = SendPress_Option::get('wpcron-per-call', 25);
     $email_count = 0;
     $attempts = 0;
     if (SendPress_Manager::limit_reached($count)) {
         return;
     }
     SendPress_Email_Cache::build_cache();
     for ($i = 0; $i < $count; $i++) {
         $email = SendPress_Data::get_single_email_from_queue();
         if ($email != null) {
             $attempts++;
             SendPress_Data::queue_email_process($email->id);
             $result = SendPress_Manager::send_email_from_queue($email);
             $email_count++;
             if ($result) {
                 if ($result === true) {
                     $wpdb->update(SendPress_Data::queue_table(), array('success' => 1, 'inprocess' => 3), array('id' => $email->id));
                     //( $sid, $rid, $lid=null, $uid=null, $ip=null, $device_type=null, $device=null, $type='confirm' )
                     //$wpdb->update( SendPress_Data::queue_table() , array('success'=>1,'inprocess'=>3 ) , array('id'=> $email->id ));
                     //$wpdb->insert(SendPress_Data::subscriber_tracker_table() , array('subscriberID'=>$email->subscriberID,'emailID'=>$email->emailID,'sent_at' => get_gmt_from_date( date('Y-m-d H:i:s') )) );
                     SPNL()->db("Subscribers_Tracker")->add(array('subscriber_id' => intval($email->subscriberID), 'email_id' => intval($email->emailID)));
                     SendPress_Data::add_subscriber_event($email->subscriberID, $email->emailID, $email->listID, null, null, null, null, 'send');
                 } else {
                     $wpdb->update(SendPress_Data::queue_table(), array('success' => 2, 'inprocess' => 3), array('id' => $email->id));
                     SendPress_Data::add_subscriber_event($email->subscriberID, $email->emailID, $email->listID, null, null, null, null, 'bounce');
                     SendPress_Data::bounce_subscriber_by_id($email->subscriberID);
                 }
                 //$wpdb->insert( $this->subscriber_open_table(),  $senddata);
                 $count++;
                 //SendPress_Data::update_report_sent_count( $email->emailID );
             } else {
                 $wpdb->update(SendPress_Data::queue_table(), array('attempts' => $email->attempts + 1, 'inprocess' => 0, 'last_attempt' => date('Y-m-d H:i:s')), array('id' => $email->id));
             }
         } else {
             //We ran out of emails to process.
             break;
         }
         set_time_limit(30);
     }
     return;
 }
 static function external($template_id, $email_id, $subscriber_id, $e)
 {
     //maybe saved link?
     $link_data = array("id" => $subscriber_id, "view" => 'manage');
     $code = SendPress_Data::encrypt($link_data);
     $link = SendPress_Manager::public_url($code);
     if (SendPress_Option::get('manage-page') == 'custom') {
         $page = SendPress_Option::get('manage-page-id');
         if ($page != false) {
             $plink = get_permalink($page);
             if ($plink != "") {
                 $link = $plink . '?spms=' . $code;
             }
         }
     }
     return $link;
 }
 function pn_select($sub_id, $listid)
 {
     $pro_list = SendPress_Option::get('pro_notification_lists');
     if (isset($pro_list['post_notifications']['id']) && $listid == $pro_list['post_notifications']['id']) {
         $current = SendPress_Data::get_subscriber_meta($sub_id, 'post_notifications', $listid);
         $info = SendPress_Data::get_post_notification_types();
         echo '<select name="' . $listid . '-pn">';
         echo "<option cls value='-1' >No Status</option>";
         foreach ($info as $key => $value) {
             $cls = '';
             if ($current == $key) {
                 $cls = " selected='selected' ";
             }
             echo "<option {$cls} value='" . $key . "'>" . $value . "</option>";
         }
         echo '</select> ';
     }
 }
Пример #11
0
 function auto_cron()
 {
     // make sure we're in wp-cron.php
     if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) {
         // make sure a secret string is provided in the ur
         if (isset($_GET['action']) && $_GET['action'] == 'sendpress') {
             $time_start = microtime(true);
             $count = SendPress_Data::emails_in_queue();
             $bg = 0;
             if ($count > 0) {
                 SendPress_Queue::send_mail();
                 $count = SendPress_Data::emails_in_queue();
             } else {
                 SPNL()->log->prune_logs();
                 SendPress_Data::clean_queue_table();
                 //SendPress_Logging::prune_logs();
                 $bg = 1;
             }
             $attempted_count = SendPress_Option::get('autocron-per-call', 25);
             $pro = 0;
             if (defined('SENDPRESS_PRO_VERSION')) {
                 $pro = SENDPRESS_PRO_VERSION;
             }
             $stuck = SendPress_Data::emails_stuck_in_queue();
             $limit = SendPress_Manager::limit_reached();
             $emails_per_day = SendPress_Option::get('emails-per-day');
             $emails_per_hour = SendPress_Option::get('emails-per-hour');
             $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
             $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
             $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails);
             $time_end = microtime(true);
             $time = $time_end - $time_start;
             echo json_encode(array("background" => $bg, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3)));
             die;
         }
     }
 }
 /**
  * Enqueue styles and scripts needed for the pointers.
  */
 function enqueue()
 {
     if (!current_user_can('manage_options')) {
         return;
     }
     SendPress_Option::set('allow_tracking', '');
     $track = SendPress_Option::get('allow_tracking');
     $tour = false;
     //SendPress_Option::get( 'intro_tour' );
     if (($track == false || $track == '') && !isset($_GET['allow_tracking'])) {
         wp_enqueue_style('wp-pointer');
         wp_enqueue_script('jquery-ui');
         wp_enqueue_script('wp-pointer');
         wp_enqueue_script('utils');
         add_action('admin_print_footer_scripts', array($this, 'tracking_request'));
     } else {
         if ($tour == 'false' || $tour == false) {
             /*
             add_action( 'admin_print_footer_scripts', array( $this, 'intro_tour' ) );
             add_action( 'admin_head', array( $this, 'admin_head' ) );
             */
         }
     }
 }
    function html($sp)
    {
        SendPress_Tracking::event('Queue Tab');
        if (isset($_GET['cron'])) {
            $sp->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        //$sp->fetch_mail_from_queue();
        $sp->cron_start();
        //echo $sp->get_key(). "<br>";
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        /*
        		$x = $sp->encrypt_data($open_info);
        
        	echo $x."<br>";
        	$x = $sp->decrypt_data($x);
        
        	print_r($x);
        		echo "<br>";
        
        	$d = $_GET['t'];
        	$x = $sp->decrypt_data($d);
        
        	print_r($x->id);
        		echo "<br>";
        	
        	
        	//echo wp_get_schedule('sendpress_cron_action_run');
        	//
        	$time_delay =  SendPress_Option::get('time-delay');
        	echo $time_delay;
        	echo date('l jS \of F Y H:i:s A',$time_delay );
        	echo "<br>";
        	$time = date('H:i:s');
        
        echo $time;//11:09
        	$time = date('H:i:s', $time_delay);
        
        echo $time;//11:09
        */
        $autocron = SendPress_Option::get('autocron', 'no');
        if ($autocron == 'yes') {
            $api_info = json_decode(SendPress_Cron::get_info());
            if (isset($api_info->active) && $api_info->active === 0) {
                echo "<p class='alert alert-danger'><strong>Oh no!</strong> It looks like AutoCron disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
                delete_transient('sendpress_autocron_cache');
                SendPress_Option::set('autocron', 'no');
            } else {
                if (isset($api_info->lastcheck)) {
                    echo "<p class='alert alert-success'><strong>Looking good!</strong> Autocron is running and last checked your site at:&nbsp;" . $api_info->lastcheck . " UTC</p>";
                }
            }
        } else {
            echo "<p class='alert alert-info'><strong>Howdy.</strong> It looks like AutoCron was not enabled or it disconnected itself. To get max send speed please re-enable it <a href='" . SendPress_Admin::link('Settings_Account') . "'>here</a>.</p>";
        }
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">
	<a class="btn btn-large btn-default " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
        echo $txt;
        ?>
</a>

	<a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
        _e('Send Emails Now', 'sendpress');
        ?>
</a>
	</div>
	</div>
	<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        //print_r(SendPress_Data::emails_stuck_in_queue());
        ?>

		
		<h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
		<h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
		<small><?php 
        _e('You can adjust these settings here', 'sendpress');
        ?>
: <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"><?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.</small>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- 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');
        ?>
" 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>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page($_GET['page']);
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" 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? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', '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('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" 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('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
    function html($sp)
    {
        global $sendpress_sender_factory;
        $senders = $sendpress_sender_factory->get_all_senders();
        ksort($senders);
        $method = SendPress_Option::get('sendmethod');
        $fe = __('From Email', 'sendpress');
        $fn = __('From Name', 'sendpress');
        ?>
<!--
<div style="float:right;" >
  <a href="" class="btn btn-large btn-default" ><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>
-->


<form method="post" id="post">
	<br class="clear">
	<br class="clear">
	<div class="sp-row">
		<div class="sp-50 sp-first">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-user"></span> ' . __('Sending Email', 'sendpress'));
        ?>
			<div class="form-group">
				<label for="fromname"><?php 
        _e('From Name', 'sendpress');
        ?>
</label>
				<input name="fromname" tabindex=1 type="text" id="fromname" value="<?php 
        echo SendPress_Option::get('fromname');
        ?>
" class="form-control">
			</div>
			<div class="form-group">
				<label for="fromemail"><?php 
        _e('From Email', 'sendpress');
        ?>
</label>
				<input name="fromemail" tabindex=2 type="text" id="fromemail" value="<?php 
        echo SendPress_Option::get('fromemail');
        ?>
" class="form-control">
			</div>

			<?php 
        $this->panel_end();
        ?>
		</div >
		<div class="sp-50">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Test Email', 'sendpress'));
        ?>

			<div class="form-group">
				<label for="testemail"><?php 
        _e('Where to send Test Email', 'sendpress');
        ?>
</label>
				<input name="testemail" type="text" id="test-email-main" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>
			</div>
			<div class="sp-row">
				<div class="sp-50 sp-first">
					<button class="btn btn-primary btn-block" value="test" name="test" type="submit"><?php 
        _e('Send Test!', 'sendpress');
        ?>
</button>
				</div>
				<div class="sp-50">
					<button class="btn btn-danger btn-block" data-toggle="modal" data-target="#debugModal" type="button"><?php 
        _e('Debug Info', 'sendpress');
        ?>
</button>
				</div>
			</div>
			<div class="sp-row">
				<br>
				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									<?php 
        _e('Click to View Last Error', 'sendpress');
        ?>
								</a>
							</h4>
						</div>
						<div id="collapseOne" class="panel-collapse collapse">
							<div class="panel-body">

								<?php 
        $logs = SPNL()->log->get_connected_logs(array('posts_per_page' => 1, 'log_type' => 'sending'));
        if (!empty($logs)) {
            foreach ($logs as $log) {
                echo "<strong>" . $log->post_date . "</strong>  " . $log->post_title;
                echo "<br>" . $log->post_content;
            }
        }
        ?>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php 
        $this->panel_end();
        ?>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title"><?php 
        _e('Sending Account Setup', 'sendpress');
        ?>
</h3>
		</div>
		<div class="panel-body">

			<input type="hidden" name="action" value="account-setup" />
			
			<?php 
        if (count($senders) < 3) {
            $c = 0;
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($c >= 1) {
                    $class = "margin-left: 4%";
                }
                echo "<div style=' float:left; width: 48%; {$class}' id='{$key}'>";
                ?>
					<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Send Emails via', 'sendpress');
                ?>
						<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
                $c++;
            }
        } else {
            ?>
				<div class="tabbable tabs-left">
					<ul class="nav nav-tabs">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "class='active'";
                }
                echo "<li {$class}><a href='#{$key}' data-toggle='tab'>";
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    echo '<span class="glyphicon glyphicon-ok-sign"></span> ';
                }
                echo $sender->label();
                echo "</a></li>";
            }
            ?>
					</ul>
					<div class="tab-content" style="display:block;">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "active";
                }
                echo "<div class='tab-pane {$class}' id='{$key}'>";
                ?>
							<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Activate', 'sendpress');
                ?>
								<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
            }
            ?>

						</div>
					</div>


					<p > <span class="glyphicon glyphicon-ok-sign"></span> = <?php 
            _e('Currently Active', 'sendpress');
            ?>
</p>
					<?php 
        }
        ?>

				</div>
			</div>
			<br class="clear">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title"><?php 
        _e('Advanced Sending Options', 'sendpress');
        ?>
</h3>
				</div>
				<div class="panel-body">
					<div class="boxer form-box">
						<div style="float: right; width: 45%;">
							<h2><?php 
        _e('Email Sending Limits', 'sendpress');
        ?>
</h2>

							<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $offset = get_option('gmt_offset') * 60 * 60;
        // Time offset in seconds
        $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
        //print_r(wp_get_schedules());
        printf(__('You have sent <strong>%d</strong> emails so far today.', 'sendpress'), $emails_so_far);
        ?>
.<br><br>
<input type="text" size="6" name="emails-per-day" value="<?php 
        echo $emails_per_day;
        ?>
" /> <?php 
        _e('Emails Per Day', 'sendpress');
        ?>
<br><br>
<input type="text" size="6" name="emails-per-hour" value="<?php 
        echo $emails_per_hour;
        ?>
" /> <?php 
        _e('Emails Per Hour', 'sendpress');
        ?>
<br><br>
<h2><?php 
        _e('Email Encoding', 'sendpress');
        ?>
</h2>
<?php 
        $charset = SendPress_Option::get('email-charset', 'UTF-8');
        ?>
Charset:
<select name="email-charset" id="">

	<?php 
        $charsete = SendPress_Data::get_charset_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Squares or weird characters displaying in your emails select the charset for your language', 'sendpress');
        ?>
.
<br><br>
<?php 
        _e('Encoding', 'sendpress');
        ?>
: <select name="email-encoding" id="">
<?php 
        $charset = SendPress_Option::get('email-encoding', '8bit');
        $charsete = SendPress_Data::get_encoding_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Older versions of SendPress used', 'sendpress');
        ?>
 "quoted-printable"
<br><br><br>
<h2><?php 
        _e('AutoCron Information', 'sendpress');
        ?>
</h2>
<?php 
        $api_info = json_decode(SendPress_Cron::get_info());
        $autocron = SendPress_Option::get('autocron', 'no');
        if ($autocron == 'yes') {
            ?>
<ul>
	<li>Last Check: <?php 
            echo $api_info->lastcheck;
            ?>
 UTC</li>
	<li>Errors: <?php 
            echo $api_info->errors;
            ?>
 </li>
	<li>Active: <?php 
            if ($api_info->active == 0) {
                echo "false";
            } else {
                echo "true";
            }
            ?>
 </li>
	
</ul>

<?php 
        } else {
            ?>
	<p>AutoCron is not enabled.</p>
<?php 
        }
        ?>

<br class="clear">
</div>
<div style="width: 45%; margin-right: 10%">
	<?php 
        $tl = SendPress_Option::get('autocron', 'no');
        ?>
	<h2><?php 
        _e('SendPress Pro Auto Cron', 'sendpress');
        ?>
</h2>
	<p>At least once every hour we visit your site, just like a "cron" job.<br>There's no setup involved. Easy and hassle free.</p>

	<button id="sp-enable-cron" <?php 
        if ($tl == 'yes') {
            echo "style='display:none;'";
        }
        ?>
 class="btn  btn-success">Enable Pro Auto Cron</button><button id="sp-disable-cron" <?php 
        if ($tl == 'no') {
            echo "style='display:none;'";
        }
        ?>
 class="btn  btn-danger">Disable Pro Auto Cron</button>
	<br><br>
	<strong>Enable AutoCron and receive a 20% discount code for SendPress Pro. Your discount code will be emailed to you.</strong>
	<br><br>
	<p class="well">
		<strong>Without SendPress Pro</strong><br>
		Auto Cron is limited to a max of <strong>3,000*</strong> emails per day at a max rate of <strong>125*</strong> emails per hour.
		<br><br>
		<strong>With SendPress Pro</strong><br>
		Auto Cron starts at a max of <strong>12,000*</strong> emails per day at a max rate of <strong>500*</strong> emails per hour. Sending of up to <strong>36,000*</strong> emails a day available provided your server can handle it. <br><br><br>
		<strong>*</strong>Auto Cron will not send faster then your <strong>Email Sending Limits</strong> to the right.<br><br>Please make sure you follow the rules of your hosting provider or upgrade to <strong><a href="http://sendpress.com">SendPress Pro</a></strong> to use a third-party service.
	</p>
	<small>Pro Auto Cron does collect some data about your website and usage of SendPress. It will not track any user details, so your security and privacy are safe with us.</small>



<!--
  WordPress Cron: Next run @ <?php 
        echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
        ?>
<br><br>-->

<br class="clear">
</div>
</div>
</div>
</div>


<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        wp_nonce_field($sp->_nonce_value);
        ?>
<input type="submit" class="btn btn-primary" value="Save"/> <a href="" class="btn btn-default"><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a>
</form>
<form method="post" id="post-test" class="form-inline">
	<input type="hidden" name="action" value="send-test-email" />
	<input name="testemail" type="hidden" id="test-email-form" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>

	<br class="clear">




	<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        //SendPress General Nonce
        wp_nonce_field($sp->_nonce_value);
        ?>
</form>
<?php 
        $error = SendPress_Option::get('phpmailer_error');
        $hide = 'hide';
        if (!empty($error)) {
            $hide = '';
            $phpmailer_error = '<pre>' . $error . '</pre>';
            ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			$('#debugModal').modal('show');
		});
	</script>

	<?php 
        }
        ?>


<div class="modal fade" id="debugModal" tabindex="-1" 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('SMTP Debug Info', 'sendpress');
        ?>
</h3>
			</div>
			<div class="modal-body">
				<?php 
        if (!empty($phpmailer_error)) {
            $server = "smtp.sendgrid.net";
            $port = "25";
            $port2 = "465";
            $port3 = "587";
            $timeout = "1";
            if ($server and $port and $timeout) {
                $port25 = @fsockopen("{$server}", $port, $errno, $errstr, $timeout);
                $port465 = @fsockopen("{$server}", $port2, $errno, $errstr, $timeout);
                $port587 = @fsockopen("{$server}", $port3, $errno, $errstr, $timeout);
            }
            if (!$port25) {
                echo '<div class="alert alert-error">';
                _e('Port 25 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            if (!$port465) {
                echo '<div class="alert alert-error">';
                _e('Port 465 seems to be blocked. Gmail may have trouble', 'sendpress');
                echo '</div>';
            }
            if (!$port587) {
                echo '<div class="alert alert-error">';
                _e('Port 587 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            echo $phpmailer_error;
        }
        ?>


				<pre>
					<?php 
        $whoops = SendPress_Option::get('last_test_debug');
        if (empty($whoops)) {
            _e('No Debug info saved.', 'sendpress');
        } else {
            echo $whoops;
        }
        ?>
				</pre>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
			</div>
		</div>
	</div></div>
	<?php 
    }
    function help_debug()
    {
        global $wp_version, $wpdb;
        $browser = new SendPress_Browser();
        echo "<b>WordPress Version</b>: " . $wp_version . "<br>";
        echo "<b>SendPress Version</b>: " . SENDPRESS_VERSION . "<br>";
        if (defined('SENDPRESS_PRO_VERSION')) {
            echo "<b>SendPress Pro Version</b>: " . SENDPRESS_VERSION . "<br>";
        }
        echo '<b>PHP Version</b>: ' . phpversion() . '<br>';
        $mem = (int) ini_get('memory_limit');
        $used = function_exists('memory_get_usage') ? round(memory_get_usage() / 1024 / 1024, 2) : 0;
        if (!empty($mem) && !empty($used)) {
            $prec = round($used / $mem * 100, 0);
        }
        echo '<b>PHP Memory Limit</b>: ' . $mem . __(' MByte') . '<br>';
        echo '<b>PHP Memory Used</b>: ' . $used . __(' MByte') . '<br>';
        echo '<b>MySQL Version</b>: ' . $wpdb->db_version() . '<br><br>';
        echo '<b>Send Setup</b>: ' . SendPress_Option::get('sendmethod') . '<br><br>';
        SendPress_DB_Tables::check_setup();
        /*
        		echo "<b>Ports:</b><br>";
        	  	$server  = "smtp.sendgrid.net";
        	  	$port   = "25";
        	  	$port2   = "465";
        	  	$port3   = "587";
        	  	$timeout = "1";
        
        	  if ($server and $port and $timeout) {
        	    $port25 =  @fsockopen("$server", $port, $errno, $errstr, $timeout);
        	    $port465 =  @fsockopen("$server", $port2, $errno, $errstr, $timeout);
        	    $port587 =  @fsockopen("$server", $port3, $errno, $errstr, $timeout);
        	  }	
        	  echo "Port 25: ";
        	  if(!$port25){
        	  	 _e('blocked','sendpress');
        	  } else {
        	  	_e('open','sendpress');
        	  }
        	   echo "<br>Port 465: ";
        	  if(!$port465){
        	  	 _e('blocked','sendpress');
        	  } else {
        	  	_e('open','sendpress');
        	  }
        	   echo "<br>Port 587: ";
        	  if(!$port587){
        	  	 _e('blocked','sendpress');
        	  } else {
        	  	_e('open','sendpress');
        	  }  */
        ?>
<br><br>

	  	<b>Support Info:</b>
	  	<textarea readonly="readonly" class="sendpress-sysinfo"  name="sendpress-sysinfo" title="<?php 
        _e('To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'sendpress');
        ?>
"><?php 
        echo esc_html($this->display());
        ?>
</textarea>



	  <?php 
    }
 function send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     $phpmailer = new SendPress_PHPMailer();
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $html = $this->change($html, 'UTF-8', $charset);
         $text = $this->change($text, 'UTF-8', $charset);
         $subject = $this->change($subject, 'UTF-8', $charset);
     }
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     //$subject = str_replace(array('’','“','�','–'),array("'",'"','"','-'),$subject);
     //$html = str_replace(chr(194),chr(32),$html);
     //$text = str_replace(chr(194),chr(32),$text);
     //return $email;
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $content_type = 'text/html';
     $phpmailer->MsgHTML($html);
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     $hosting = SendPress_Option::get('website-hosting-provider');
     if ($hosting == 'godaddy') {
         // We are sending SMTP mail
         $phpmailer->IsSMTP();
         // Set the other options
         $phpmailer->Host = 'relay-hosting.secureserver.net';
     }
     // If we don't have a charset from the input headers
     //if ( !isset( $charset ) )
     //$charset = get_bloginfo( 'charset' );
     // Set the content-type and charset
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     //$phpmailer->Sender = '*****@*****.**';//SendPress_Option::get('fromemail');
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     //$phpmailer->AddCustomHeader( sprintf( 'X-SP-MID: %s',$email->messageID ) );
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: website');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     $phpmailer->AddCustomHeader('X-SP-LIST: ' . $list_id);
     $phpmailer->AddCustomHeader('X-SP-REPORT: ' . $report_id);
     $phpmailer->AddCustomHeader('X-SP-SUBSCRIBER: ' . $sid);
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
         //$this->last_send_smtp_debug = $smtp_debug;
     }
     if ($result != true) {
         $log_message = 'Website <br>';
         $log_message .= $to . "<br>";
         if ($istest == true) {
             $log_message .= "<br><br>";
             $log_message .= $smtp_debug;
         }
         //$phpmailer->ErrorInfo
         SPNL()->log->add($phpmailer->ErrorInfo, $log_message, 0, 'sending');
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
         //$msg .= 'The full debugging output(exported mailer) is shown below:\n';
         //$msg .= var_export($phpmailer,true)."\n";
         //$this->append_log($msg);
     }
     return $result;
 }
    function html()
    {
        global $is_IE;
        global $post_ID, $post;
        /*
        if (  wp_is_mobile() &&
        	 ! ( $is_IE && preg_match( '/MSIE [5678]/', $_SERVER['HTTP_USER_AGENT'] ) ) ) {
        
        	wp_enqueue_script('editor-expand');
        	$_wp_autoresize_on = true;
        }
        */
        $emailID = SPNL()->validate->_int('emailID');
        if ($emailID > 0) {
            $post = get_post($emailID);
            $post_ID = $post->ID;
        }
        if ($post->post_type !== 'sp_newsletters') {
            SendPress_Admin::redirect('Emails');
        }
        $template_id = get_post_meta($post->ID, '_sendpress_template', true);
        ?>
     <form method="post" id="post" role="form">
        <input type="hidden" name="post_ID" id="post_ID" value="<?php 
        echo $post->ID;
        ?>
" />
        <input type="hidden" name="post_type" id="post_type" value="sp_newsletters" />
        <input type="hidden" name="action" id="action" value="save-email" />
       <div  >
       <div style="float:right;" class="btn-toolbar">
            <div id="sp-cancel-btn" class="btn-group">
               <?php 
        if ($post->post_status != 'sp-autoresponder') {
            ?>
                <a href="?page=<?php 
            echo SPNL()->validate->page();
            ?>
" id="cancel-update" class="btn btn-default"><?php 
            echo __('Cancel', 'sendpress');
            ?>
</a>&nbsp;
            
            <?php 
        } else {
            ?>
     		<a href="<?php 
            echo SendPress_Admin::link('Emails_Autoresponder');
            ?>
" id="cancel-update" class="btn btn-default"><?php 
            echo __('Cancel', 'sendpress');
            ?>
</a>&nbsp;
           
            <?php 
        }
        ?>
            </div>
            <div class="btn-group">
            
             <button class="btn btn-default " type="submit" value="save" name="submit"><i class="icon-white icon-ok"></i> <?php 
        echo __('Update', 'sendpress');
        ?>
</button>
           
            <?php 
        if (SendPress_Admin::access('Emails_Send') && $post->post_status != 'sp-autoresponder') {
            ?>
            <button class="btn btn-primary " type="submit" value="save-next" name="submit"><i class="icon-envelope icon-white"></i> <?php 
            echo __('Send', 'sendpress');
            ?>
</button>
            <?php 
        }
        ?>
            </div>
        </div>
	

</div>
        <h2><?php 
        _e('Edit Email Content', 'sendpress');
        ?>
</h2>
        <br>
        <?php 
        $this->panel_start('<span class="glyphicon glyphicon-envelope"></span> ' . __('Subject', 'sendpress'));
        ?>
        <input type="text" name="post_subject" size="30" tabindex="1" class="form-control" value="<?php 
        echo esc_attr(htmlspecialchars(get_post_meta($post->ID, '_sendpress_subject', true)));
        ?>
" id="email-subject" autocomplete="off" />
        <?php 
        $this->panel_end();
        ?>
        <div class="sp-row">
<div class="sp-75 sp-first">
<!-- Nav tabs -->
<?php 
        $enable_edits = SendPress_Option::get('enable_email_template_edit');
        ?>
<ul class="nav nav-tabs">
  <li class="active"><a href="#content-area-one-tab" data-toggle="tab"><?php 
        _e('Main Content', 'sendpress');
        ?>
</a></li>
  <?php 
        if ($enable_edits) {
            ?>
  	<li><a href="#header-content" data-toggle="tab"><?php 
            _e('Header', 'sendpress');
            ?>
</a></li>
  	<li><a href="#footer-content" data-toggle="tab"><?php 
            _e('Footer', 'sendpress');
            ?>
</a></li>
  	<?php 
        }
        ?>
 
  <!--
  <li><a href="#messages" data-toggle="tab">Messages</a></li>
  <li><a href="#settings" data-toggle="tab">Settings</a></li>
  -->
</ul>

<div class="tab-content" style="display:block;">
  <div class="tab-pane in active" id="content-area-one-tab">
  <?php 
        wp_editor($post->post_content, 'content_area_one_edit', array('dfw' => true, 'drag_drop_upload' => true, 'tabfocus_elements' => 'insert-media-button-1,save-post', 'editor_height' => 360, 'tinymce' => array('resize' => false, 'wp_autoresize_on' => !empty($_wp_autoresize_on) && get_user_setting('editor_expand', 'on') === 'on', 'add_unload_trigger' => false)));
        //wp_editor($post->post_content,'content_area_one_edit');
        ?>
</div>

	<?php 
        if ($enable_edits) {
            ?>
		<div class="tab-pane" id="header-content">
			<?php 
            wp_editor(get_post_meta($post->ID, '_header_content', true), 'header_content_edit', array('dfw' => true, 'drag_drop_upload' => true, 'tabfocus_elements' => 'insert-media-button-1,save-post', 'editor_height' => 360, 'tinymce' => array('resize' => false, 'wp_autoresize_on' => !empty($_wp_autoresize_on) && get_user_setting('editor_expand', 'on') === 'on', 'add_unload_trigger' => false)));
            ?>

		</div>
		<div class="tab-pane" id="footer-content">
			<?php 
            wp_editor(get_post_meta($post->ID, '_footer_content', true), 'footer_content_edit', array('dfw' => true, 'drag_drop_upload' => true, 'tabfocus_elements' => 'insert-media-button-1,save-post', 'editor_height' => 360, 'tinymce' => array('resize' => false, 'wp_autoresize_on' => !empty($_wp_autoresize_on) && get_user_setting('editor_expand', 'on') === 'on', 'add_unload_trigger' => false)));
            ?>

		</div>
		<?php 
        }
        ?>
   <!--
  <div class="tab-pane fade" id="messages"><?php 
        wp_editor($post->post_content, 'content-3');
        ?>
</div>
  <div class="tab-pane fade" id="settings"><?php 
        wp_editor($post->post_content, 'content-4');
        ?>
</div>
  -->
</div>

</div>
<div class="sp-25">
<br><br>

	<?php 
        $this->panel_start(__('Template', 'sendpress'));
        ?>
	<select name="template" class="form-control">
	<?php 
        $args = array('post_type' => 'sp_template', 'post_status' => array('sp-standard'), 'posts_per_page' => -1);
        $the_query = new WP_Query($args);
        if ($the_query->have_posts()) {
            echo '<optgroup label="SendPress Templates">';
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $temp_id = $the_query->post->ID;
                $s = '';
                if ($temp_id == $template_id) {
                    $s = 'selected';
                }
                echo '<option value="' . $temp_id . '" ' . $s . '>' . get_the_title() . '</option>';
            }
            echo '</optgroup>';
        } else {
            echo '<option value="0" ></option>';
        }
        $args = array('post_type' => 'sp_template', 'post_status' => array('sp-custom'), 'posts_per_page' => -1);
        $the_query = new WP_Query($args);
        if ($the_query->have_posts()) {
            echo '<optgroup label="Custom Templates">';
            while ($the_query->have_posts()) {
                $the_query->the_post();
                $temp_id = $the_query->post->ID;
                $s = '';
                if ($temp_id == $template_id) {
                    $s = 'selected';
                }
                echo '<option value="' . $temp_id . '" ' . $s . '>' . get_the_title() . '</option>';
            }
            echo '</optgroup>';
        }
        ?>
	
	</select>
	<?php 
        $this->panel_end();
        ?>
</div>
</div>
<div class="well clear">
            <h2><?php 
        _e('Test This Email', 'sendpress');
        ?>
</h2>
            <p><input type="text" name="test-email" value="" class="sp-text" placeholder="<?php 
        echo __('Insira um email para o envio de teste.', 'jaiminho');
        ?>
." /></p>
            <button class="btn btn-success" name="submit" type="submit" value="send-test"><i class=" icon-white icon-inbox"></i> <?php 
        _e('Send Test', 'sendpress');
        ?>
</button>
        </div>


<div class="modal fade bs-modal-lg" id="sendpress-helper" tabindex="-1" 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>
		<ul class="nav nav-tabs" id="myTab">
			<li class="active tabs-first"><a href="#posts"><?php 
        _e('Single Post', 'sendpress');
        ?>
</a></li>
		  	<li ><a href="#merge"><?php 
        _e('Personalize', 'sendpress');
        ?>
</a></li>
		 
		  	<!--
		  <li><a href="#messages">Messages</a></li>
		  <li><a href="#settings">Settings</a></li>
			-->
		</ul>
	</div>
	<div class="modal-body">

 
<div class="tab-content">
	 <div class="tab-pane active" id="posts">

  	<div id="search-header"><?php 
        _e('Search Posts', 'sendpress');
        ?>
: <input type="text" name="q" id="sp-single-query"></div>
  	<div  id="sp-post-preview" class="well">
  		<?php 
        _e('No Post Selected', 'sendpress');
        ?>
  	</div>

  	<p><?php 
        _e('Header HTML', 'sendpress');
        ?>
:&nbsp;
	  	<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios1" value="h1" >
		  H1
		</label>
		<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios2" value="h2">
		  H2
		</label>
		<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios2" value="h3" checked>
		  H3
		</label>
		<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios2" value="h4">
		  H4
		</label>
		<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios2" value="h5">
		  H5
		</label>
		<label class="radio">
		  <input type="radio" name="headerOptions" id="optionsRadios2" value="h6">
		  H6
		</label>
	</p>
	<p><?php 
        _e('Header Link', 'sendpress');
        ?>
:&nbsp;
	  	<label class="radio">
		  <input type="radio" name="headerlinkOptions" id="optionsRadios2" value="link" checked>
		  <?php 
        _e('Link Header to Post', 'sendpress');
        ?>
		</label>
		<label class="radio">
		  <input type="radio" name="headerlinkOptions" id="optionsRadios2" value="nolink">
		  <?php 
        _e('Don\'t Link Header to Post', 'sendpress');
        ?>
		</label>
	</p>
  	<p><?php 
        _e('Post Content', 'sendpress');
        ?>
:&nbsp;
	  	<label class="radio">
		  <input type="radio" name="optionsRadios" id="optionsRadios1" value="excerpt" checked>
		  <?php 
        _e('Excerpt', 'sendpress');
        ?>
		</label>
		<label class="radio">
		  <input type="radio" name="optionsRadios" id="optionsRadios2" value="full">
		  <?php 
        _e('Full Post', 'sendpress');
        ?>
		</label>
	</p>
  	<button class="btn btn-mini btn-success sp-insert-code" id="sp-post-preview-insert" data-code=""><?php 
        _e('Insert', 'sendpress');
        ?>
</button>
  </div>
 	<div class="tab-pane " id="merge">
 		<h3><?php 
        _e('Subscriber specific content', 'sendpress');
        ?>
</h3>
  		<table class="table table-condensed table-striped">
  			
  <thead>
    <tr>
      <th><?php 
        _e('Description', 'sendpress');
        ?>
</th>
      <th><?php 
        _e('Code', 'sendpress');
        ?>
</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
    	<td><?php 
        _e('First Name', 'sendpress');
        ?>
</td>
      	<td>*|FNAME|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|FNAME|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    <tr>
    	<td><?php 
        _e('Last Name', 'sendpress');
        ?>
</td>
      	<td>*|LNAME|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|LNAME|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    <tr>
    	<td><?php 
        _e('Email', 'sendpress');
        ?>
</td>
      	<td>*|EMAIL|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code"  data-code="*|EMAIL|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>

  </tbody>
</table>
	<h3><?php 
        _e('Site specific content', 'sendpress');
        ?>
</h3>
  		<table class="table table-condensed table-striped">
  			
  <thead>
    <tr>
      <th><?php 
        _e('Description', 'sendpress');
        ?>
</th>
      <th><?php 
        _e('Code', 'sendpress');
        ?>
</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
    	<td><?php 
        _e('Website URL', 'sendpress');
        ?>
</td>
      	<td>*|SITE:URL|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|SITE:URL|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    <tr>
    	<td><?php 
        _e('Website Title', 'sendpress');
        ?>
</td>
      	<td>*|SITE:TITLE|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|SITE:TITLE|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    <tr>
    	<td><?php 
        _e('Website Description', 'sendpress');
        ?>
</td>
      	<td>*|SITE:DECRIPTION|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code"  data-code="*|SITE:DESCRIPTION|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    
  </tbody>
</table>
<h3><?php 
        _e('Date and Time', 'sendpress');
        ?>
</h3>
  		<table class="table table-condensed table-striped">
  			
  <thead>
    <tr>
      <th><?php 
        _e('Description', 'sendpress');
        ?>
</th>
      <th><?php 
        _e('Code', 'sendpress');
        ?>
</th>
      <th></th>
    </tr>
  </thead>
  <tbody>
    <tr>
    	<td><?php 
        _e('Current Date', 'sendpress');
        ?>
<br><small><?php 
        _e('Format based on WordPress settings', 'sendpress');
        ?>
.</small></td>
      	<td>*|DATE|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|DATE|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
     <tr>
    	<td><?php 
        _e('Current Time', 'sendpress');
        ?>
<br><small>5:16 pm</small></td>
      	<td>*|DATE:g:i a|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|DATE:g:i a|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
    <tr>
    	<td><?php 
        _e('Custom Date', 'sendpress');
        ?>
<br><small>March 10, 2001, 5:16 pm</small></td>
      	<td>*|DATE:F j, Y, g:i a|*</td>
      	<td class="text-right"><button class="btn btn-xs btn-success sp-insert-code" data-code="*|DATE:F j, Y, g:i a|*"><?php 
        _e('Insert', 'sendpress');
        ?>
</button></td>
    </tr>
  
    
  </tbody>
</table>

  </div>
 
  <div class="tab-pane" id="messages">...</div>
  <div class="tab-pane" id="settings">...</div>
</div>
		
	</div>
	<div class="modal-footer">
	 	<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
	</div>
</div>
</div>
	<?php 
        SendPress_Data::nonce_field();
        ?>
        </form>
	<?php 
    }
 static function create_default_form($type = 'signup')
 {
     //SendPress_Option::set('default-signup-widget-settings',null);
     $postid = SendPress_Option::get('default-' . $type . '-widget-settings');
     $hasPost = false;
     if (!empty($postid)) {
         $hasPost = true;
         $query = array();
         /*
         			$query =  get_posts(array(
         				'post_type'=>'sp_settings',
         				'post_status'=>'any',
         				'p'=>$postid
         			));
         */
         if (count($query) === 0) {
             $hasPost = false;
             $xposts = get_posts(array('post_type' => 'sp_settings', 'post_status' => 'any', 'orderby' => 'ID', 'order' => 'ASC'));
             foreach ($xposts as $pchecks) {
                 if ($pchecks->post_title == 'Default Signup Settings') {
                     $hasPost = true;
                     SendPress_Option::set('default-signup-widget-settings', $pchecks->ID);
                 }
                 //Default Signup Settings
             }
         }
     }
     if (!$hasPost) {
         switch ($type) {
             case 'signup':
                 $postid = SendPress_Data::create_settings_post("Default Signup Settings", SendPress_Data::signup_defaults());
                 SendPress_Option::set('default-' . $type . '-widget-settings', $postid);
                 break;
         }
     }
 }
    function html($sp)
    {
        $key_active = false;
        if (get_transient('sendpress_key_state') === 'valid') {
            $key_active = true;
        }
        // SendPress_Helper::log('API Key = '.SendPress_Option::get('api_key'));
        // SendPress_Helper::log('API State = '.get_transient( 'sendpress_key_state' ));
        $key = SendPress_Option::get('api_key');
        if (empty($key) || $key == '') {
            $key_active = false;
            delete_transient('sendpress_key_state');
        }
        ?>
		<h4><?php 
        _e('SendPress API Key', 'sendpress');
        ?>
</h4>
		

		<form method="post" id="post">
			
			
			<?php 
        if ($key_active) {
            echo '<span class="icon-ok-sign"></span>';
        }
        ?>
			<input <?php 
        if ($key_active) {
            echo 'disabled';
        }
        ?>
 name="api_key" type="text" id="api_key" value="<?php 
        echo SendPress_Option::get('api_key');
        ?>
" class="regular-text sp-text">
			<?php 
        if (!$key_active) {
            ?>
				<a href="#" class="save-api-key btn-success  btn"><?php 
            _e('Register Key', 'sendpress');
            ?>
</a>
			<?php 
        } else {
            ?>
				<a href="#" class="save-api-key btn-danger btn"><?php 
            _e('Deactivate Key', 'sendpress');
            ?>
</a>
			<?php 
        }
        ?>
			<div class="description">
				<?php 
        echo sprintf(__('Enter your API key to enable premium support and automatic updates. Get your API key by logging into <a href="%s">SendPress.com</a>.', 'sendpress'), 'http://sendpress.com');
        ?>
			</div>
			<input class="action " type="hidden" name="action" value="<?php 
        if ($key_active) {
            echo 'module-deactivate-api-key';
        } else {
            echo 'module-save-api-key';
        }
        ?>
" />
			<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
		</form>
		
	<?php 
    }
 function render_html($post_id = false, $render = true, $inline = false, $no_links = false, $custom_html = false)
 {
     global $post;
     remove_filter('the_content', 'sharing_display', 19);
     remove_filter('the_excerpt', 'sharing_display', 19);
     $saved = false;
     if ($post_id !== false) {
         $post = get_post($post_id);
         $saved = $post;
     }
     $saved = $post;
     if (!isset($post)) {
         //echo __('Sorry we could not find your email.','sendpress');
         return;
     }
     //$selected_template = $this->get_template( $post_id );
     //$template_list = $this->info();
     $post_template = get_post_meta($post->ID, '_sendpress_template', true);
     if ($post_template != '' && is_numeric($post_template) && $post_template > 0) {
         $HtmlCode = SendPress_Email_Render_Engine::render_template($post_template, $post_id, $custom_html);
     } else {
         $old = get_post_meta($post->ID, '_sendpress_system', true);
         if ($old == 'old') {
             $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/original.html');
         } else {
             $HtmlCode = file_get_contents(SENDPRESS_PATH . '/templates/simple.html');
         }
     }
     if ($HtmlCode != false) {
         /*
         ob_start();
         require_once( $template_list[$selected_template]['file'] );
         $HtmlCode= ob_get_clean(); 
         */
         $HtmlCode = do_shortcode($HtmlCode);
         add_filter('the_content', 'do_shortcode', 11);
         if ($custom_html == false) {
             $content = $post->post_content;
         } else {
             $content = $custom_html;
         }
         $content = apply_filters('the_content', $content);
         //print_r($post->post_content);
         $content = str_replace(']]>', ']]&gt;', $content);
         //$content = do_shortcode( $content );
         $HtmlCode = str_replace("*|SP:CONTENT|*", $content, $HtmlCode);
         $post = $saved;
         $HtmlCode = str_replace("*|SP:SUBJECT|*", $post->post_title, $HtmlCode);
         $body_bg = get_post_meta($post->ID, 'body_bg', true);
         $body_text = get_post_meta($post->ID, 'body_text', true);
         $body_link = get_post_meta($post->ID, 'body_link', true);
         $header_bg = get_post_meta($post->ID, 'header_bg', true);
         $active_header = get_post_meta($post->ID, 'active_header', true);
         $upload_image = get_post_meta($post->ID, 'upload_image', true);
         $header_text_color = get_post_meta($post->ID, 'header_text_color', true);
         $header_text = get_post_meta($post->ID, 'header_text', true);
         //needs adding to the template
         $header_link = get_post_meta($post->ID, 'header_link', true);
         //needs adding to the template
         $sub_header_text = get_post_meta($post->ID, 'sub_header_text', true);
         //needs adding to the template
         $image_header_url = get_post_meta($post->ID, 'image_header_url', true);
         //needs adding to the template
         $content_bg = get_post_meta($post->ID, 'content_bg', true);
         $content_text = get_post_meta($post->ID, 'content_text', true);
         $content_link = get_post_meta($post->ID, 'sp_content_link_color', true);
         $content_border = get_post_meta($post->ID, 'content_border', true);
         $header_link_open = '';
         $header_link_close = '';
         if ($active_header == 'image') {
             if (!empty($image_header_url)) {
                 $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $image_header_url . "'>";
                 $header_link_close = "</a>";
             }
             $headercontent = $header_link_open . "<img style='display:block;' src='" . $upload_image . "' border='0' />" . $header_link_close;
             $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode);
         } else {
             if (!empty($header_link)) {
                 $header_link_open = "<a style='color:" . $header_text_color . "' href='" . $header_link . "'>";
                 $header_link_close = "</a>";
             }
             $headercontent = "<div style='padding: 10px; text-align:center;'><h1 style='text-align:center; color: " . $header_text_color . " !important;'>" . $header_link_open . $header_text . $header_link_close . "</h1>" . $sub_header_text . "</div>";
             $HtmlCode = str_replace("*|SP:HEADERCONTENT|*", $headercontent, $HtmlCode);
         }
         $HtmlCode = str_replace("*|SP:HEADERBG|*", $header_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:HEADERTEXT|*", $header_text_color, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYBG|*", $body_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYTEXT|*", $body_text, $HtmlCode);
         $HtmlCode = str_replace("*|SP:BODYLINK|*", $body_link, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTBG|*", $content_bg, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTTEXT|*", $content_text, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTLINK|*", $content_link, $HtmlCode);
         $HtmlCode = str_replace("*|SP:CONTENTBORDER|*", $content_border, $HtmlCode);
         $HtmlCode = $this->tag_replace($HtmlCode);
         // Date processing
         $canspam = wpautop(SendPress_Option::get('canspam'));
         $HtmlCode = str_replace("*|SP:CANSPAM|*", $canspam, $HtmlCode);
         $social = '';
         if ($twit = SendPress_Option::get('twitter')) {
             $social .= "<a href='{$twit}' style='color: {$body_link};'>Twitter</a>";
         }
         if ($fb = SendPress_Option::get('facebook')) {
             if ($social != '') {
                 $social .= " | ";
             }
             $social .= "<a href='{$fb}'  style='color: {$body_link};'>Facebook</a>";
         }
         if ($ld = SendPress_Option::get('linkedin')) {
             if ($social != '') {
                 $social .= " | ";
             }
             $social .= "<a href='{$ld}'  style='color: {$body_link};'>LinkedIn</a>";
         }
         $social = SendPress_Data::build_social($body_link);
         $HtmlCode = str_replace("*|SP:SOCIAL|*", $social, $HtmlCode);
         /*
         $dom = new DomDocument();
         	$dom->strictErrorChecking = false;
         	@$dom->loadHtml($HtmlCode);
         	$iTags = $dom->getElementsByTagName('img');
         	foreach ($iTags as $iElement) {
         		$class = $iElement->getAttribute('class');
         	}
         	$body_html = $dom->saveHtml();
         */
         /*
         			$simplecss = file_get_contents(SENDPRESS_PATH.'/templates/simple.css');
         				
         			// create instance
         			$cssToInlineStyles = new CSSToInlineStyles($HtmlCode, $simplecss);
         // grab the processed HTML
         			$HtmlCode = $cssToInlineStyles->convert();
         */
         $display_correct = __("Is this email not displaying correctly?", "sendpress");
         $view = __("View it in your browser", "sendpress");
         $start_text = __("Not interested anymore?", "sendpress");
         $unsubscribe = __("Unsubscribe", "sendpress");
         $instantly = __("Instantly", "sendpress");
         $manage = __("Manage Subscription", "sendpress");
         if ($render) {
             //RENDER IN BROWSER
             if ($inline) {
                 $link = get_permalink($post->ID);
                 $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $link . '">' . $view . '</a>.';
                 $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode);
                 $remove_me = ' <a href="#"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | ';
                 $manage = ' <a href="#"  style="color: ' . $body_link . ';" >' . $manage . '</a> ';
                 $HtmlCode = str_replace("*|SP:MANAGE|*", $manage, $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $HtmlCode);
             } else {
                 $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|ID|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|FNAME|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|LNAME|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|EMAIL|*", '', $HtmlCode);
             }
             echo $HtmlCode;
         } else {
             //PREP FOR SENDING
             if ($no_links == false) {
                 $link = get_permalink($post->ID);
                 $open_info = array("id" => $post->ID, "view" => "email");
                 $code = SendPress_Data::encrypt($open_info);
                 $xlink = SendPress_Manager::public_url($code);
                 $browser = $display_correct . ' <a style="color: ' . $body_link . ';" href="' . $xlink . '">' . $view . '</a>.';
                 $HtmlCode = str_replace("*|SP:BROWSER|*", $browser, $HtmlCode);
             } else {
                 $HtmlCode = str_replace("*|SP:BROWSER|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:UNSUBSCRIBE|*", '', $HtmlCode);
                 $HtmlCode = str_replace("*|SP:MANAGE|*", '', $HtmlCode);
             }
             return $HtmlCode;
         }
     } else {
         //echo __('Sorry we could not find your email template.','sendpress');
         return;
     }
 }
    function html()
    {
        $icon_list = SendPress_Data::social_icons();
        $socialsize = SendPress_Option::get('socialsize', 'large');
        ?>
<form method="post" id="post" role="form">
<div  >
	<div id="button-area">  
		<input type="submit" value="<?php 
        _e('Save', 'sendpress');
        ?>
" class="btn btn-large btn-primary"/>
	</div>

</div>
<br><br><br>
<?php 
        $this->panel_start();
        ?>

<div class="sp-row">
<div class="sp-50 sp-first">
<p class="lead"><?php 
        _e('Social Icons appear in emails in Alphabetical order. If you enter a url in the box below then that icon will show in your emails.', 'sendpress');
        ?>
</p>
</div>
<div class="sp-50">
<p>
<label >
<input type="radio" name="icon-view" value="large" <?php 
        checked($socialsize, 'large');
        ?>
 /> <?php 
        _e('Large', 'sendpress');
        ?>
 ( 32px x 32px )
</label>
<br>
<label >
<input type="radio" name="icon-view" value="small" <?php 
        checked($socialsize, 'small');
        ?>
 /> <?php 
        _e('Small', 'sendpress');
        ?>
 ( 16px x 16px )
</label>
<br>
<label >
<input type="radio" name="icon-view" value="text" <?php 
        checked($socialsize, 'text');
        ?>
 /> <?php 
        _e('Text', 'sendpress');
        ?>
</label>
</p>
</div>
</div>

<div class="sp-row">
<div class="sp-50 sp-first">
<?php 
        $icons = count($icon_list);
        $link = SendPress_Option::get('socialicons');
        $firsthalf = array_slice($icon_list, 0, $icons / 2);
        $secondhalf = array_slice($icon_list, $icons / 2);
        $firsthalf = array_merge(array_flip(array('Facebook', 'LinkedIn', 'GitHub', 'Instagram')), $firsthalf);
        $secondhalf = array_merge(array_flip(array('Twitter', 'Skype', 'Vimeo', 'YouTube', 'WordPress')), $secondhalf);
        foreach ($firsthalf as $key => $value) {
            $class = "";
            if (isset($link[$key])) {
                $class = "bg-success";
            }
            ?>
	
   
   		
      
		<div class="well <?php 
            echo $class;
            ?>
">
			<div class="form-group">
			<?php 
            echo "<span class='hidden-xs hidden-sm pull-right text-muted'>" . $value . "</span>";
            ?>
 		<label for="url-<?php 
            echo $key;
            ?>
" class="control-label ">
		<img src="<?php 
            echo SENDPRESS_URL . "img/16px/" . $key . ".png";
            ?>
" />
		<img src="<?php 
            echo SENDPRESS_URL . "img/32px/" . $key . ".png";
            ?>
" />
		<?php 
            echo $key . "</label>";
            $xlink = "";
            if (isset($link[$key])) {
                $xlink = $link[$key];
            }
            ?>
		 
  </div><input type="text" name="url-<?php 
            echo $key;
            ?>
" value="<?php 
            echo $xlink;
            ?>
" class="form-control" placeholder="<?php 
            echo __('URL da mídia social: por favor, inclua http:// ou https://', 'jaiminho');
            ?>
">
    </div>
		<?php 
        }
        ?>
</div>
<div class="sp-50">
<?php 
        foreach ($secondhalf as $key => $value) {
            $class = "";
            if (isset($link[$key])) {
                $class = "bg-success";
            }
            ?>
	
   
   		
      
		<div class="well <?php 
            echo $class;
            ?>
">
			<div class="form-group">
			<?php 
            echo "<span class='hidden-xs hidden-sm pull-right text-muted'>" . $value . "</span>";
            ?>
 		<label for="url-<?php 
            echo $key;
            ?>
" class="control-label ">
		<img src="<?php 
            echo SENDPRESS_URL . "img/16px/" . $key . ".png";
            ?>
" />
		<img src="<?php 
            echo SENDPRESS_URL . "img/32px/" . $key . ".png";
            ?>
" />
		<?php 
            echo $key . "</label>";
            $xlink = "";
            if (isset($link[$key])) {
                $xlink = $link[$key];
            }
            ?>
		 
    </div><input type="text" name="url-<?php 
            echo $key;
            ?>
" value="<?php 
            echo $xlink;
            ?>
" class="form-control" placeholder="<?php 
            echo __('URL da mídia social: por favor, inclua http:// ou https://', 'jaiminho');
            ?>
" />

    </div>
		<?php 
        }
        ?>
</div>
</div>

<?php 
        $this->panel_end();
        ?>
		

<?php 
        wp_nonce_field($this->_nonce_value);
        ?>
</form>
<?php 
    }
    function html($sp)
    {
        ?>
		<div class="notifications">
			<form method="post" id="post">

				<div class="sp-row">
					<?php 
        do_action('sendpress_notification_settings_top');
        ?>
				</div>
				<div class="sp-row">
					<div class="sp-50 sp-first">
						<?php 
        $this->panel_start('<span class="glyphicon glyphicon-envelope"></span> ' . __('E-mail Notifications', 'sendpress'));
        ?>

							<?php 
        $options = SendPress_Option::get('notification_options');
        ?>

							<p>
								<input type="checkbox" class="form-control" value="<?php 
        echo $options['notifications-enable'];
        ?>
" name="notifications-enable" id="notifications-enable" <?php 
        checked($options['notifications-enable'], true);
        ?>
/>&nbsp;<?php 
        _e('Send E-mail Notifications');
        ?>
							</p>

							<h5 style="display:inline;" class="nomargin"><?php 
        _e('To E-mail', 'sendpress');
        ?>
:</h5>
							<input name="toemail" class="form-control" style="display:inline; width:80%;" tabindex=2 type="text" id="toemail" value="<?php 
        echo $options['email'];
        ?>
">
							<br><br>

							<p>
							<input type="checkbox" class="form-control" value="<?php 
        echo $options['send-to-admins'];
        ?>
" name="send-to-admins" id="send-to-admins" <?php 
        checked($options['send-to-admins'], true);
        ?>
/>
							<?php 
        _e('Send Notifications to all WordPress Administrators', 'sendpress');
        ?>
							</p>
							<p><?php 
        _e('Select the notifications you\'d like to receive and how often you\'d like to receive them', 'sendpress');
        ?>
.</p>
							<h5><?php 
        _e('User Subscribed', 'sendpress');
        ?>
:</h5>
							<input class="notifications-radio" type="radio" value="0" <?php 
        if (intval($options['subscribed']) === 0) {
            echo 'checked="checked"';
        }
        ?>
 name="subscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Instant', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="1" <?php 
        if (intval($options['subscribed']) === 1) {
            echo 'checked="checked"';
        }
        ?>
 name="subscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Daily', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="2" <?php 
        if (intval($options['subscribed']) === 2) {
            echo 'checked="checked"';
        }
        ?>
 name="subscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Weekly', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="3" <?php 
        if (intval($options['subscribed']) === 3) {
            echo 'checked="checked"';
        }
        ?>
 name="subscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Monthly', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;

							<h5><?php 
        _e('User Unsbscribed', 'sendpress');
        ?>
:</h5>
							<input class="notifications-radio" type="radio" value="0" <?php 
        if (intval($options['unsubscribed']) === 0) {
            echo 'checked="checked"';
        }
        ?>
 name="unsubscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Instant', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="1" <?php 
        if (intval($options['unsubscribed']) === 1) {
            echo 'checked="checked"';
        }
        ?>
 name="unsubscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Daily', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="2" <?php 
        if (intval($options['unsubscribed']) === 2) {
            echo 'checked="checked"';
        }
        ?>
 name="unsubscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Weekly', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;
							<input class="notifications-radio" type="radio" value="3" <?php 
        if (intval($options['unsubscribed']) === 3) {
            echo 'checked="checked"';
        }
        ?>
 name="unsubscribed" <?php 
        if (!$options['notifications-enable']) {
            echo 'disabled';
        }
        ?>
>
							<?php 
        _e('Monthly', 'sendpress');
        ?>
&nbsp;&nbsp;&nbsp;

						<?php 
        $this->panel_end();
        ?>

					</div>
			   		<div class="sp-50">
						<?php 
        $this->panel_start('<span class="glyphicon glyphicon-comment"></span> ' . __('HipChat Notification', 'sendpress'));
        ?>

							<p>
							<input class="form-control" type="checkbox" value="<?php 
        echo $options['enable-hipchat'];
        ?>
" name="enable-hipchat" id="enable-hipchat" <?php 
        checked($options['enable-hipchat'], true);
        ?>
/>
							<?php 
        _e('Enable HipChat Notification', 'sendpress');
        ?>
<br>
							</p>
							<?php 
        _e('API Key', 'sendpress');
        ?>
: <input class="form-control" style="width:80%; display:inline;" name="hipchat-api" tabindex=2 type="text" id="hipchat-api" value="<?php 
        echo $options['hipchat-api'];
        ?>
"><br><a style="display:inline-block; margin-left:50px;" href="https://sendpress.hipchat.com/admin/api" target="_blank"><?php 
        _e('Where is my API key', 'sendpress');
        ?>
?</a><br>

							<?php 
        if (strlen($options['hipchat-api']) > 0) {
            global $hc;
            $hc = new SendPress_HipChat($options['hipchat-api'], 'https://api.hipchat.com');
            try {
                $rooms = $hc->get_rooms();
                ?>
										<br>
										<h5 class="nomargin"><?php 
                _e('Select the rooms to send notifications to:', 'sendpress');
                ?>
</h5>
										<p style="margin-left:30px;">
										<?php 
                foreach ($rooms as $room) {
                    ?>
											<input type="checkbox" class="form-control" value="<?php 
                    echo $options['hipchat-rooms'][$room->room_id];
                    ?>
" name="hipchat-rooms[<?php 
                    echo $room->room_id;
                    ?>
]" id="hipchat-rooms[<?php 
                    echo $room->room_id;
                    ?>
]" <?php 
                    checked($options['hipchat-rooms'][$room->room_id], true);
                    ?>
/>
											<?php 
                    echo $room->name;
                    ?>
<br>
											<?php 
                }
                ?>
										</p>
										<?php 
            } catch (Exception $e) {
                ?>
										<?php 
                _e('Room Name', 'sendpress');
                ?>
: <input class="form-control" name="hipchat-room" tabindex=2 type="text" id="hipchat-room" value="<?php 
                echo $options['hipchat-room'];
                ?>
">
										<?php 
            }
        }
        ?>

						<?php 
        $this->panel_end();
        ?>
			   		</div>
			   	</div>
   				<?php 
        do_action('sendpress_notification_settings_bottom');
        ?>
   				<?php 
        wp_nonce_field($sp->_nonce_value);
        ?>
   			</form>
   		</div>

		<?php 
    }
 static function old_send_email($to, $subject, $html, $text, $istest = false, $sid, $list_id, $report_id)
 {
     global $phpmailer, $wpdb;
     // (Re)create it, if it's gone missing
     if (!is_object($phpmailer) || !is_a($phpmailer, 'PHPMailer')) {
         require_once ABSPATH . WPINC . '/class-phpmailer.php';
         require_once ABSPATH . WPINC . '/class-smtp.php';
         $phpmailer = new PHPMailer();
     }
     /*
      * Make sure the mailer thingy is clean before we start,  should not
      * be necessary, but who knows what others are doing to our mailer
      */
     $phpmailer->ClearAddresses();
     $phpmailer->ClearAllRecipients();
     $phpmailer->ClearAttachments();
     $phpmailer->ClearBCCs();
     $phpmailer->ClearCCs();
     $phpmailer->ClearCustomHeaders();
     $phpmailer->ClearReplyTos();
     //return $email;
     //
     $charset = SendPress_Option::get('email-charset', 'UTF-8');
     $encoding = SendPress_Option::get('email-encoding', '8bit');
     $phpmailer->CharSet = $charset;
     $phpmailer->Encoding = $encoding;
     if ($charset != 'UTF-8') {
         $sender = new SendPress_Sender();
         $html = $sender->change($html, 'UTF-8', $charset);
         $text = $sender->change($text, 'UTF-8', $charset);
         $subject = $sender->change($subject, 'UTF-8', $charset);
     }
     $subject = str_replace(array('’', '“', '�', '–'), array("'", '"', '"', '-'), $subject);
     $html = str_replace(chr(194), chr(32), $html);
     $text = str_replace(chr(194), chr(32), $text);
     $phpmailer->AddAddress(trim($to));
     $phpmailer->AltBody = $text;
     $phpmailer->Subject = $subject;
     $phpmailer->MsgHTML($html);
     $content_type = 'text/html';
     $phpmailer->ContentType = $content_type;
     // Set whether it's plaintext, depending on $content_type
     //if ( 'text/html' == $content_type )
     $phpmailer->IsHTML(true);
     /**
      * We'll let php init mess with the message body and headers.  But then
      * we stomp all over it.  Sorry, my plug-inis more important than yours :)
      */
     do_action_ref_array('phpmailer_init', array(&$phpmailer));
     $from_email = SendPress_Option::get('fromemail');
     $phpmailer->From = $from_email;
     $phpmailer->FromName = SendPress_Option::get('fromname');
     $phpmailer->Sender = SendPress_Option::get('fromemail');
     $sending_method = SendPress_Option::get('sendmethod');
     $phpmailer = apply_filters('sendpress_sending_method_' . $sending_method, $phpmailer);
     $hdr = new SendPress_SendGrid_SMTP_API();
     $hdr->addFilterSetting('dkim', 'domain', SendPress_Manager::get_domain_from_email($from_email));
     $phpmailer->AddCustomHeader(sprintf('X-SMTPAPI: %s', $hdr->asJSON()));
     $phpmailer->AddCustomHeader('X-SP-METHOD: old');
     // Set SMTPDebug to 2 will collect dialogue between us and the mail server
     if ($istest == true) {
         $phpmailer->SMTPDebug = 2;
         // Start output buffering to grab smtp output
         ob_start();
     }
     // Send!
     $result = true;
     // start with true, meaning no error
     $result = @$phpmailer->Send();
     //$phpmailer->SMTPClose();
     if ($istest == true) {
         // Grab the smtp debugging output
         $smtp_debug = ob_get_clean();
         SendPress_Option::set('phpmailer_error', $phpmailer->ErrorInfo);
         SendPress_Option::set('last_test_debug', $smtp_debug);
     }
     if ($result != true && $istest == true) {
         $hostmsg = 'host: ' . $phpmailer->Host . '  port: ' . $phpmailer->Port . '  secure: ' . $phpmailer->SMTPSecure . '  auth: ' . $phpmailer->SMTPAuth . '  user: '******'';
         $msg .= __('The result was: ', 'sendpress') . $result . "\n";
         $msg .= __('The mailer error info: ', 'sendpress') . $phpmailer->ErrorInfo . "\n";
         $msg .= $hostmsg;
         $msg .= __("The SMTP debugging output is shown below:\n", "sendpress");
         $msg .= $smtp_debug . "\n";
     }
     return $result;
 }
Пример #24
0
 function html()
 {
     $post_template = $this->id();
     global $wpdb;
     //$email =  $this->email();
     // Get any existing copy of our transient data
     if (SendPress_Email_Cache::get($this->id()) != null) {
         $body_html = SendPress_Email_Cache::get($this->id());
         $post_template = get_post_meta($this->id(), '_sendpress_template', true);
         $body_html = spnl_do_email_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true);
     } else {
         if (false === ($body_html = get_transient('sendpress_report_body_html_' . $this->id())) || $this->purge() == true) {
             // It wasn't there, so regenerate the data and save the transient
             if (!$this->post_info) {
                 $this->post_info = get_post($this->id());
             }
             if ($this->cache() !== false) {
                 $body_html = $this->cache();
             } else {
                 $body_html = SendPress_Template::get_instance()->render($this->id(), false, false, $this->remove_links());
                 $this->cache($body_html);
             }
             set_transient('sendpress_report_body_html_' . $this->id(), $body_html, 60 * 60 * 2);
         }
     }
     $subscriber = SendPress_Data::get_subscriber($this->subscriber_id());
     if (!is_null($subscriber)) {
         $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html);
         $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html);
         $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html);
         $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html);
     }
     $open_info = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "open");
     $code = SendPress_Data::encrypt($open_info);
     $link = SendPress_Manager::public_url($code);
     $tracker = "<img src='" . $link . "' width='1' height='1'/></body>";
     $body_html = str_replace("</body>", $tracker, $body_html);
     $body_link = get_post_meta($this->id(), 'body_link', true);
     $body_html = spnl_do_subscriber_tags($body_html, $post_template, $this->id(), $this->subscriber_id(), true);
     //$pattern ="/(?<=href=(\"|'))[^\"']+(?=(\"|'))/";
     //$body_html = preg_replace( $pattern , site_url() ."?sendpress=link&fxti=".$subscriber_key."&spreport=". $this->id ."&spurl=$0", $body_html );
     if (class_exists("DomDocument")) {
         $dom = new DomDocument();
         $dom->strictErrorChecking = false;
         @$dom->loadHtml($body_html);
         $pTags = $dom->getElementsByTagName('p');
         foreach ($pTags as $pElement) {
             $px = $pElement->getAttribute('style');
             $pElement->setAttribute('style', $px . ' margin-top:0;margin-bottom:10px;');
         }
         if ($this->tracker()) {
             $aTags = $dom->getElementsByTagName('a');
             foreach ($aTags as $aElement) {
                 $href = $aElement->getAttribute('href');
                 /*
                 $style = $aElement->getAttribute('style');
                 
                 if($style == ""){
                 	$aElement->setAttribute('style');
                 }
                 */
                 //ADD TO DB?
                 if (strrpos($href, "*|") === false && strrpos($href, "#") !== 0) {
                     if (SendPress_Option::get('skip_mailto', false) == true && strrpos($href, "mailto") !== false) {
                         continue;
                     }
                     /*
                     $urlinDB = SendPress_Data::get_url_by_report_url( $this->id(), $href );
                     if(!isset($urlinDB[0])){
                     
                     	$urlData = array(
                     		'url' => trim($href),
                     		'reportID' => $this->id(),
                     	);
                     	$urlID = SendPress_Data::insert_report_url( $urlData );
                     
                     } else {
                     	$urlID  = $urlinDB[0]->urlID;
                     }
                     $link = array(
                     	"id"=>$this->subscriber_id(),
                     	"report"=> $this->id(),
                     	"urlID"=> $urlID,
                     	"view"=>"link"
                     );
                     */
                     $link = array("id" => $this->subscriber_id(), "report" => $this->id(), "view" => "tracker", "url" => $href);
                     $code = SendPress_Data::encrypt($link);
                     $link = SendPress_Manager::public_url($code);
                     $href = $link;
                     $aElement->setAttribute('href', $href);
                 }
             }
         }
         $body_html = $dom->saveHtml();
     }
     $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => "unsubscribe");
     $code = SendPress_Data::encrypt($link_data);
     $link = SendPress_Manager::public_url($code);
     if (SendPress_Option::get('old_unsubscribe_link', false) === true) {
         $start_text = __("Not interested anymore?", "sendpress");
         $unsubscribe = __("Unsubscribe", "sendpress");
         $instantly = __("Instantly", "sendpress");
         $remove_me_old = $start_text . ' <a href="' . $link . '"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> ' . $instantly . '.';
         $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me_old, $body_html);
         $body_html = str_replace("*|SP:MANAGE|*", '', $body_html);
     } else {
         $link_data = array("id" => $this->subscriber_id(), "report" => $this->id(), "urlID" => '0', "view" => "manage", "listID" => $this->list_id(), "action" => "");
         $code = SendPress_Data::encrypt($link_data);
         $manage_link = SendPress_Manager::public_url($code);
         $unsubscribe = __("Unsubscribe", "sendpress");
         $manage = __("Manage Subscription", "sendpress");
         $remove_me = ' <a href="' . $link . '"  style="color: ' . $body_link . ';" >' . $unsubscribe . '</a> | ';
         $manage = ' <a href="' . $manage_link . '"  style="color: ' . $body_link . ';" >' . $manage . '</a> ';
         $body_html = str_replace("*|SP:UNSUBSCRIBE|*", $remove_me, $body_html);
         $body_html = str_replace("*|SP:MANAGE|*", $manage, $body_html);
     }
     if (!is_null($subscriber)) {
         $body_html = str_replace("*|FNAME|*", $subscriber->firstname, $body_html);
         $body_html = str_replace("*|LNAME|*", $subscriber->lastname, $body_html);
         $body_html = str_replace("*|EMAIL|*", $subscriber->email, $body_html);
         $body_html = str_replace("*|ID|*", $subscriber->subscriberID, $body_html);
     }
     //$body_html = apply_filters('sendpress_post_render_email', $body_html);
     //echo  $body_html;
     //print_r($email);
     return $body_html;
 }
    function html()
    {
        global $sendpress_sender_factory;
        $senders = $sendpress_sender_factory->get_all_senders();
        ksort($senders);
        $method = SendPress_Option::get('sendmethod');
        $fe = __('From Email', 'sendpress');
        $fn = __('From Name', 'sendpress');
        ?>
<!--
<div style="float:right;" >
  <a href="" class="btn btn-large btn-default" ><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>
-->


<form method="post" id="post">
	<br class="clear">
	<br class="clear">
	<div class="sp-row">
		<div class="sp-50 sp-first">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-user"></span> ' . __('Sending Email', 'sendpress'));
        ?>
			<div class="form-group">
				<label for="fromname"><?php 
        _e('From Name', 'sendpress');
        ?>
</label>
				<input name="fromname" tabindex=1 type="text" id="fromname" value="<?php 
        echo SendPress_Option::get('fromname');
        ?>
" class="form-control">
			</div>
			<div class="form-group">
				<label for="fromemail"><?php 
        _e('From Email', 'sendpress');
        ?>
</label>
				<input name="fromemail" tabindex=2 type="text" id="fromemail" value="<?php 
        echo SendPress_Option::get('fromemail');
        ?>
" class="form-control">
			</div>

			<div class="form-group">
                <label for="bounceemail"><?php 
        _e('Email de Retorno', 'jaiminho');
        ?>
</label>
                <input name="bounceemail" tabindex=3 type="text" id="bounceemail" value="<?php 
        echo SendPress_Option::get('bounce_email');
        ?>
" class="form-control">
            </div>

			<?php 
        $this->panel_end();
        ?>
		</div >
		<div class="sp-50">
			<?php 
        $this->panel_start('<span class="glyphicon glyphicon-inbox"></span> ' . __('Test Email', 'sendpress'));
        ?>

			<div class="form-group">
				<label for="testemail"><?php 
        _e('Where to send Test Email', 'sendpress');
        ?>
</label>
				<input name="testemail" type="text" id="test-email-main" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>
			</div>
			<div class="sp-row">
				<div class="sp-50 sp-first">
					<button class="btn btn-primary btn-block" value="test" name="test" type="submit"><?php 
        _e('Send Test!', 'sendpress');
        ?>
</button>
				</div>
				<div class="sp-50">
					<button class="btn btn-danger btn-block" data-toggle="modal" data-target="#debugModal" type="button"><?php 
        _e('Debug Info', 'sendpress');
        ?>
</button>
				</div>
			</div>
			<div class="sp-row">
				<br>
				<div class="panel-group" id="accordion">
					<div class="panel panel-default">
						<div class="panel-heading">
							<h4 class="panel-title">
								<a data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
									<?php 
        _e('Click to View Last Error', 'sendpress');
        ?>
								</a>
							</h4>
						</div>
						<div id="collapseOne" class="panel-collapse collapse">
							<div class="panel-body">

								<?php 
        $logs = SPNL()->log->get_connected_logs(array('posts_per_page' => 1, 'log_type' => 'sending'));
        if (!empty($logs)) {
            foreach ($logs as $log) {
                echo "<strong>" . $log->post_date . "</strong>  " . $log->post_title;
                echo "<br>" . $log->post_content;
            }
        }
        ?>
							</div>
						</div>
					</div>
				</div>
				
			</div>
			<?php 
        $this->panel_end();
        ?>
		</div>
	</div>

	<div class="panel panel-default">
		<div class="panel-heading">
			<h3 class="panel-title"><?php 
        _e('Sending Account Setup', 'sendpress');
        ?>
</h3>
		</div>
		<div class="panel-body">

			<input type="hidden" name="action" value="account-setup" />
			<?php 
        $new = array();
        foreach ($senders as $key => $sender) {
            array_push($new, array($key, $sender->label()));
        }
        echo '<strong>Delivery Method: </strong>';
        $this->select('sendpress-sender', $method, $new);
        ?>
<br><br>
			<?php 
        if (count($senders) < 3) {
            $c = 0;
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($c >= 1) {
                    $class = "margin-left: 4%";
                }
                echo "<div style=' float:left; width: 48%; {$class}' id='{$key}'>";
                ?>
					<!-- XXXX -->	
					<p>&nbsp;<!--<input name="sendpress-sender" type="radio"  <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Send Emails via', 'sendpress');
                ?>
 -->
						<?php 
                echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
                $c++;
            }
        } else {
            ?>
				<div class="tabbable tabs-left">
					<ul class="nav nav-tabs">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "class='active'";
                }
                echo "<li {$class}><a href='#{$key}' data-toggle='tab'>";
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    echo '<span class="glyphicon glyphicon-ok-sign"></span> ';
                }
                echo $sender->label();
                echo "</a></li>";
            }
            ?>
					</ul>
					<div class="tab-content" style="display:block;">
						<?php 
            foreach ($senders as $key => $sender) {
                $class = '';
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    $class = "active";
                }
                echo "<div class='tab-pane {$class}' id='{$key}'>";
                ?>
							<!-- XXXX -->
							<!--<p>&nbsp;<input name="sendpress-sender" type="radio"  <?php 
                if ($key === 'SendPress_Sender_Website' && is_multisite()) {
                    echo 'style="display:none"';
                }
                ?>
 <?php 
                if ($method == $key || strpos(strtolower($key), $method) > 0) {
                    ?>
checked="checked"<?php 
                }
                ?>
 id="website" value="<?php 
                echo $key;
                ?>
" /> <?php 
                _e('Activate', 'sendpress');
                ?>
-->
								<?php 
                //echo $sender->label();
                echo "</p><div class='well'>";
                echo $sender->settings();
                echo "</div></div>";
            }
            ?>

						</div>
					</div>


					<p > <span class="glyphicon glyphicon-ok-sign"></span> = <?php 
            _e('Currently Active', 'sendpress');
            ?>
</p>
					<?php 
        }
        ?>

				</div>
			</div>
			<br class="clear">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h3 class="panel-title"><?php 
        _e('Advanced Sending Options', 'sendpress');
        ?>
</h3>
				</div>
				<div class="panel-body">
					<div class="boxer form-box">
						<div style="float: right; width: 45%;">
							<h2><?php 
        _e('Email Sending Limits', 'sendpress');
        ?>
</h2>

							<?php 
        $emails_per_day = SendPress_Option::get('emails-per-day');
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $credits = SendPress_Option::get('emails-credits');
        //$hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $offset = get_option('gmt_offset') * 60 * 60;
        // Time offset in seconds
        $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
        //print_r(wp_get_schedules());
        sprintf(__('You have sent <strong>%s</strong> emails so far today and you have <strong>%s</strong> credits remaining.', 'sendpress'), $emails_so_far, $credits);
        ?>
<br><br>
<input type="text" size="6" name="emails-per-day" value="<?php 
        echo $emails_per_day;
        ?>
" /> <?php 
        _e('Emails Per Day', 'sendpress');
        ?>
<br><br>
<input type="text" size="6" name="emails-per-hour" value="<?php 
        echo $emails_per_hour;
        ?>
" /> <?php 
        _e('Emails Per Hour', 'sendpress');
        ?>
<br><br>
<h2><?php 
        _e('Email Encoding', 'sendpress');
        ?>
</h2>
<?php 
        $charset = SendPress_Option::get('email-charset', 'UTF-8');
        ?>
Charset:
<select name="email-charset" id="">

	<?php 
        $charsete = SendPress_Data::get_charset_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select><br>
<?php 
        _e('Squares or weird characters displaying in your emails select the charset for your language', 'sendpress');
        ?>
.
<br><br>
<?php 
        _e('Encoding', 'sendpress');
        ?>
: <select name="email-encoding" id="">
<?php 
        $charset = SendPress_Option::get('email-encoding', '8bit');
        $charsete = SendPress_Data::get_encoding_types();
        foreach ($charsete as $type) {
            $select = "";
            if ($type == $charset) {
                $select = " selected ";
            }
            echo "<option {$select} value={$type}>{$type}</option>";
        }
        ?>
</select>

<br class="clear">
</div>
</div>
</div>
</div>


<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        wp_nonce_field($this->_nonce_value);
        ?>
<input type="submit" class="btn btn-primary" value="Save"/> <a href="" class="btn btn-default"><i class="icon-remove"></i> <?php 
        _e('Cancel', 'sendpress');
        ?>
</a>
</form>
<form method="post" id="post-test" class="form-inline">
	<input type="hidden" name="action" value="send-test-email" />
	<input name="testemail" type="hidden" id="test-email-form" value="<?php 
        echo SendPress_Option::get('testemail');
        ?>
" class="form-control"/>

	<br class="clear">




	<?php 
        //Page Nonce
        //wp_nonce_field(  basename(__FILE__) ,'_spnonce' );
        //SendPress General Nonce
        wp_nonce_field($this->_nonce_value);
        ?>
</form>
<?php 
        $error = SendPress_Option::get('phpmailer_error');
        $hide = 'hide';
        if (!empty($error) && isset($_POST['testemail'])) {
            $hide = '';
            $phpmailer_error = '<pre>' . $error . '</pre>';
            ?>
	<script type="text/javascript">
		jQuery(document).ready(function($) {
			$('#debugModal').modal('show');
		});
	</script>

	<?php 
        }
        ?>


<div class="modal fade" id="debugModal" tabindex="-1" 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('SMTP Debug Info', 'sendpress');
        ?>
</h3>
			</div>
			<div class="modal-body">
				<?php 
        if (!empty($phpmailer_error)) {
            $server = "smtp.sendgrid.net";
            $port = "25";
            $port2 = "465";
            $port3 = "587";
            $timeout = "1";
            if ($server and $port and $timeout) {
                $port25 = @fsockopen("{$server}", $port, $errno, $errstr, $timeout);
                $port465 = @fsockopen("{$server}", $port2, $errno, $errstr, $timeout);
                $port587 = @fsockopen("{$server}", $port3, $errno, $errstr, $timeout);
            }
            if (!$port25) {
                echo '<div class="alert alert-error">';
                _e('Port 25 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            if (!$port465) {
                echo '<div class="alert alert-error">';
                _e('Port 465 seems to be blocked. Gmail may have trouble', 'sendpress');
                echo '</div>';
            }
            if (!$port587) {
                echo '<div class="alert alert-error">';
                _e('Port 587 seems to be blocked.', 'sendpress');
                echo '</div>';
            }
            echo $phpmailer_error;
        }
        ?>


				<pre>
					<?php 
        $whoops = SendPress_Option::get('last_test_debug');
        if (empty($whoops)) {
            _e('No Debug info saved.', 'sendpress');
        } else {
            echo $whoops;
        }
        ?>
				</pre>
			</div>
			<div class="modal-footer">
				<a href="#" class="btn" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
			</div>
		</div>
	</div></div>
	<?php 
    }
 static function auto_cron()
 {
     // make sure we're in wp-cron.php
     if (false !== strpos($_SERVER['REQUEST_URI'], '/wp-cron.php')) {
         // make sure a secret string is provided in the ur
         if (isset($_GET['action']) && $_GET['action'] == 'sendpress') {
             //* Use cache
             static $cron_bg_run = null;
             static $cron_bg_run_weekly = null;
             $time_start = microtime(true);
             $count = SendPress_Data::emails_in_queue();
             $bg = 0;
             $bg_weekly = 0;
             $error = '';
             try {
                 if ($count > 0) {
                     SendPress_Queue::send_mail();
                     $count = SendPress_Data::emails_in_queue();
                 } else {
                     //* If cache is empty, pull transient
                     if (!$cron_bg_run) {
                         $cron_bg_run = get_transient('spnl-background-daily');
                     }
                     //* If transient has expired, do a fresh update check
                     if (!$cron_bg_run) {
                         //* If cache is empty, pull transient
                         if (!$cron_bg_run_weekly) {
                             $cron_bg_run_weekly = get_transient('spnl-background-weekly');
                         }
                         //* If transient has expired, do a fresh update check
                         if (!$cron_bg_run_weekly) {
                             SPNL()->log->prune_logs();
                             SendPress_Data::clean_queue_table();
                             SendPress_DB_Tables::repair_tables();
                             $cron_bg_run_weekly = array('runtime' => date("F j, Y, g:i a"));
                             set_transient('spnl-background-weekly', $cron_bg_run_weekly, 60 * 60 * 24 * 7);
                             $bg_weekly = 1;
                         }
                         //SendPress_Logging::prune_logs();
                         $bg = 1;
                         $cron_bg_run = array('runtime' => date("F j, Y, g:i a"));
                         set_transient('spnl-background-daily', $cron_bg_run, 60 * 60 * 24);
                     }
                 }
             } catch (Exception $e) {
                 $error = $e->getMessage();
                 SPNL()->log->add('Autocron', $error, 0, 'error');
             }
             $attempted_count = SendPress_Option::get('autocron-per-call', 25);
             $pro = 0;
             if (defined('SENDPRESS_PRO_VERSION')) {
                 $pro = SENDPRESS_PRO_VERSION;
             }
             $stuck = SendPress_Data::emails_stuck_in_queue();
             $limit = SendPress_Manager::limit_reached();
             $emails_per_day = SendPress_Option::get('emails-per-day');
             $emails_per_hour = SendPress_Option::get('emails-per-hour');
             $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
             $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
             $limits = array('autocron' => $attempted_count, 'dl' => $emails_per_day, 'hl' => $emails_per_hour, 'ds' => $emails_so_far, 'hs' => $hourly_emails);
             $time_end = microtime(true);
             $time = $time_end - $time_start;
             echo json_encode(array("error" => $error, "background" => $bg, "weekly" => $bg_weekly, "queue" => $count, "stuck" => $stuck, "version" => SENDPRESS_VERSION, "pro" => $pro, "limit" => $limit, 'info' => $limits, 'time' => number_format($time, 3)));
             die;
         }
     }
 }
    function text_settings()
    {
        ?>

<br>
<div class="well">
<?php 
        $display_correct = __("Is this email not displaying correctly?", "sendpress");
        $view = __("View it in your browser", "sendpress");
        if (SendPress_Option::get('beta')) {
            ?>
<h4 class="nomargin"><?php 
            _e('Link to browser version', 'sendpress');
            ?>
</h4>
<p><input type=radio value="" name="browerslink" checked/> <?php 
            _e('Use default', 'sendpress');
            ?>
&nbsp;&nbsp;&nbsp;<input type=radio value="" name="browerslink"/> <?php 
            _e('Use custom', 'sendpress');
            ?>
&nbsp;&nbsp;&nbsp;<input type=radio value="" name="browerslink"/> <?php 
            _e('None', 'sendpress');
            ?>
</p>
<p><input name="inbrowser" type="text" id="inbrowser" value="<?php 
            echo SendPress_Option::get('inbrowser');
            ?>
" class="regular-text sp-text"></p>
<br>
<?php 
        }
        ?>


<div style="float: right; width: 45%;">
	
</div>	
<div style="width: 45%; margin-right: 10%">
<h4 class="nomargin"><?php 
        _e('CAN-SPAM', 'sendpress');
        ?>
: <small><?php 
        _e('required in the US.', 'sendpress');
        ?>
</small>&nbsp;&nbsp;&nbsp;&nbsp;<?php 
        _e('This area displays in Email Footer', 'sendpress');
        ?>
</h4>
<textarea cols="20" rows="10" class="large-text code" name="can-spam"><?php 
        echo SendPress_Option::get('canspam');
        ?>
</textarea>
<p><?php 
        _e('Your message must include your valid physical postal address. This can be your current street address, a post office box youve registered with the U.S. Postal Service, or a private mailbox youve registered with a commercial mail receiving agency established under Postal Service regulations.', 'sendpress');
        ?>
</p>
<?php 
        _e('This is dictated under the <a href="http://business.ftc.gov/documents/bus61-can-spam-act-compliance-guide-business" target="_blank">Federal CAN-SPAM Act of 2003</a>.', 'sendpress');
        ?>
					</p>
</div>
</div>




		<?php 
    }
    function html()
    {
        SendPress_Tracking::event('Queue Tab');
        if (SPNL()->validate->_isset('cron')) {
            SPNL()->fetch_mail_from_queue();
        }
        //Create an instance of our package class...
        $testListTable = new SendPress_Queue_Table();
        //Fetch, prepare, sort, and filter our data...
        $testListTable->prepare_items();
        SendPress_Option::set('no_cron_send', 'false');
        SPNL()->cron_start();
        $open_info = array("id" => 13, "report" => 10, "view" => "open");
        $autocron = SendPress_Option::get('autocron', 'no');
        ?>

<br>
	<div id="taskbar" class="lists-dashboard rounded group"> 

	<div id="button-area">  
	<?php 
        $pause_sending = SendPress_Option::get('pause-sending', 'no');
        $txt = __('Pause Sending', 'sendpress');
        //Stop Sending for now
        if ($pause_sending == 'yes') {
            $txt = __('Resume Sending', 'sendpress');
        }
        ?>
	<div class="btn-group">

       <?php 
        if (SendPress_Option::get('emails-credits') && SendPress_Option::get('sendmethod') === 'Jaiminho_Sender_NetWork' || SendPress_Option::get('sendmethod') != 'Jaiminho_Sender_NetWork') {
            SendPress_Option::set('pause-sending', 'no');
            ?>
          <a class="btn btn-large btn-default " href="<?php 
            echo SendPress_Admin::link('Queue');
            ?>
&action=pause-queue" ><i class="icon-repeat icon-white "></i> <?php 
            echo $txt;
            ?>
</a>
          <a id="send-now" class="btn btn-primary btn-large " data-toggle="modal" href="#sendpress-sending"   ><i class="icon-white icon-refresh"></i> <?php 
            _e('Send Emails Now', 'sendpress');
            ?>
</a>
	</div>
	</div>
	<?php 
        } else {
            SendPress_Option::set('pause-sending', 'yes');
        }
        $emails_per_day = SendPress_Option::get('emails-per-day');
        if ($emails_per_day == 0) {
            $emails_per_day = __('Unlimited', 'sendpress');
        }
        $emails_per_hour = SendPress_Option::get('emails-per-hour');
        $hourly_emails = SendPress_Data::emails_sent_in_queue("hour");
        $emails_so_far = SendPress_Data::emails_sent_in_queue("day");
        $credits = SendPress_Option::get('emails-credits');
        //print_r(SendPress_Data::emails_stuck_in_queue());
        global $wpdb;
        $table = SendPress_Data::queue_table();
        $date = getdate();
        // Maurilio TODO: fazer com os créditos sejam contados a partir da 00:00:00 do primeiro dia do mês atual
        $hour_ago = strtotime('-' . $date["mday"] . ' day');
        $time = date('Y-m-d H:i:s', $hour_ago);
        $query = $wpdb->prepare("SELECT COUNT(*) FROM {$table} where last_attempt > %s and success = %d", $time, 1);
        $credits_so_far = $wpdb->get_var($query);
        $result_credits = $credits - $credits_so_far;
        if ($credits <= 0) {
            echo "<p class='alert alert-danger' style='width:70%;'>" . __("Vixe! Você não tem créditos. Para enviar emails em sua fila ou enviar novos emails, você precisa obter mais créditos.", "jaiminho") . "</p>";
        } else {
            ?>
        <h2><?php 
            echo $credits ? __('Você tem', 'jaiminho') : "";
            ?>
        <strong><?php 
            echo $result_credits ? $result_credits : "";
            ?>
</strong> <?php 
            echo $credits ? __('créditos', 'jaiminho') : "";
            ?>
.
        </h2>
        <?php 
        }
        ?>
       
      <h2><strong><?php 
        echo $emails_so_far;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_day;
        ?>
</strong> <?php 
        _e('emails sent in the last 24 hours', 'sendpress');
        ?>
.</h2>
      <h2><strong><?php 
        echo $hourly_emails;
        ?>
</strong> <?php 
        _e('of a possible', 'sendpress');
        ?>
 <strong><?php 
        echo $emails_per_hour;
        ?>
</strong> <?php 
        _e('emails sent in the last hour', 'sendpress');
        ?>
.</h2>
      <?php 
        if (is_multisite() && is_super_admin() || !is_multisite()) {
            ?>
      <small><?php 
            _e('You can adjust these settings here', 'sendpress');
            ?>
: <a href="<?php 
            echo SendPress_Admin::link('Settings_Account');
            ?>
"><?php 
            _e('Settings', 'sendpress');
            ?>
 > <?php 
            _e('Sending Account', 'sendpress');
            ?>
</a>.</small>
                 <?php 
        }
        ?>
 		<?php 
        if ($autocron == 'no') {
            $offset = get_option('gmt_offset') * 60 * 60;
            // Time offset in seconds
            $local_timestamp = wp_next_scheduled('sendpress_cron_action') + $offset;
            ?>
<br><small><?php 
            _e('The cron will run again around', 'sendpress');
            ?>
: <?php 
            echo date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $local_timestamp);
            ?>
</small>
<?php 
        }
        ?>
 		<br><br>
		</div>
	<!-- 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');
        ?>
" 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();
        ?>
" /> 
	    <!-- Now we can render the completed list table -->
	    <?php 
        $testListTable->display();
        ?>
	    <?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
	<br>
	<!--
		<a class="btn btn-large btn-success " href="<?php 
        echo SendPress_Admin::link('Queue');
        ?>
&action=reset-queue" ><i class="icon-repeat icon-white "></i> <?php 
        _e('Re-queue All Emails', 'sendpress');
        ?>
</a><br><br>
	-->
	<form  method='get'>
		<input type='hidden' value="<?php 
        echo SPNL()->validate->page();
        ?>
" name="page" />
		
		<input type='hidden' value="empty-queue" name="action" />
		<a class="btn btn-large  btn-danger" data-toggle="modal" href="#sendpress-empty-queue" ><i class="icon-warning-sign "></i> <?php 
        _e('Delete All Emails in the Queue', 'sendpress');
        ?>
</a>
		<?php 
        wp_nonce_field($this->_nonce_value);
        ?>
	</form>
<div class="modal fade" id="sendpress-empty-queue" tabindex="-1" 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? Delete All Emails in the Queue.', 'sendpress');
        ?>
</h3>
	</div>
	<div class="modal-body">
		<p><?php 
        _e('This will remove all emails from the queue without attempting to send them', '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('Queue');
        ?>
&action=empty-queue" id="confirm-delete" class="btn btn-danger" ><?php 
        _e('Yes! Delete All Emails', 'sendpress');
        ?>
</a>
	</div>
</div></div>
</div>

<div class="modal fade" id="sendpress-sending" tabindex="-1" 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('Sending Emails', 'sendpress');
        ?>
</h3>
  </div>
  <div class="modal-body">
    <div id="sendbar" class="progress progress-striped
     active">
  <div id="sendbar-inner" class="progress-bar"
       style="width: 40%;"></div>
</div>
	<span id="queue-sent">-</span> <?php 
        _e('of', 'sendpress');
        ?>
 <span id="queue-total">-</span> <?php 
        _e('emails left to send', 'sendpress');
        ?>
.<br>
	<br>
	<?php 
        _e('You are also limited to', 'sendpress');
        ?>
 <?php 
        echo $emails_per_hour;
        ?>
 <?php 
        _e('emails per hour', 'sendpress');
        ?>
.<br>
	<?php 
        _e('To change these settings go to', 'sendpress');
        ?>
 <a href="<?php 
        echo SendPress_Admin::link('Settings_Account');
        ?>
"> <?php 
        _e('Settings', 'sendpress');
        ?>
 > <?php 
        _e('Sending Account', 'sendpress');
        ?>
</a>.
  </div>
  <div class="modal-footer">
   <?php 
        _e('If you close this window sending will stop. ', 'sendpress');
        ?>
<a href="#" class="btn btn-primary" data-dismiss="modal"><?php 
        _e('Close', 'sendpress');
        ?>
</a>
  </div>
</div>
</div></div>
<?php 
    }
        function html($sp)
        {
            SendPress_Tracking::event('Overview Tab');
            global $wp_version;
            $classes = 'sp-welcome-panel';
            $option = get_user_meta(get_current_user_id(), 'show_sp_welcome_panel', true);
            // 0 = hide, 1 = toggled to show or single site creator, 2 = multisite site owner
            $hide = 0 == $option || 2 == $option && wp_get_current_user()->user_email != get_option('admin_email');
            list($display_version) = explode('-', $wp_version);
            ?>
<br>



<div class="sp-row ">

  <div class="sp-block sp-25 sp-first"> 
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::bd_nice_number(SendPress_Data::get_total_subscribers());
            ?>
</h2> <p class="fwb"><?php 
            _e('Subscribers', 'sendpress');
            ?>
</p>  
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            $report = SendPress_Data::get_last_report();
            echo SendPress_Data::emails_active_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Actively Sending', 'sendpress');
            ?>
</small></p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            echo SendPress_Data::emails_maxed_in_queue();
            ?>
</h2> <p class="fwb"><?php 
            _e('Emails Stuck in Queue', 'sendpress');
            ?>
</p>
  </div>
  <div class="sp-block sp-25">
    <h2 class="nomargin nopadding"><?php 
            _e('Autocron last check', 'sendpress');
            ?>
</h2> <p class="fwb">  <?php 
            $autocron = SendPress_Option::get('autocron', 'no');
            //print_r(SendPress_Data::emails_stuck_in_queue());
            if ($autocron == 'yes') {
                $api_info = json_decode(SendPress_Cron::get_info());
                if (isset($api_info->lastcheck)) {
                    echo $api_info->lastcheck . " UTC";
                } else {
                    echo "No Data";
                }
            } else {
                echo "Not Enabled";
            }
            ?>
</p>
  </div>

</div>
<?php 
            if ($report) {
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                $this->panel_start($report->post_title . " <small style='color:#333;'>" . __('This email had', 'sendpress') . " " . $rec . " " . __('Recipients', 'sendpress') . "</small>");
                $stat_type = get_post_meta($report->ID, '_stat_type', true);
                $clicks = SPNL()->db("Subscribers_Url")->clicks_email_id($report->ID);
                $clicks_total = SPNL()->db("Subscribers_Url")->clicks_total_email_id($report->ID);
                ?>

<div class="sp-row">
  <div class="sp-50 sp-first">
    <h4 style="text-align:center;"><?php 
                _e('Opens', 'sendpress');
                ?>
</h4>
      <?php 
                $this->panel_start();
                $open = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $open = SPNL()->db("Subscribers_Tracker")->get_opens_total($report->ID);
                    } else {
                        $open = SendPress_Data::get_opens($report->ID);
                    }
                    $p = $open / $rec * 100;
                }
                ?>
        <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $open;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5>Total</h5>
         <?php 
                echo $open;
                ?>
        </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db("Subscribers_Tracker")->get_opens($report->ID);
                } else {
                    $ou = SendPress_Data::get_opens_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
          <div style="text-align:center;">
          <h5>Unique</h5>
          <?php 
                echo $ou;
                ?>
          </div>
       </div>
       </div>
        
      <?php 
                $this->panel_end();
                ?>
  </div>
  <div class="sp-50">
  <h4 style="text-align:center;"><?php 
                _e('Clicks', 'sendpress');
                ?>
</h4>
    <?php 
                $this->panel_start();
                $click = 0;
                $rec = get_post_meta($report->ID, '_send_last_count', true);
                if ($report) {
                    if ($stat_type == 'new') {
                        $click = SPNL()->db("Subscribers_Url")->clicks_email_id($report->ID);
                    } else {
                        $click = SendPress_Data::get_clicks($report->ID);
                    }
                    $p = $click / $rec * 100;
                }
                ?>
     <div class="sp-row">
        <div class="sp-50 sp-first">
          <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($p);
                ?>
%" data-info="Total Opens" data-width="15" data-fontsize="30" data-percent="<?php 
                echo floor($p);
                ?>
" data-fgcolor="#61a9dc" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $click;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
         </div>
         <div style="text-align:center;">
         <h5><?php 
                _e('Total', 'sendpress');
                ?>
</h5>
         <?php 
                echo $click;
                ?>
         </div>
        </div>
        <div class="sp-50">
        <?php 
                $ou = 0;
                if ($stat_type == 'new') {
                    $ou = SPNL()->db("Subscribers_Url")->clicks_total_email_id($report->ID);
                } else {
                    $ou = SendPress_Data::get_clicks_unique_total($report->ID);
                }
                $px = $ou / $rec * 100;
                ?>
        <div style="float:left;">
          <div id="myStat" class="chartid" data-dimension="150" data-text="<?php 
                echo floor($px);
                ?>
%" data-info="Unique Opens" data-width="15" data-fontsize="30" data-percent="35" data-fgcolor="#85d002" data-bgcolor="#eee" data-fill="#ddd" data-total="<?php 
                echo $rec;
                ?>
" data-part="<?php 
                echo $ou;
                ?>
" data-icon="long-arrow-up" data-icon-size="28" data-icon-color="#fff"></div>
        </div>
        <div style="text-align:center;">
          <h5><?php 
                _e('Unique', 'sendpress');
                ?>
</h5>
          <?php 
                echo $ou;
                ?>
         </div>
       </div>
       </div>
        
     <?php 
                $this->panel_end();
                ?>
  </div>
</div>
<?php 
                $this->panel_end();
            }
            ?>




<div class="sp-row">
<div class="sp-33 sp-first">
<div class="panel panel-default">
  <div class="panel-heading">
    <h3 class="panel-title"><?php 
            _e('Recent Subscribers', 'sendpress');
            ?>
</h3>
  </div>
  <div class="panel-body">
  	<table class="table table-striped table-condensed">
    <tr>
    <th>Date</th>
    <th>List</th>
    <th><div style="text-align:right;">Email</div></th>
    </tr>
  	<?php 
            $recent = SendPress_Data::get_recent_subscribers();
            foreach ($recent as $item) {
                echo "<tr>";
                echo "<td>";
                if (property_exists($item, 'subscriberID')) {
                    $d = SendPress_Data::get_subscriber($item->subscriberID);
                    if (property_exists($item, 'updated')) {
                        echo date_i18n("m.d.y", strtotime($item->updated));
                    }
                    echo "</td>";
                    echo "<td >";
                    if (property_exists($item, 'listID')) {
                        echo get_the_title($item->listID);
                    }
                    echo "</td>";
                    echo "<td align='right'>";
                    if (is_object($d)) {
                        echo $d->email . "<br>";
                    }
                    echo "</td>";
                    echo "</tr>";
                }
            }
            ?>
  </table>
  </div>
</div>
</div>
<div class="sp-33">
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
            _e('Most Active Subscribers', 'sendpress');
            ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  	<?php 
            $recent = SPNL()->db("Subscribers_Tracker")->get_most_active();
            // SendPress_Data::get_most_active_subscriber();
            foreach ($recent as $item) {
                if (property_exists($item, 'subscriber_id')) {
                    echo "<li>";
                    $d = SendPress_Data::get_subscriber($item->subscriber_id);
                    if (is_object($d)) {
                        echo $d->email;
                    }
                    echo "</li>";
                }
            }
            ?>
	  	</ul>
	  </div>
	</div>
</div>
<div class="sp-33">
  <?php 
            if (!defined('SENDPRESS_PRO_VERSION')) {
                ?>
	<div class="panel panel-default">
	  <div class="panel-heading">
	    <h3 class="panel-title"><?php 
                _e('Go Pro!', 'sendpress');
                ?>
</h3>
	  </div>
	  <div class="panel-body">
	  	<ul>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Advanced Reports', 'sendpress');
                ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Check Spam Scores', 'sendpress');
                ?>
</a></li>
	  		<li><a href="http://sendpress.com/purchase-pricing/"><?php 
                _e('Post Notifications', 'sendpress');
                ?>
</a></li>
	  	</ul>
   
	  </div>
	</div>
  <?php 
            }
            ?>
</div>
</div>

<script>
jQuery( document ).ready(function($) {
        $('.chartid').circliful();
    });
</script>
<!--
<div class="panel panel-default">
  <div class="panel-body">
   <h2>Welcome to SendPress</h2>
  </div>
</div>

-->
<?php 
            if (SendPress_Option::get('feedback') == 'yes' || SendPress_Option::get('allow_tracking') == 'yes') {
                SendPress_Tracking::data();
            }
        }
        function sub_menu($sp = false)
        {
            ?>
		<div class="navbar navbar-default" >
			<div class="navbar-header">
			  <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
       <span class="sr-only"><?php 
            _e('Toggle navigation', 'sendpress');
            ?>
</span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>

    </button>
   <a class="navbar-brand" href="#"><?php 
            _e('Emails', 'sendpress');
            ?>
</a>
	</div>
		 <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
		<ul class="nav navbar-nav">
					<li <?php 
            if (!isset($_GET['view']) || isset($_GET['view']) && $_GET['view'] === 'style' || isset($_GET['view']) && $_GET['view'] === 'create' || isset($_GET['view']) && $_GET['view'] === 'send' || isset($_GET['view']) && $_GET['view'] === 'send-confirm' || isset($_GET['view']) && $_GET['view'] === 'send-queue') {
                ?>
class="active"<?php 
            }
            ?>
 >
				    	<a href="<?php 
            echo SendPress_Admin::link('Emails');
            ?>
"><?php 
            _e('Newsletters', 'sendpress');
            ?>
</a>
				  	</li>
				  	<?php 
            if (false == true) {
                //if(SendPress_Option::get('prerelease_templates') == 'yes') {
                ?>
				 	
				  	<li <?php 
                if (isset($_GET['view']) && $_GET['view'] === 'all') {
                    ?>
class="active"<?php 
                }
                ?>
 >
				    	<a href="<?php 
                echo SendPress_Admin::link('Emails_Auto');
                ?>
"><?php 
                _e('Autoresponders', 'sendpress');
                ?>
</a>
				  	</li>
				  	  	<!--	-->
				  	<?php 
            }
            ?>

				  	<li <?php 
            if (isset($_GET['view']) && ($_GET['view'] === 'temp' || $_GET['view'] === 'tempstyle')) {
                ?>
class="active"<?php 
            }
            ?>
 >
				    	<a href="<?php 
            echo SendPress_Admin::link('Emails_Temp');
            ?>
"><?php 
            _e('Templates', 'sendpress');
            ?>
</a>
				  	</li>
				  	<li <?php 
            if (isset($_GET['view']) && ($_GET['view'] === 'templates' || $_GET['view'] === 'tempedit')) {
                ?>
class="active"<?php 
            }
            ?>
 >
				    	<a href="<?php 
            echo SendPress_Admin::link('Emails_Templates');
            ?>
"><?php 
            _e('Custom Templates', 'sendpress');
            ?>
</a>
				  	</li>
				  	<?php 
            //}
            ?>
				  	<li <?php 
            if (isset($_GET['view']) && $_GET['view'] === 'social') {
                ?>
class="active"<?php 
            }
            ?>
 >
				    	<a href="<?php 
            echo SendPress_Admin::link('Emails_Social');
            ?>
"><?php 
            _e('Social Icons', 'sendpress');
            ?>
</a>
				  	</li>
				  	<li <?php 
            if (isset($_GET['view']) && in_array($_GET['view'], array('postnotifications'))) {
                ?>
class="active"<?php 
            }
            ?>
 >
              <a href="<?php 
            echo SendPress_Admin::link('Emails_Postnotifications');
            ?>
"><?php 
            _e('Post Notifications', 'sendpress');
            ?>
</a>
            </li>
				  	
            
            <?php 
            if (SendPress_Option::get('beta')) {
                ?>
         
              <li <?php 
                if (isset($_GET['view']) && in_array($_GET['view'], array('autoresponder', 'autoedit'))) {
                    ?>
class="active"<?php 
                }
                ?>
 >
                <a href="<?php 
                echo SendPress_Admin::link('Emails_Autoresponder');
                ?>
"><?php 
                _e('Automation', 'sendpress');
                ?>
</a>
              </li>
           
              
            <?php 
            }
            ?>

            <li <?php 
            if (strpos($sp->_current_view, 'systememail') !== false) {
                ?>
class="active"<?php 
            }
            ?>
 ><a <?php 
            if (strpos($sp->_current_view, 'systememail') !== false) {
                ?>
class="wp-ui-primary"<?php 
            }
            ?>
  href="<?php 
            echo SendPress_Admin::link('Emails_Systememail');
            ?>
"><i class=" icon-bullhorn"></i> <?php 
            _e('System Email', 'sendpress');
            ?>
</a></li>
				</ul>
			</div>
		</div>

		<?php 
        }