| @@ -1,0 +1,67 @@ | ||
| 1 | +<?php | |
| 2 | +defined('ABSPATH') || die('Restricted Access'); | |
| 3 | + | |
| 4 | +/** | |
| 5 | + * Return TRUE if the level is handled by the current application | |
| 6 | + * Return FALSE if the level is not enough | |
| 7 | + */ | |
| 8 | +function acym_level(int $neededLevel): bool | |
| 9 | +{ | |
| 10 | + $levels = [ | |
| 11 | + 'Starter' => ACYM_STARTER, | |
| 12 | + 'Essential' => ACYM_ESSENTIAL, | |
| 13 | + 'Enterprise' => ACYM_ENTERPRISE, | |
| 14 | + ]; | |
| 15 | + | |
| 16 | + $config = acym_config(); | |
| 17 | + $currentLevel = $config->get('level'); | |
| 18 | + | |
| 19 | + $expirationDate = $config->get('expirationdate', 'not-set'); | |
| 20 | + | |
| 21 | + if ($config->get('isTrial', 0) == 1 && ($expirationDate !== 'not-set' && $expirationDate < time())) { | |
| 22 | + $currentLevel = 'Starter'; | |
| 23 | + } | |
| 24 | + | |
| 25 | + $currentLevelNumber = $levels[$currentLevel] ?? 0; | |
| 26 | + | |
| 27 | + return $currentLevelNumber >= $neededLevel; | |
| 28 | +} | |
| 29 | + | |
| 30 | +function acym_upgradeTo(string $version, string $utmMedium): void | |
| 31 | +{ | |
| 32 | + $link = ACYM_ACYMAILING_WEBSITE.'pricing?utm_source=acymailing_plugin&utm_medium='.$utmMedium.'&utm_campaign=purchase'; | |
| 33 | + $text = $version === 'essential' ? 'AcyMailing Essential' : 'AcyMailing Enterprise'; | |
| 34 | + echo '<div class="acym__upgrade cell grid-x text-center align-center"> | |
| 35 | + <h2 class="acym__listing__empty__title cell">'.wp_kses( | |
| 36 | + acym_translationSprintf('ACYM_USE_THIS_FEATURE', '<span class="acym__color__blue">'.esc_html($text).'</span>'), | |
| 37 | + [ | |
| 38 | + 'span' => [ | |
| 39 | + 'class' => true, | |
| 40 | + ], | |
| 41 | + ] | |
| 42 | + ).'</h2> | |
| 43 | + <a target="_blank" href="'.esc_url($link).'" class="cell medium-6 large-shrink button acym__button__upgrade">'.esc_html( | |
| 44 | + acym_translation('ACYM_UPGRADE_NOW_SIMPLE') | |
| 45 | + ).'</a> | |
| 46 | + </div>'; | |
| 47 | +} | |
| 48 | + | |
| 49 | +function acym_existsAcyMailing59(): bool | |
| 50 | +{ | |
| 51 | + $allTables = acym_getTables(); | |
| 52 | + | |
| 53 | + if (!in_array(acym_getPrefix().'acymailing_config', $allTables)) { | |
| 54 | + return false; | |
| 55 | + } | |
| 56 | + | |
| 57 | + $version = acym_loadResult('SELECT `value` FROM #__acymailing_config WHERE `namekey` = "version"'); | |
| 58 | + | |
| 59 | + return version_compare($version, '5.9.0', '>='); | |
| 60 | +} | |
| 61 | + | |
| 62 | +function acym_displayButtonGetProVersion(string $class = 'cell shrink', string $text = 'ACYM_UPGRADE_NOW_SIMPLE'): void | |
| 63 | +{ | |
| 64 | + echo '<a href="'.esc_url(ACYM_ACYMAILING_WEBSITE.'pricing').'" | |
| 65 | + target="_blank" | |
| 66 | + class="button acym__button__upgrade '.esc_attr($class).'">'.esc_html(acym_translation($text)).'</a>'; | |
| 67 | +} | |