Skip to content

Instantly share code, notes, and snippets.

@sercomi
Created March 30, 2012 07:32
Show Gist options
  • Save sercomi/2248792 to your computer and use it in GitHub Desktop.
Save sercomi/2248792 to your computer and use it in GitHub Desktop.
WP: Cron jobs
//Crear un nuevo temporizador
add_filter('cron_schedules', 'add_scheduled_interval');
// Anyade nuevos intervalos a wp_schedules
function add_scheduled_interval($schedules)
{
$schedules['minutes_1'] = array('interval'=>60, 'display'=>'Once 1 minutes');
$schedules['minutes_30'] = array('interval'=>30, 'display'=>'Once 30 minutes');
return $schedules;
}
//Programar WP_Cron para obtener XML de EP
if( !wp_next_scheduled( 'europapress_refresh' ) ) {
wp_schedule_event( time(), 'minutes_1', 'europapress_refresh' );
}
add_action( 'europapress_refresh', 'ep_read_xml' );
//Elimina todas las tareas programadas para el hook
//wp_clear_scheduled_hook( 'europapress_refresh' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment