-
Notifications
You must be signed in to change notification settings - Fork 4
Description
Problem
Flow scheduling is limited to 10 hardcoded intervals defined in SchedulerIntervals.php:
Every 5 Minutes, Hourly, Every 2 Hours, Every 4 Hours, Every 6 Hours,
Twice Daily, Daily, Every 3 Days, Weekly, Monthly
Users inevitably need an interval that doesn't exist (e.g., every 3 hours, every 8 hours, twice a week, weekdays only at 9am). Adding each one manually doesn't scale.
Proposal
Replace the dropdown of hardcoded intervals with cron expression support. One text input, infinite flexibility.
UI
Two modes in the scheduling selector:
- Simple mode (default) — Keep the existing presets as quick-select buttons for common intervals. These just populate the cron field.
- Advanced mode — Raw cron expression input with a human-readable preview ("Runs every 3 hours", "Runs at 9am on weekdays").
Backend
- Store
cron_expressioninscheduling_configinstead of/alongsideinterval - After each flow execution, compute next run from the cron expression
- Action Scheduler already supports arbitrary timestamps via
as_schedule_single_action()— no WordPress cron intervals needed - Backward compatible: existing
intervalvalues map to cron expressions (every_4_hours→0 */4 * * *)
Examples
| Want | Cron Expression |
|---|---|
| Every 3 hours | 0 */3 * * * |
| Every 90 minutes | */90 * * * * |
| Weekdays at 9am | 0 9 * * 1-5 |
| Twice a week (Mon/Thu) | 0 9 * * 1,4 |
| 1st and 15th of month | 0 0 1,15 * * |
| Every 4 hours during business hours | 0 9,13,17 * * * |
Libraries
PHP cron parsing: dragonmantank/cron-expression is the standard (used by Laravel). Single dependency, calculates next run date from expression.
Migration
Existing flows with interval: "every_4_hours" should auto-migrate to cron_expression: "0 */4 * * *" on plugin update. The interval field can remain for backward compat but cron_expression takes priority when present.
Files
inc/Engine/Filters/SchedulerIntervals.php— current hardcoded intervals (can become the "simple mode" presets)inc/Abilities/Flow/CreateFlowAbility.php— flow creation with schedulinginc/Abilities/Flow/FlowHelpers.php— interval resolution- Flow scheduling in Action Scheduler hooks
Impact
Removes a recurring friction point. Every time someone needs a new interval, it currently requires a code change and plugin update. Cron expressions solve this permanently.