Skip to content

Commit 2d0a04c

Browse files
authored
Fix cron schedules not being found (#1)
1 parent 257e373 commit 2d0a04c

File tree

3 files changed

+21
-14
lines changed

3 files changed

+21
-14
lines changed

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
php-version: 8.2
1717

1818
- name: Install dependencies
19-
run: composer build:dev
19+
run: composer install
2020

2121
- name: Validate against coding standards
2222
run: composer lint

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"authors": [
44
{
55
"name": "Seb Kay",
6-
"email": "seb@fhoke.com"
6+
"email": "seb@sebkay.com"
77
}
88
],
99
"minimum-stability": "stable",

src/Helpers.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,47 @@ public static function wpCronIntervals(): array
99
return [
1010
[
1111
'slug' => 'five_minutes',
12-
'label' => \__('5 minutes', 'paris-tile-stone-profits-connector'),
12+
'label' => \__('5 minutes', 'wp-cronable'),
1313
'value' => 300,
1414
],
1515
[
1616
'slug' => 'ten_minutes',
17-
'label' => \__('10 minutes', 'paris-tile-stone-profits-connector'),
17+
'label' => \__('10 minutes', 'wp-cronable'),
1818
'value' => 600,
1919
],
2020
[
2121
'slug' => 'fifteen_minutes',
22-
'label' => \__('15 minutes', 'paris-tile-stone-profits-connector'),
22+
'label' => \__('15 minutes', 'wp-cronable'),
2323
'value' => 900,
2424
],
2525
[
2626
'slug' => 'twenty_minutes',
27-
'label' => \__('20 minutes', 'paris-tile-stone-profits-connector'),
27+
'label' => \__('20 minutes', 'wp-cronable'),
2828
'value' => 1200,
2929
],
3030
[
3131
'slug' => 'thirty_minutes',
32-
'label' => \__('30 minutes', 'paris-tile-stone-profits-connector'),
32+
'label' => \__('30 minutes', 'wp-cronable'),
3333
'value' => 1800,
3434
],
3535
[
3636
'slug' => 'forty_five_minutes',
37-
'label' => \__('45 minutes', 'paris-tile-stone-profits-connector'),
37+
'label' => \__('45 minutes', 'wp-cronable'),
3838
'value' => 2700,
3939
],
4040
[
4141
'slug' => 'one_hour',
42-
'label' => \__('1 hour', 'paris-tile-stone-profits-connector'),
42+
'label' => \__('1 hour', 'wp-cronable'),
4343
'value' => 3600,
4444
],
4545
[
4646
'slug' => 'four_hours',
47-
'label' => \__('4 hours', 'paris-tile-stone-profits-connector'),
47+
'label' => \__('4 hours', 'wp-cronable'),
4848
'value' => 14400,
4949
],
5050
[
5151
'slug' => 'daily',
52-
'label' => \__('1 day', 'paris-tile-stone-profits-connector'),
52+
'label' => \__('1 day', 'wp-cronable'),
5353
'value' => 86400,
5454
],
5555
];
@@ -63,9 +63,16 @@ public static function wpCronIntervals(): array
6363
*/
6464
public static function getCronScheduleByTime(int $time): ?array
6565
{
66-
return \collect(self::wpCronIntervals())
67-
->filter(function ($interval) use ($time) {
68-
return $interval['value'] == $time;
66+
return \collect(\wp_get_schedules())
67+
->filter(function ($schedule) use ($time) {
68+
return $schedule['interval'] == $time;
69+
})
70+
->map(function (array $schedule, string $key) {
71+
return [
72+
'label' => $schedule['display'],
73+
'slug' => $key,
74+
'value' => $schedule['interval'],
75+
];
6976
})
7077
->values()
7178
->first();

0 commit comments

Comments
 (0)