本文整理汇总了PHP中WYSIJA::get_cron_schedule方法的典型用法代码示例。如果您正苦于以下问题:PHP WYSIJA::get_cron_schedule方法的具体用法?PHP WYSIJA::get_cron_schedule怎么用?PHP WYSIJA::get_cron_schedule使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WYSIJA
的用法示例。
在下文中一共展示了WYSIJA::get_cron_schedule方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wysija_exec_process
function wysija_exec_process($process = 'queue')
{
$scheduled_times = WYSIJA::get_cron_schedule($process);
if (isset($scheduled_times['running']) && $scheduled_times['running'] && $scheduled_times['running'] + 900 > time()) {
echo 'already running : ' . $process . '<br/>';
return;
}
//set schedule as running
WYSIJA::set_cron_schedule($process, 0, time());
//execute schedule
switch ($process) {
case 'queue':
WYSIJA::croned_queue($process);
$hPremium =& WYSIJA::get('premium', 'helper', false, WYSIJANLP);
if (is_object($hPremium)) {
$hPremium->splitVersion_croned_queue_process();
}
break;
case 'bounce':
$hPremium =& WYSIJA::get('premium', 'helper', false, WYSIJANLP);
if (is_object($hPremium)) {
$hPremium->croned_bounce();
}
break;
case 'daily':
WYSIJA::croned_daily();
break;
case 'weekly':
if (is_object($hPremium)) {
$hPremium->croned_weekly();
}
break;
case 'monthly':
WYSIJA::croned_monthly();
break;
}
//set next_schedule
WYSIJA::set_cron_schedule($process);
if ($report) {
echo 'processed : ' . $process . '<br/>';
}
}
示例2: cron_check
/**
* check that there is no passed schedules that need to be executed now
* @return void
*/
public static function cron_check()
{
$cron_schedules = WYSIJA::get_cron_schedule('all');
if (empty($cron_schedules)) {
return;
} else {
$processes = WYSIJA::get_cron_frequencies();
$updatedsched = false;
foreach ($cron_schedules as $proc => &$params) {
$running = 0;
if (isset($params['running'])) {
$running = $params['running'];
}
//if the process has timedout we reschedule the next execution
if ($running && time() > $running + 900) {
//WYSIJA::setInfo('error','modifying next schedule for '.$proc);
$next_schedule = time() + $processes[$proc];
$params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
$updatedsched = true;
}
}
if ($updatedsched) {
//WYSIJA::setInfo('error','updating scheds');
WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
}
}
$timenow = time();
$processesToRun = array();
foreach ($cron_schedules as $process => $scheduled_times) {
if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + 900 < $timenow) && $scheduled_times['next_schedule'] < $timenow) {
$processesToRun[] = $process;
}
}
$model_config =& WYSIJA::get('config', 'model');
if (!empty($processesToRun) && $model_config->getValue('cron_page_hit_trigger')) {
//call the cron url
$cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
//TODO we should use the http class there
$hHTTP =& WYSIJA::get('http', 'helper');
$hHTTP->request_timeout($cron_url);
}
}
示例3: run_scheduled_task
/**
* run process if it's not detected as already running
* @param type $process
* @return type
*/
function run_scheduled_task($process = 'queue')
{
//first let's make sure that the process asked to be run is not already running
$scheduled_times = WYSIJA::get_cron_schedule($process);
$processes = WYSIJA::get_cron_frequencies();
$process_frequency = $processes[$process];
// check if the scheduled task is already being processed,
// we consider it timed out once the started running time plus the frequency has been passed
if (!empty($scheduled_times['running']) && $scheduled_times['running'] + $process_frequency > time()) {
if ($this->report) {
echo 'already running : ' . $process . '<br/>';
}
return;
}
// set schedule as running
WYSIJA::set_cron_schedule($process, 0, time());
// execute schedule
switch ($process) {
case 'queue':
// check if there are any scheduled newsletters ready for action
WYSIJA::check_scheduled_newsletters();
// if premium is activated we execute the premium cron process
if (defined('WYSIJANLP')) {
$helper_premium = WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$helper_premium->croned_queue_process();
} else {
// run the standard queue process no scheduled tasks will be check since it has already been checked above
WYSIJA::croned_queue(false);
}
break;
case 'bounce':
$helper_premium = WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$model_config = WYSIJA::get('config', 'model');
// if premium is activated we launch the premium function
if (is_multisite()) {
$multisite_prefix = 'ms_';
}
// we don't process the bounce automatically unless the option is ticked
if (defined('WYSIJANLP') && $model_config->getValue($multisite_prefix . 'bounce_process_auto')) {
$helper_premium->croned_bounce();
} else {
$process .= ' (bounce handling not activated)';
}
break;
case 'daily':
WYSIJA::croned_daily();
break;
case 'weekly':
if (defined('WYSIJANLP')) {
$helper_premium = WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$helper_premium->croned_weekly();
}
WYSIJA::croned_weekly();
break;
case 'monthly':
WYSIJA::croned_monthly();
break;
}
// set next_schedule details
WYSIJA::set_cron_schedule($process);
if ($this->report) {
echo 'processed : ' . $process . '<br/>';
}
}
示例4: defaultDisplay
//.........这里部分代码省略.........
$columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
foreach ($senttotalgroupedby as $sentbystatus) {
if ($sentbystatus['statususer'] != "-2") {
$updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
}
if (isset($senttotal[$sentbystatus['email_id']])) {
$senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
} else {
unset($sentbystatus['statususer']);
$senttotal[$sentbystatus['email_id']] = $sentbystatus;
}
}
$model_email = WYSIJA::get('email', 'model');
foreach ($updateEmail as $emailid => $update) {
foreach ($columnnamestatus as $v) {
if (!isset($update[$v])) {
$update[$v] = 0;
}
}
$model_email->update($update, array('email_id' => $emailid));
$model_email->reset();
}
$model_config = WYSIJA::get('config', 'model');
$running = false;
$is_multisite = is_multisite();
if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
$sending_emails_each = $model_config->getValue('ms_sending_emails_each');
} else {
$sending_emails_each = $model_config->getValue('sending_emails_each');
}
if ($model_config->getValue('cron_manual')) {
$formsHelp = WYSIJA::get('forms', 'helper');
$queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
$queue_scheduled = WYSIJA::get_cron_schedule('queue');
$next_scheduled_queue = $queue_scheduled['next_schedule'];
$running = $queue_scheduled['running'];
if ($running) {
$helper_toolbox = WYSIJA::get('toolbox', 'helper');
$running = time() - $running;
$running = $helper_toolbox->duration_string($running, true, 4);
}
} else {
$schedules = wp_get_schedules();
$queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
$next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
}
$status_sent_complete = array();
if (isset($senttotal) && $senttotal) {
foreach ($senttotal as $sentot) {
if ($sentot) {
$this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
$this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
} else {
$this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
}
$this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
$this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
$this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
}
}
foreach ($statstotal as $sentot) {
if (!isset($this->data['sent'][$sentot['email_id']])) {
$this->data['sent'][$sentot['email_id']]['total'] = 0;
$this->data['sent'][$sentot['email_id']]['to'] = 0;
}
$this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
示例5: cron_check
/**
* check that there is no passed schedules that need to be executed now
* @return void
*/
public static function cron_check()
{
$cron_schedules = WYSIJA::get_cron_schedule('all');
if (empty($cron_schedules)) {
return;
} else {
$processes = WYSIJA::get_cron_frequencies();
$updated_sched = false;
foreach ($cron_schedules as $schedule => &$params) {
$running = 0;
$time_now = time();
if (isset($params['running'])) {
$running = $params['running'];
}
//if the process has timedout we reschedule the next execution
if ($running && $time_now > $running + $processes[$schedule]) {
//WYSIJA::setInfo('error','modifying next schedule for '.$proc);
$process_frequency = $processes[$schedule];
$next_schedule = $running + $process_frequency;
// if the next schedule is already behind, we give it 30 seconds before it can trigger again
if ($next_schedule < $time_now) {
$next_schedule = $time_now + 30;
}
$params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
$updated_sched = true;
}
}
if ($updated_sched) {
//WYSIJA::setInfo('error','updating scheds');
WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
}
}
$time_now = time();
$processesToRun = array();
foreach ($cron_schedules as $schedule => $scheduled_times) {
if (strpos($schedule, '(bounce handling not activated)') !== false) {
continue;
}
if (!isset($processes[$schedule])) {
continue;
}
$process_frequency = $processes[$schedule];
if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + $process_frequency < $time_now) && $scheduled_times['next_schedule'] < $time_now) {
$processesToRun[] = $schedule;
}
}
$model_config = WYSIJA::get('config', 'model');
$page_view_trigger = (int) $model_config->getValue('cron_page_hit_trigger');
if (!empty($processesToRun) && $page_view_trigger === 1) {
//call the cron url
// do not call that more than once per 5 minutes attempt at reducing the CPU load for some users
// http://wordpress.org/support/topic/wysija-newsletters-slowing-down-my-site-1
$last_cron_time_plus_5min = (int) get_option('wysija_last_php_cron_call') + 5 * 60;
if ($last_cron_time_plus_5min < time()) {
$cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
$cron_request = apply_filters('cron_request', array('url' => $cron_url, 'args' => array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))));
wp_remote_post($cron_url, $cron_request['args']);
WYSIJA::update_option('wysija_last_php_cron_call', time());
}
}
}
示例6: defaultDisplay
//.........这里部分代码省略.........
if ($sentbystatus['statususer'] != "-2") {
$updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
}
if (isset($senttotal[$sentbystatus['email_id']])) {
$senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
} else {
unset($sentbystatus['statususer']);
$senttotal[$sentbystatus['email_id']] = $sentbystatus;
}
}
$modelEmail = WYSIJA::get('email', 'model');
foreach ($updateEmail as $emailid => $update) {
foreach ($columnnamestatus as $v) {
if (!isset($update[$v])) {
$update[$v] = 0;
}
}
$modelEmail->update($update, array('email_id' => $emailid));
$modelEmail->reset();
}
/**/
$modelC = WYSIJA::get('config', 'model');
$running = false;
$is_multisite = is_multisite();
//$is_multisite=true;//PROD comment that line
if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
$sending_emails_each = $modelC->getValue('ms_sending_emails_each');
} else {
$sending_emails_each = $modelC->getValue('sending_emails_each');
}
if ($modelC->getValue('cron_manual')) {
$formsHelp = WYSIJA::get('forms', 'helper');
$queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
$queue_scheduled = WYSIJA::get_cron_schedule('queue');
$next_scheduled_queue = $queue_scheduled['next_schedule'];
$running = $queue_scheduled['running'];
if ($running) {
$helperToolbox = WYSIJA::get('toolbox', 'helper');
$running = time() - $running;
$running = $helperToolbox->duration($running, true, 4);
}
} else {
$schedules = wp_get_schedules();
$queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
$next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
}
$status_sent_complete = array();
if (isset($senttotal) && $senttotal) {
foreach ($senttotal as $sentot) {
if ($sentot) {
$this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
$this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
} else {
$this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
}
$this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
$this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
$this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
}
}
foreach ($statstotal as $sentot) {
if (!isset($this->data['sent'][$sentot['email_id']])) {
$this->data['sent'][$sentot['email_id']]['total'] = 0;
$this->data['sent'][$sentot['email_id']]['to'] = 0;
}
$this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
示例7: run_scheduled_task
function run_scheduled_task($process = 'queue')
{
$scheduled_times = WYSIJA::get_cron_schedule($process);
if (isset($scheduled_times['running']) && $scheduled_times['running'] && $scheduled_times['running'] + 900 > time()) {
if ($this->report) {
echo 'already running : ' . $process . '<br/>';
}
return;
}
WYSIJA::set_cron_schedule($process, 0, time());
switch ($process) {
case 'queue':
WYSIJA::croned_queue($process);
if (defined('WYSIJANLP')) {
$hPremium =& WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$hPremium->croned_queue_process();
}
break;
case 'bounce':
if (defined('WYSIJANLP')) {
$hPremium =& WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$hPremium->croned_bounce();
}
break;
case 'daily':
WYSIJA::croned_daily();
break;
case 'weekly':
if (defined('WYSIJANLP')) {
$hPremium =& WYSIJA::get('premium', 'helper', false, WYSIJANLP);
$hPremium->croned_weekly();
}
WYSIJA::croned_weekly();
break;
case 'monthly':
WYSIJA::croned_monthly();
break;
}
WYSIJA::set_cron_schedule($process);
if ($this->report) {
echo 'processed : ' . $process . '<br/>';
}
}
示例8: cron_check
/**
* check that there is no passed schedules that need to be executed now
* @return void
*/
public static function cron_check()
{
$cron_schedules = WYSIJA::get_cron_schedule('all');
if (empty($cron_schedules)) {
return;
} else {
$processes = WYSIJA::get_cron_frequencies();
$updated_sched = false;
foreach ($cron_schedules as $schedule => &$params) {
$running = 0;
$time_now = time();
if (isset($params['running'])) {
$running = $params['running'];
}
//if the process has timedout we reschedule the next execution
if ($running && $time_now > $running + $processes[$schedule]) {
//WYSIJA::setInfo('error','modifying next schedule for '.$proc);
$process_frequency = $processes[$schedule];
$next_schedule = $running + $process_frequency;
// if the next schedule is already behind, we give it 30 seconds before it can trigger again
if ($next_schedule < $time_now) {
$next_schedule = $time_now + 30;
}
$params = array('next_schedule' => $next_schedule, 'prev_schedule' => $running, 'running' => false);
$updated_sched = true;
}
}
if ($updated_sched) {
//WYSIJA::setInfo('error','updating scheds');
WYSIJA::update_option('wysija_schedules', $cron_schedules, 'yes');
}
}
$time_now = time();
$processesToRun = array();
foreach ($cron_schedules as $schedule => $scheduled_times) {
$process_frequency = $processes[$schedule];
if ((!$scheduled_times['running'] || (int) $scheduled_times['running'] + $process_frequency < $time_now) && $scheduled_times['next_schedule'] < $time_now) {
$processesToRun[] = $schedule;
}
}
$model_config = WYSIJA::get('config', 'model');
$page_view_trigger = (int) $model_config->getValue('cron_page_hit_trigger');
if (!empty($processesToRun) && $page_view_trigger === 1) {
//call the cron url
$cron_url = site_url('wp-cron.php') . '?' . WYSIJA_CRON . '&action=wysija_cron&process=' . implode(',', $processesToRun) . '&silent=1';
$cron_request = apply_filters('cron_request', array('url' => $cron_url, 'args' => array('timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters('https_local_ssl_verify', true))));
wp_remote_post($cron_url, $cron_request['args']);
}
}