retesere20

cron-example-1

Jun 14th, 2019
87
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_filter( 'cron_schedules', function ( $schedules ) {
  2. $schedules['one_minute'] = [ 'interval' => 60, 'display' => esc_html__( 'Every Minute' )];
  3. return $schedules;
  4. });
  5.  
  6. add_action('init', function(){
  7. if ( ! wp_next_scheduled( $this->prefixed.'cron_hook1' ) ) {
  8. wp_schedule_event( time(), 'one_minute', $this->prefixed.'cron_hook1', $this->cron_params );
  9. }
  10. });
  11. add_action( $this->prefixed.'cron_hook1', [$this, 'cron_func'], 10, 1 );
RAW Paste Data