| @@ -1,44 +1,0 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace AcyMailing\WpInit; | |
| 4 | - | |
| 5 | -use AcyMailing\Controllers\ConfigurationController; | |
| 6 | -use AcyMailing\Helpers\CronHelper; | |
| 7 | - | |
| 8 | -class Cron | |
| 9 | -{ | |
| 10 | - public function __construct() | |
| 11 | - { | |
| 12 | - add_filter('cron_schedules', [$this, 'addCronIntervals'], 100); | |
| 13 | - add_action(ConfigurationController::CRON_TASK_NAME, [$this, 'triggerAutomatedTasks']); | |
| 14 | - } | |
| 15 | - | |
| 16 | - public function addCronIntervals(array $schedules): array | |
| 17 | - { | |
| 18 | - $schedules['every_minute'] = [ | |
| 19 | - 'interval' => 60, | |
| 20 | - 'display' => 'Every minute', | |
| 21 | - ]; | |
| 22 | - | |
| 23 | - return $schedules; | |
| 24 | - } | |
| 25 | - | |
| 26 | - public function triggerAutomatedTasks() | |
| 27 | - { | |
| 28 | - | |
| 29 | - if (!acym_level(ACYM_ESSENTIAL)) { | |
| 30 | - acym_deleteScheduledTask(['name' => ConfigurationController::CRON_TASK_NAME]); | |
| 31 | - | |
| 32 | - return; | |
| 33 | - } | |
| 34 | - | |
| 35 | - if (!acym_isLicenseValidWeekly() && (empty($_SERVER['HTTP_REFERER']) || strpos($_SERVER['HTTP_REFERER'], 'api.acymailing.com') === false)) { | |
| 36 | - acym_deleteScheduledTask(['name' => ConfigurationController::CRON_TASK_NAME]); | |
| 37 | - | |
| 38 | - return; | |
| 39 | - } | |
| 40 | - | |
| 41 | - $cronHelper = new CronHelper(); | |
| 42 | - $cronHelper->cron(); | |
| 43 | - } | |
| 44 | -} | |