ajax = new ACMajax(); add_filter( 'cron_schedules', array($this, 'add_schedules_to_filter') ); $this->time_offset = get_option('gmt_offset') * 3600; add_action('admin_menu', array($this, 'add_menu_page')); add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_and_styles')); } public function add_schedules_to_filter($schedules) { foreach ( get_option('acm_schedules', array()) as $name => $schedule ) { $schedules[$name] = array( 'interval' => $schedule['interval'], 'display' => $schedule['display'] ); } return $schedules; } public function enqueue_scripts_and_styles($hook) { if( 'tools_page_acm' != $hook ) return; wp_enqueue_script( 'acm_scripts', ACM_URL.'assets/js/admin.js', array('jquery'), 1, true ); wp_enqueue_script( 'acm_ajax_scripts', ACM_URL.'assets/js/ajax.js', array('jquery'), 1, true ); wp_enqueue_style( 'acm_style', ACM_URL.'assets/css/style.css' ); } public function add_menu_page() { add_management_page('Advanced Cron Manager', 'Cron Manager', 'manage_options', 'acm', array($this, 'acm_page')); } public function acm_page() { $this->parse_crons(); ?>
show_notifications(); ?>

display_content(); ?>
display_aside(); ?>
$crons) { foreach ($crons as $cron_name => $cron_args) { foreach ($cron_args as $cron) { $this->crons[$timestamp + $this->time_offset][] = array( 'hook' => $cron_name, 'cron' => $cron, 'hash' => acm_get_cron_hash($cron_name, $timestamp, $cron['args'], (!isset($cron['interval'])) ? 0 : $cron['interval']) ); } } } ksort($this->crons); } public function show_notifications() { echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; } public function display_content() { $this->schedules = wp_get_schedules(); $this->display_cron_table(); } public function display_aside() { echo '

'.__('Cron Schedules', 'acm').'

'; $this->display_cron_schedules(); echo '
'; echo '

'.__('Informations', 'acm').'

'; $this->display_informations_widget(); echo '
'; } public function display_informations_widget() { echo '

'; _e('Please remember - after deactivation of this plugin added Schedules will be not available. Added Tasks will still work.', 'acm'); echo '

'; echo '

'; _e('Important - WordPress Cron is depended on the User. WP Cron fires only on the page visit so it can be not accurate.', 'acm'); echo '

'; } public function display_cron_schedules() { echo ''; echo '
'; $this->display_add_schedule_form(); } public function display_add_schedule_form() { ?> display_cron_table_body(); ?>
crons as $timestamp => $cron_many) { foreach ($cron_many as $cron) { $alternate = ($alternate == '') ? 'alternate' : ''; echo ''; echo ''; echo $cron['hook']; $this->display_row_actions($cron['hook'], (!isset($cron['cron']['interval'])) ? 0 : $cron['cron']['interval'], $cron['cron']['args']); echo ''; echo ''; echo empty($cron['cron']['schedule']) ? _e('single', 'acm') : $cron['cron']['schedule']; echo ''; echo ''.acm_get_cron_arguments($cron['cron']['args']).''; echo ''.acm_get_next_cron_execution($timestamp).''; echo ''; } } // Add task row $this->add_task_row($alternate); } public function add_task_row($alternate) { $alternate = ($alternate == '') ? 'alternate' : ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; ?>
+ .
'; } public function display_row_actions($cron, $interval, $args) { echo '
'; if ( in_array($cron, $this->protected_crons) ) { _e('Task protected', 'acm'); } else { // echo ''.__('Edit', 'acm').' | '; echo ''.__('Remove', 'acm').''; } echo '
'; } } ?>