Skip to content

Instantly share code, notes, and snippets.

@sethrubenstein
Created May 6, 2014 14:59
Show Gist options
  • Save sethrubenstein/2886866cffb7a84f3c16 to your computer and use it in GitHub Desktop.
Save sethrubenstein/2886866cffb7a84f3c16 to your computer and use it in GitHub Desktop.
<?php
/**
* On an early action hook, check if the hook is scheduled - if not, schedule it.
*/
function prefix_setup_schedule() {
if ( ! wp_next_scheduled( 'prefix_hourly_event' ) ) {
wp_schedule_event( time(), 'hourly', 'prefix_hourly_event');
}
}
add_action( 'wp', 'prefix_setup_schedule' );
/**
* On the scheduled action hook, run a function.
*/
function prefix_do_this_hourly() {
// do something every hour
}
add_action( 'prefix_hourly_event', 'prefix_do_this_hourly' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment