__construct();
$utctzobj = timezone_open('UTC');
$tzobj = $utctzobj;
if ($tz = get_option ('timezone_string') ) $tzobj = timezone_open($tz);
}
function __construct() {
global $tzobj;
load_plugin_textdomain('amr-cron-manager', false, dirname( plugin_basename( __FILE__ ) ) . 'lang');
add_action('admin_menu', array($this, 'add_admin_menu'));
$sp = '&\nb\sp;';
$this->dateformat = 'D'.$sp.'d'.$sp.'M'.$sp.'y';
$this->datetimeformat = $this->dateformat.', H:i:s e'; //'l, j M y';//get_option('date_format');
}
function set_startdate() {
global $tzobj;
$gmt_time = (int) microtime(true);
for ($i = 1; $i <= 8; $i++) {
$blogtime = $this->convert_UTC_timestamp_to_blog($gmt_time,$tzobj);
$nextdates[$gmt_time] = date_i18n($this->dateformat,$blogtime);
$gmt_time = $gmt_time + (60*60*24);
}
$html = '';//'
';
//';
$html .= '';
return($html);
}
function set_starttime() {
global $tzobj;
$gmt_time = (int) microtime(true);
$timestamp = $this->convert_UTC_timestamp_to_blog($gmt_time, $tzobj);
$time = date('H:i',$timestamp);
$html = '';
$html .= '';
return($html);
}
function add_admin_menu($s) {
global $wp_version;
add_submenu_page(
version_compare($wp_version, "2.7", ">=") ? 'tools.php' : 'edit.php', //parent
'amr-cron' , //page title
__('Cron Manager', 'amr-cron-manager') , //Menu title
'administrator' , //capability
'amr-cron-manager', //dirname(__FILE__) , //menu slug
array(&$this,'wp_cron_menu') //function
);
return $s;
}
function convert_blog_timestamp_to_UTC($timestamp,$tzobj) {
$date = date_create('now', $tzobj);
$utctzobj = timezone_open('UTC');
$date->format('U');
$date->setTimezone($utctzobj);
return($date->format('U'));
}
function convert_UTC_timestamp_to_blog($timestamp,$tzobj) {
$date = date_create('@'.$timestamp);
$date->setTimezone($tzobj);
$offset = $date->getOffset();
$newtimestamp = $timestamp+$offset;
return($newtimestamp);
}
function cronmgr_settings() {
//amr_cron_license_page(); not really needed yet - add if lots of feature requests
}
function unschedule ($hook,$timestamp,$args) {
global $wp_filter, $tzobj, $utctzobj;
$blogtime = $this->convert_UTC_timestamp_to_blog($timestamp,$tzobj );
wp_clear_scheduled_hook( $hook, $args );
// args dont always go if they were int not string
foreach ($args as $i=>$v) {
if (is_numeric($v)) $args[$i] = (int) $v;
}
wp_unschedule_event($timestamp, $hook, $args ); //no return value
// check if it was actually deleted
$crons = _get_cron_array();
if ( isset( $crons[$timestamp][$hook] ) ) {
$key = md5(serialize($args)); var_dump($key);
var_dump($args);
var_dump($crons[$timestamp][$hook]);
$note = __('Still some left - maybe these have arguments?','amr-cron-manager')
." ".$hook." (".$timestamp.")";
$note .= __('Try using Really Delete','amr-cron-manager');
}
else
$note = sprintf(__('Unscheduled %s for %s','amr-cron-manager'),$hook,date_i18n('d-M H:i',$blogtime)
//.' ('.$timestamp.')'
);
$note = '
'.$note.'
'.$note.'
'.$note.'
'.count($timeslots).' '.__('Timeslots:','amr-cron-manager').'
'; $ans .= '| '.__('Date and Time').' | Job | Action by priority? | ' .'Frequency | Arguments | Actions: Run sooner or delete? | |
|---|---|---|---|---|---|---|
| '
.date_i18n($this->datetimeformat,$blogtimestamp)
.''
//. '('.$gmt_time.')'
.' '; if ($gmt_time < $gmt_now ) { $timetext .= __('ASAP','amr-cron-manager'); } else { $timetext .= sprintf(__('In %s time','amr-cron-manager') , human_time_diff( $gmt_time ,$gmt_now)); } $timetext .= ' '; $timetext .= sprintf(_n('%s task','%s tasks',count($tasks), 'amr-cron-manager'),count($tasks)); $timetext .= ' | '.PHP_EOL;
$taskcount = 1;
foreach ($tasks as $procname => $task) {
if ($taskcount > 1) $taskline = '||||||
| '; else $taskline = $timetext; $taskline .= ' | '.$procname.' | '; $taskcount++; if (has_action( $procname )) { $action = ' √'.__('exists','amr-cron-manager'); if (isset($GLOBALS['wp_filter'][$procname])) { foreach ($GLOBALS['wp_filter'][$procname] as $priority => $prioritisedtasks) { foreach ($prioritisedtasks as $functions_to_do) { foreach ($functions_to_do as $func) { if (!($func == 1)) { if (is_array($func)) { // probably object and function if (is_object($func[0])) { $info = get_class($func[0]).'::'.$func[1]; } else $info = print_r($func,true); $action .= ''. $action.' | '; $taskwithargcount = 1; foreach ($task as $md5key => $taskdetails) { if ($taskwithargcount > 1) $taskwithargs = ''; else $taskwithargs = $taskline; $uns = ''; if (!empty($taskdetails['schedule'])) $schedule = $taskdetails['schedule']; else $schedule = 'single run'; // $uns = ' '.PHP_EOL; // $taskwithargs .= ' | '. $schedule.' | '; $argsline = ''; $butargs = ''; if (!empty($taskdetails['args'])) { // $key = md5(serialize($taskdetails['args'])); // $args = (serialize(esc_attr($taskdetails['args']))); foreach ($taskdetails['args'] as $i => $value) { $argsline .= $i.'='. $value; $butargs .= ''.PHP_EOL; } } else { $key = ''; $argsline .= ' '; $args = ''; } $taskwithargs .= ''. $argsline.' | '; // Add in delete button for each entry. $but = ''; $but .= ''.PHP_EOL; $taskwithargs .= ''.$but." |
A key point about default wordpress cron is that it only runs if there is traffic on the website. So if you are testing at low traffic hours you may not see a cron job run when you think it should. If you want more immediate and reliable scheduled action please google 'wordpress cron' - there is a lot of content out there about wordpress cron and alternate ways to run it. For most sites wordpress default cron is adequate.
See the point above. Click on 'Trigger cron now', then go back to dashboard and refresh the dashboard.
To run a job 'now', leave the date and time proposed as is (they will be in the past by the time you have looked at the screen. Then click reschedule. That will reschedule that job for that time and the job should run. You may have to click 'trigger cron now'. The trigger cron now page is useful when you are debugging cron jobs. You may temporarily issue output and it will be visible if the cron runs on that 'trigger cron' page load.
It probably rescheduled and ran, and then setup the next run as per it's frequency.
If you have triggered the cron and think a job should have run, then refresh the cron dashboard to see. It will either
If a job has no action it will do nothing. It is just there, an entry that keeps getting rescheduled. Maybe the plugin that created it got deleted? Someplugins don't know to clean up after themselves. Maybe it is just temporarily inactive? Maybe it's a bug in the creating plugin? If you don't think you need it, delete it.
The only way to do this is either maybe wordpress or the creating plugin will automaticaly bring the job back to life, or you ay have to reactivate the creating plugin. Yes that means deactivate then activate again.
Some plugins check whether their jobs are running and if not, they recreate them.