Last active
July 31, 2018 07:33
-
-
Save talentedaamer/dde325c69f836aef4d6be17612927fbc to your computer and use it in GitHub Desktop.
add custom weekly, monthly and 30 minutes cron time schedules via cron_schedules filter hook
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 | |
function wptc_add_intervals( $schedules ) { | |
// add a 'weekly' interval | |
if( ! isset( $schedules['weekly'] ) ) { | |
$schedules['weekly'] = array( | |
'interval' => 604800, // seconds in a week | |
'display' => __('Once Weekly') | |
); | |
} | |
// add a 'monthly' interval | |
if( ! isset( $schedules['monthly'] ) ) { | |
$schedules['monthly'] = array( | |
'interval' => 2635200, // seconds in a month | |
'display' => __('Once a month') | |
); | |
} | |
// add a '30min' interval | |
if( ! isset( $schedules['30min'] ) ) { | |
$schedules['30min'] = array( | |
'interval' => 1800, // seconds in 30 minutes or use 30*60 | |
'display' => __('Once Every 30 minutes') | |
); | |
} | |
return $schedules; | |
} | |
add_filter( 'cron_schedules', 'wptc_add_intervals' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment