> $schedules Schedules. * @return array> */ public function cron_schedules( array $schedules ): array { if ( ! isset( $schedules[ self::INTERVAL_WEEKLY ] ) ) { $schedules[ self::INTERVAL_WEEKLY ] = array( 'interval' => WEEK_IN_SECONDS, 'display' => __( 'Once Weekly (007AJ Backup Restore Verifier)', '007aj-backup-restore-verifier' ), ); } return $schedules; } /** * (Re)schedule the full-backup event from current settings. */ public function reschedule(): void { $this->clear(); $interval = Settings::schedule_interval(); if ( Settings::INTERVAL_DISABLED === $interval ) { return; } if ( ! in_array( $interval, Settings::allowed_intervals(), true ) ) { $interval = 'daily'; } if ( ! wp_next_scheduled( self::HOOK_SCHEDULED_BACKUP ) ) { // Stagger a few minutes so activate + first visit don't pile on. wp_schedule_event( time() + ( 2 * MINUTE_IN_SECONDS ), $interval, self::HOOK_SCHEDULED_BACKUP ); } } /** * Clear scheduled backup event(s). */ public function clear(): void { wp_clear_scheduled_hook( self::HOOK_SCHEDULED_BACKUP ); } /** * Cron callback: queue a full backup when idle. */ public function run_scheduled_backup(): void { if ( is_multisite() ) { return; } $runner = new Job_Runner(); $queued = $runner->queue_backup( array( 'components' => array( 'database' => true, 'plugins' => true, 'themes' => true, 'uploads' => true, ), 'trigger' => 'schedule', ) ); if ( empty( $queued['ok'] ) ) { // Soft skip when another heavy job is active — next cadence retries. return; } $job_id = (int) $queued['job_id']; Logger::info( $job_id, 'Scheduled full backup queued.' ); // Advance one tick immediately so progress starts without waiting for resume cron. $runner->tick( $job_id ); } /** * Next scheduled timestamp (UTC unix) or 0. */ public function next_run(): int { $ts = wp_next_scheduled( self::HOOK_SCHEDULED_BACKUP ); return $ts ? (int) $ts : 0; } /** * Human-readable next run in site timezone, or “not scheduled”. */ public function next_run_label(): string { $ts = $this->next_run(); if ( $ts <= 0 ) { return __( 'Not scheduled', '007aj-backup-restore-verifier' ); } return wp_date( 'Y-m-d H:i:s T', $ts ); } }