Skip to content

Commit

Permalink
add one hour cron schedule
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspercroome committed Apr 17, 2024
1 parent fd0a7af commit 3757452
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions client-mu-plugins/goodbids/src/classes/Auctions/Cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,31 @@ function ( array $schedules ): array {
}
);
}
private function add_one_hour_cron_schedule(): void {
add_filter(
'cron_schedules', // phpcs:ignore
function ( array $schedules ): array {
foreach ( $this->cron_intervals as $id => $props ) {
// If one is already set, confirm it matches our schedule.
if ( ! empty( $schedules[ $props['name'] ] ) ) {
if ( MINUTE_IN_SECONDS * 60 === $schedules[ $props['name'] ] ) {
continue;
}

$this->cron_intervals[ $id ]['name'] .= '_goodbids';
}

// Adds every hourly cron schedule.
$schedules[ $this->cron_intervals[ $id ]['name'] ] = [
'interval' => $this->cron_intervals[ $id ]['interval'],
'display' => $this->cron_intervals[ $id ]['display'],
];
}

return $schedules;
}
);
}

/**
* Schedule a cron job that runs every minute to trigger auctions to start.
Expand Down

0 comments on commit 3757452

Please sign in to comment.