Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?
add_action('wp', 'myplugin_schedule_cron');
add_action('myplugin_cronjob', 'myplugin_cron_function');
#add_action('wp_head', 'myplugin_cron_function'); //test
/*-------------------------------------------------------------
Name: myplugin_schedule_cron
Purpose: schedule cron on page load if not scheduled
Receive: - none -
Return: - none -
-------------------------------------------------------------*/
function myplugin_schedule_cron() {
if ( !wp_next_scheduled( 'myplugin_cronjob' ) )
wp_schedule_event(time(), 'daily', 'myplugin_cronjob');
}
/*-------------------------------------------------------------
Name: myplugin_cron_function
Purpose: function to run with cron
Receive: - none -
Return: - none -
-------------------------------------------------------------*/
function myplugin_cron_function() {
//do something
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.