Created
March 30, 2012 07:32
-
-
Save sercomi/2248792 to your computer and use it in GitHub Desktop.
WP: Cron jobs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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