wp schedule 事件中的自定義重複間隔()

// this function add custom interval (5 minutes) to the $schedules  
function five_minutes_interval( $schedules ) {
      $schedules['five_minutes'] = array(
            'interval'  => 60 * 5,
            'display'   =>  '5 minutes';
    );
    return $schedules;
}

// add a custom interval filter
add_filter( 'cron_schedules', 'five_minutes_interval' );

// Schedules a hook
wp_schedule_event( time(), 'five_minutes', 'my_event' );