本文整理汇总了PHP中WYSIJA::get_cron_frequencies方法的典型用法代码示例。如果您正苦于以下问题:PHP WYSIJA::get_cron_frequencies方法的具体用法?PHP WYSIJA::get_cron_frequencies怎么用?PHP WYSIJA::get_cron_frequencies使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WYSIJA
的用法示例。
在下文中一共展示了WYSIJA::get_cron_frequencies方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例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();
$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());
}
}
}
示例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: 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']);
}
}