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