Last active
February 3, 2018 03:05
-
-
Save davidsword/a92239204229686a5b31cf13100054bc 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
<? | |
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