tasks
2 weeks ago
bootstrap.php
2 weeks ago
class-abstract-task.php
2 weeks ago
class-task-manager.php
2 weeks ago
handler.php
2 weeks ago
bootstrap.php
42 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Background Task Bootstrap |
| 5 | * |
| 6 | * Loads the task infrastructure and registers every concrete task. |
| 7 | * This file is required from three call-sites in backup-backup.php: |
| 8 | * |
| 9 | * init hook → TaskManager::boot() (normal page loads) |
| 10 | * activation hook → TaskManager::on_activation() (plugin activated) |
| 11 | * deactivation hook → TaskManager::on_deactivation() (plugin deactivated) |
| 12 | * |
| 13 | * After requiring this file, call whichever lifecycle method is appropriate. |
| 14 | * The file itself performs no side-effects beyond loading and registering so |
| 15 | * it is safe to require_once from any call-site. |
| 16 | * |
| 17 | * ── Adding a new task ──────────────────────────────────────────────────────── |
| 18 | * |
| 19 | * 1. Create `includes/cron/tasks/YourTask.php` extending AbstractTask. |
| 20 | * 2. Add the two lines below (require_once + register call). |
| 21 | * 3. Done – no other file needs to change. |
| 22 | * |
| 23 | * ───────────────────────────────────────────────────────────────────────────── |
| 24 | */ |
| 25 | |
| 26 | // Exit on direct access |
| 27 | if (!defined('ABSPATH')) exit; |
| 28 | |
| 29 | // ── Infrastructure ──────────────────────────────────────────────────────────── |
| 30 | |
| 31 | require_once __DIR__ . '/class-abstract-task.php'; |
| 32 | require_once __DIR__ . '/class-task-manager.php'; |
| 33 | |
| 34 | // ── Task registration ───────────────────────────────────────────────────────── |
| 35 | |
| 36 | use BMI\Plugin\CRON\TaskManager; |
| 37 | use BMI\Plugin\CRON\Tasks\ScheduleKeepaliveTask; |
| 38 | |
| 39 | require_once __DIR__ . '/tasks/class-schedule-keepalive-task.php'; |
| 40 | |
| 41 | TaskManager::register(new ScheduleKeepaliveTask()); |
| 42 |