Created
May 6, 2014 14:59
-
-
Save sethrubenstein/2886866cffb7a84f3c16 to your computer and use it in GitHub Desktop.
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
<?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