本文整理汇总了PHP中SendPress_Data::queue_table方法的典型用法代码示例。如果您正苦于以下问题:PHP SendPress_Data::queue_table方法的具体用法?PHP SendPress_Data::queue_table怎么用?PHP SendPress_Data::queue_table使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SendPress_Data
的用法示例。
在下文中一共展示了SendPress_Data::queue_table方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: send_single_from_queue
static function send_single_from_queue()
{
global $wpdb;
//$emails = $this->wpdbQuery("SELECT * FROM ".$this->queue_table()." WHERE success = 0 AND max_attempts != attempts LIMIT ".$limit,"get_results");
$count = 0;
$attempts = 0;
$queue_table = SendPress_Data::queue_table();
if (SendPress_Manager::limit_reached()) {
return array('attempted' => $attempts, 'sent' => $count);
}
SendPress_Email_Cache::build_cache();
$email = SendPress_Data::get_single_email_from_queue(true);
if (is_object($email)) {
//$email = $email[0];
if (SendPress_Manager::limit_reached()) {
return array('attempted' => $attempts, 'sent' => $count);
}
$attempts++;
SendPress_Data::queue_email_process($email->id);
$result = SendPress_Manager::send_email_from_queue($email);
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->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'))));
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);
}
$count++;
} else {
$wpdb->update($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.
return array('attempted' => $attempts, 'sent' => $count);
}
//SendPress_Manager::increase_email_count( $attempts );
return array('attempted' => $attempts, 'sent' => $count);
}
示例2: 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_sent_in_queue('All');
//$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 = 1 ';
//$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 id DESC ';
}
//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);
}
示例3: add_email_to_queue
static function add_email_to_queue($values)
{
global $wpdb;
$table = SendPress_Data::queue_table();
$messageid = SendPress_Data::unique_message_id();
$values["messageID"] = $messageid;
$values["max_attempts"] = 1;
$values["date_published"] = date('Y-m-d H:i:s');
$wpdb->insert($table, $values);
return $wpdb->insert_id;
}
示例4: html
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');
?>
//.........这里部分代码省略.........
示例5: send_mail_cron
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;
}
示例6: queue_table
function queue_table()
{
_deprecated_function(__FUNCTION__, '0.8.9', 'SendPress_Data::queue_table()');
return SendPress_Data::queue_table();
}