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