本文整理汇总了PHP中SendPress_Data::emails_in_queue方法的典型用法代码示例。如果您正苦于以下问题:PHP SendPress_Data::emails_in_queue方法的具体用法?PHP SendPress_Data::emails_in_queue怎么用?PHP SendPress_Data::emails_in_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendPress_Data
的用法示例。
在下文中一共展示了SendPress_Data::emails_in_queue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_mail
static function send_mail()
{
global $wpdb;
$attempted_count = SendPress_Option::get('autocron-per-call', 25);
if (SendPress_Manager::limit_reached($attempted_count)) {
return;
}
$count = SendPress_Data::emails_in_queue();
$email_count = 0;
$attempts = 0;
SendPress_Email_Cache::build_cache();
if ($count > 0) {
for ($i = 0; $i < $attempted_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));
SPNL()->db->subscribers_tracker->add(array('subscriber_id' => intval($email->subscriberID), 'email_id' => intval($email->emailID)));
} else {
$wpdb->update(SendPress_Data::queue_table(), array('success' => 2, 'inprocess' => 3), array('id' => $email->id));
SendPress_Data::bounce_subscriber_by_id($email->subscriberID);
}
} 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));
}
}
}
}
}
示例2: send_mail
static function send_mail()
{
global $wpdb;
$attempted_count = SendPress_Option::get('autocron-per-call', 25);
if (SendPress_Manager::limit_reached($attempted_count)) {
return;
}
$count = SendPress_Data::emails_in_queue();
$email_count = 0;
$attempts = 0;
SendPress_Email_Cache::build_cache();
if ($count > 0) {
for ($i = 0; $i < $attempted_count; $i++) {
$email = SendPress_Data::get_single_email_from_queue();
SendPress_Queue::send_the_queue($email);
}
}
}
示例3: auto_cron
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;
}
}
}
示例4: emails_allowed_to_send
static function emails_allowed_to_send()
{
$emails_per_day = SendPress_Option::get('emails-per-day');
$emails_per_hour = SendPress_Option::get('emails-per-hour');
$count = SendPress_Data::emails_in_queue();
$emails_this_hour = SendPress_Data::emails_sent_in_queue("hour");
$emails_today = SendPress_Data::emails_sent_in_queue("day");
$hour = $emails_per_hour - $emails_this_hour;
$day = $emails_per_day - $emails_today;
if ($count <= $hour && $count <= $day) {
return $count;
}
if ($hour <= $day) {
return $hour;
}
return $day;
}
示例5: column_default
/** ************************************************************************
* Recommended. This method is called when the parent class can't find a method
* specifically build for a given column. Generally, it's recommended to include
* one method for each column you want to render, keeping your package class
* neat and organized. For example, if the class needs to process a column
* named 'title', it would first see if a method named $this->column_title()
* exists - if it does, that method will be used. If it doesn't, this one will
* be used. Generally, you should try to use custom column methods as much as
* possible.
*
* Since we have defined a column_title() method later on, this method doesn't
* need to concern itself with any column with a name of 'title'. Instead, it
* needs to handle everything else.
*
* For more detailed insight into how columns are handled, take a look at
* WP_List_Table::single_row_columns()
*
* @param array $item A singular item (one full row's worth of data)
* @param array $column_name The name/slug of the column to be processed
* @return string Text or HTML to be placed inside the column <td>
**************************************************************************/
function column_default($item, $column_name)
{
$stat_type = get_post_meta($item->ID, '_stat_type', true);
switch ($column_name) {
/* case 'firstname':
case 'lastname':
return $item->$column_name;
case 'status':
return $item->$column_name;
*/
case 'bounces':
return '<span class="label">Coming Soon</span>';
break;
case 'count':
$rec = get_post_meta($item->ID, '_send_count', true) + get_post_meta($item->ID, '_send_last_count', true) . '';
$sentold = get_post_meta($item->ID, '_sent_total', true);
$queue = 0;
$sent = get_post_meta($item->ID, '_send_total', true);
$inqueue = get_post_meta($item->ID, '_in_queue', true);
if ($inqueue !== 'none') {
$queue = SendPress_Data::emails_in_queue($item->ID);
$sentindb = SendPress_Data::emails_sent_in_queue_for_report($item->ID);
if ($sentindb > $sent) {
update_post_meta($item->ID, '_send_total', $sentindb);
$sent = $sentindb;
}
if ($queue == 0) {
update_post_meta($item->ID, '_in_queue', 'none');
}
}
$string = "Recipients: " . $rec . "<br>";
$string .= "Sent: " . $sent . "<br>";
$string .= "In Queue: " . $queue . "<br>";
return $string;
break;
case 'sentto':
$display = '';
$info = get_post_meta($item->ID, '_send_data', true);
if (!empty($info['listIDS'])) {
foreach ($info['listIDS'] as $list_id) {
$list = get_post($list_id);
if ($list && $list->post_type == 'sendpress_list') {
$display .= $list->post_title . '<br>';
}
}
} else {
$lists = get_post_meta($item->ID, '_send_lists', true);
$list = explode(",", $lists);
foreach ($list as $list_id) {
$list = get_post($list_id);
if ($list && $list->post_type == 'sendpress_list') {
$display .= $list->post_title . '<br>';
}
}
}
return $display;
break;
case 'opens':
//if( $stat_type == 'new'){
$opens = SPNL()->load("Subscribers_Tracker")->get_opens($item->ID);
$opens_total = SPNL()->load("Subscribers_Tracker")->get_opens_total($item->ID);
$opens = $opens == 0 ? '-' : $opens;
$opens_total = $opens_total == 0 ? '-' : $opens_total;
return '<span class="label label-success">' . $opens . '</span> <span class="label label-info">' . $opens_total . '</span>';
/*
} else {
$ou = $this->_sendpress->get_opens_unique_count($item->ID);
$ou = $ou ? $ou : '-';
$ot = $this->_sendpress->get_opens_count($item->ID);
$ot = $ot ? $ot : '-';
return '<span class="label label-success">'. $ou .'</span> <span class="label label-info">'. $ot .'</span>';
}
*/
break;
case 'clicks':
//.........这里部分代码省略.........
示例6: auto_cron
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;
}
}
}
示例7: html
function html()
{
SendPress_Queue::send_mail();
$count = SendPress_Data::emails_in_queue();
echo json_encode(array("queue" => $count));
}
示例8: prepare_items
/** ************************************************************************
* REQUIRED! This is where you prepare your data for display. This method will
* usually be used to query the database, sort and filter the data, and generally
* get it ready to be displayed. At a minimum, we should set $this->items and
* $this->set_pagination_args(), although the following properties and methods
* are frequently interacted with here...
*
* @uses $this->_column_headers
* @uses $this->items
* @uses $this->get_columns()
* @uses $this->get_sortable_columns()
* @uses $this->get_pagenum()
* @uses $this->set_pagination_args()
**************************************************************************/
function prepare_items()
{
global $wpdb, $_wp_column_headers;
$screen = get_current_screen();
/*
select t1.* from `sp_sendpress_list_subscribers` as t1 , `sp_sendpress_subscribers` as t2
where t1.subscriberID = t2.subscriberID and t1.listID = 2*/
$query = "SELECT * FROM " . SendPress_Data::queue_table();
/* -- Pagination parameters -- */
//Number of elements in your table?
$totalitems = SendPress_Data::emails_in_queue();
//$wpdb->query($query); //return the total number of affected rows
//How many to display per page?
// get the current user ID
$user = get_current_user_id();
// get the current admin screen
$screen = get_current_screen();
// retrieve the "per_page" option
$per_page = 10;
$screen_option = $screen->get_option('per_page', 'option');
if (!empty($screen_option)) {
// retrieve the value of the option stored for the current user
$per_page = get_user_meta($user, $screen_option, true);
if (empty($per_page) || $per_page < 1) {
// get the default value if none is set
$per_page = $screen->get_option('per_page', 'default');
}
}
//Which page is this?
$paged = !empty($_GET["paged"]) ? esc_sql($_GET["paged"]) : '';
//Page Number
if (empty($paged) || !is_numeric($paged) || $paged <= 0) {
$paged = 1;
}
//How many pages do we have in total?
$totalpages = ceil($totalitems / $per_page);
$query .= ' WHERE success = 0 AND max_attempts > attempts ';
$query .= "AND ( date_sent = '0000-00-00 00:00:00' or date_sent < '" . date_i18n('Y-m-d H:i:s') . "') ";
if (isset($_GET["listid"]) && $_GET["listid"] > 0) {
$query .= ' AND listID = ' . $_GET["listid"];
}
if (isset($_GET["qs"])) {
$query .= ' AND to_email LIKE "%' . $_GET["qs"] . '%"';
}
/* -- Ordering parameters -- */
//Parameters that are going to be used to order the result
$orderby = !empty($_GET["orderby"]) ? esc_sql($_GET["orderby"]) : '';
$order = !empty($_GET["order"]) ? esc_sql($_GET["order"]) : 'ASC';
if (!empty($orderby) & !empty($order)) {
$query .= ' ORDER BY ' . $orderby . ' ' . $order;
}
if (empty($orderby)) {
$query .= ' ORDER BY attempts ASC, id ASC ';
}
//adjust the query to take pagination into account
if (!empty($paged) && !empty($per_page)) {
$offset = ($paged - 1) * $per_page;
$query .= ' LIMIT ' . (int) $offset . ',' . (int) $per_page;
}
/* -- Register the pagination -- */
$this->set_pagination_args(array("total_items" => $totalitems, "total_pages" => $totalpages, "per_page" => $per_page));
//The pagination links are automatically built according to those parameters
/* -- Register the Columns -- */
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
/* -- Fetch the items -- */
$this->items = $wpdb->get_results($query);
}
示例9: queue_count
function queue_count()
{
$this->verify_ajax_call();
// Create the response array
//
$count = SendPress_Data::emails_in_queue();
//$sp = new SendPress;
$response = array('total' => $count);
echo json_encode($response);
exit;
}