-
-
Save viruthagiri/9079102 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| function my_additional_schedules($schedules) { | |
| // interval in seconds | |
| $schedules['every2min'] = array('interval' => 2*60, 'display' => 'Every two minutes'); | |
| return $schedules; | |
| } | |
| add_filter('cron_schedules', 'my_additional_schedules'); | |
| // schedule the wp_cron_testing | |
| if( !wp_next_scheduled( 'wp_cron_testing' ) ) { | |
| wp_schedule_event( time(), 'every2min', 'wp_cron_testing' ); | |
| } | |
| add_action( 'wp_cron_testing', 'the_wp_cron_test' ); | |
| function the_wp_cron_test() { | |
| //mail my email with some debug info | |
| $to = '[email protected]'; | |
| $subject = 'the_wp_cron_test'; | |
| $message = "Debug info below. \n\n"; | |
| foreach ($_SERVER as $name => $value){ | |
| $message .= "${name} : ${value} \n"; | |
| } | |
| wp_mail( $to, $subject, $message); | |
| } | |
| //to clear the cron event from the site use the bellow line of code | |
| //wp_clear_scheduled_hook('wp_cron_testing'); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment