| 1 |
<?php |
| 2 |
|
| 3 |
namespace AcyMailing\WpInit; |
| 4 |
|
| 5 |
class Cron |
| 6 |
{ |
| 7 |
public function __construct() |
| 8 |
{ |
| 9 |
$ctrl = acym_getVar('string', 'ctrl', ''); |
| 10 |
if (acym_level(ACYM_ESSENTIAL) && !acym_isNoTemplate() && $ctrl !== 'cron') { |
| 11 |
$this->callAcyCron(); |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
public function callAcyCron() |
| 16 |
{ |
| 17 |
$config = acym_config(); |
| 18 |
|
| 19 |
$activeCron = $config->get('active_cron', 0); |
| 20 |
if (empty($activeCron)) return; |
| 21 |
|
| 22 |
$queueType = $config->get('queue_type', 'manual'); |
| 23 |
$cronNext = $config->get('cron_next', 0); |
| 24 |
if (empty($cronNext) || $cronNext > time() || $queueType === 'manual') return; |
| 25 |
|
| 26 |
$cronFrequency = $config->get('cron_frequency', 0); |
| 27 |
$cronBatches = $config->get('queue_batch_auto', 1); |
| 28 |
|
| 29 |
if (empty($cronFrequency)) return; |
| 30 |
|
| 31 |
if (intval($cronFrequency) >= 900 && intval($cronBatches) < 2) return; |
| 32 |
|
| 33 |
$cronKey = ''; |
| 34 |
if (!empty($config->get('cron_security', 0)) && !empty($config->get('cron_key'))) { |
| 35 |
$cronKey = '&cronKey='.$config->get('cron_key'); |
| 36 |
} |
| 37 |
acym_asyncCurlCall([acym_frontendLink('cron&task=cron'.$cronKey)]); |
| 38 |
} |
| 39 |
} |
| 40 |
|