Skip to content

Commit

Permalink
Fix cron schedules not being found (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebKay authored Jun 18, 2024
1 parent 257e373 commit 2d0a04c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
php-version: 8.2

- name: Install dependencies
run: composer build:dev
run: composer install

- name: Validate against coding standards
run: composer lint
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"authors": [
{
"name": "Seb Kay",
"email": "seb@fhoke.com"
"email": "seb@sebkay.com"
}
],
"minimum-stability": "stable",
Expand Down
31 changes: 19 additions & 12 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,47 @@ public static function wpCronIntervals(): array
return [
[
'slug' => 'five_minutes',
'label' => \__('5 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('5 minutes', 'wp-cronable'),
'value' => 300,
],
[
'slug' => 'ten_minutes',
'label' => \__('10 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('10 minutes', 'wp-cronable'),
'value' => 600,
],
[
'slug' => 'fifteen_minutes',
'label' => \__('15 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('15 minutes', 'wp-cronable'),
'value' => 900,
],
[
'slug' => 'twenty_minutes',
'label' => \__('20 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('20 minutes', 'wp-cronable'),
'value' => 1200,
],
[
'slug' => 'thirty_minutes',
'label' => \__('30 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('30 minutes', 'wp-cronable'),
'value' => 1800,
],
[
'slug' => 'forty_five_minutes',
'label' => \__('45 minutes', 'paris-tile-stone-profits-connector'),
'label' => \__('45 minutes', 'wp-cronable'),
'value' => 2700,
],
[
'slug' => 'one_hour',
'label' => \__('1 hour', 'paris-tile-stone-profits-connector'),
'label' => \__('1 hour', 'wp-cronable'),
'value' => 3600,
],
[
'slug' => 'four_hours',
'label' => \__('4 hours', 'paris-tile-stone-profits-connector'),
'label' => \__('4 hours', 'wp-cronable'),
'value' => 14400,
],
[
'slug' => 'daily',
'label' => \__('1 day', 'paris-tile-stone-profits-connector'),
'label' => \__('1 day', 'wp-cronable'),
'value' => 86400,
],
];
Expand All @@ -63,9 +63,16 @@ public static function wpCronIntervals(): array
*/
public static function getCronScheduleByTime(int $time): ?array
{
return \collect(self::wpCronIntervals())
->filter(function ($interval) use ($time) {
return $interval['value'] == $time;
return \collect(\wp_get_schedules())
->filter(function ($schedule) use ($time) {
return $schedule['interval'] == $time;
})
->map(function (array $schedule, string $key) {
return [
'label' => $schedule['display'],
'slug' => $key,
'value' => $schedule['interval'],
];
})
->values()
->first();
Expand Down

0 comments on commit 2d0a04c

Please sign in to comment.