Created
June 2, 2020 14:44
-
-
Save maheshwaghmare/3101653fcd3cb5a5a7bc8ce24c2ab572 to your computer and use it in GitHub Desktop.
Add schedule event OR Cron event with wp_schedule_event(). See https://maheshwaghmare.com/doc/wordpress-cron/
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 | |
/** | |
* Add schedule event or Cron event with wp_schedule_event() | |
* | |
* @todo Change the `prefix_` and with your own unique prefix. | |
* | |
* @since 1.0.0 | |
* | |
* @return void | |
*/ | |
if( ! function_exists( 'prefix_add_scheduled_event' ) ) : | |
function prefix_add_scheduled_event() { | |
// Schedule the event if it is not scheduled. | |
if ( ! wp_next_scheduled( 'prefix_cron_hook' ) ) { | |
wp_schedule_event( time(), 'every_ten_minutes', 'prefix_cron_hook' ); | |
} | |
} | |
add_action( 'admin_init', 'prefix_add_scheduled_event' ); | |
endif; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment