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: " . $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() { 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 }