class-page-dashboard.php
2 years ago
class-page-elementor-dashboard.php
2 years ago
class-page-gutenberg-dashboard.php
2 years ago
class-page-settings.php
2 years ago
class-page-support.php
2 years ago
class-page-settings.php
131 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SuperbAddons\Admin\Pages; |
| 4 | |
| 5 | defined('ABSPATH') || exit(); |
| 6 | |
| 7 | use SuperbAddons\Admin\Controllers\DashboardController; |
| 8 | use SuperbAddons\Admin\Controllers\SettingInputKey; |
| 9 | use SuperbAddons\Admin\Controllers\SettingsController; |
| 10 | use SuperbAddons\Components\Admin\InputCheckbox; |
| 11 | use SuperbAddons\Components\Admin\Modal; |
| 12 | use SuperbAddons\Components\Admin\PremiumBoxLarge; |
| 13 | use SuperbAddons\Data\Controllers\KeyController; |
| 14 | |
| 15 | use SuperbAddons\Components\Admin\ReviewBox; |
| 16 | use SuperbAddons\Components\Admin\SupportLinkBoxes; |
| 17 | use SuperbAddons\Data\Controllers\SettingsOptionKey; |
| 18 | |
| 19 | class SettingsPage |
| 20 | { |
| 21 | private $HasRegisteredKey = false; |
| 22 | private $KeyTypeLabel = false; |
| 23 | private $KeyStatus = false; |
| 24 | private $Settings = false; |
| 25 | |
| 26 | public function __construct() |
| 27 | { |
| 28 | $this->HasRegisteredKey = KeyController::HasRegisteredKey(); |
| 29 | if ($this->HasRegisteredKey) { |
| 30 | $this->KeyTypeLabel = KeyController::GetCurrentKeyTypeLabel(); |
| 31 | $this->KeyStatus = KeyController::GetKeyStatus(); |
| 32 | } |
| 33 | |
| 34 | $this->Settings = SettingsController::GetSettings(); |
| 35 | |
| 36 | $this->Render(); |
| 37 | } |
| 38 | |
| 39 | private function Render() |
| 40 | { |
| 41 | ?> |
| 42 | <div class="superbaddons-admindashboard-sidebarlayout"> |
| 43 | <div class="superbaddons-admindashboard-sidebarlayout-left"> |
| 44 | <?php |
| 45 | new PremiumBoxLarge(); |
| 46 | ?> |
| 47 | <div class="superbaddons-license-key-wrapper"> |
| 48 | <?php if ($this->HasRegisteredKey) : ?> |
| 49 | <div class="superbaddons-license-key-body"> |
| 50 | <?php $this->MaybeDisplayKeyIssue(); ?> |
| 51 | <p class="superbaddons-element-text-sm"><?= esc_html__('Current License: ', 'superbaddons'); ?><span class="superbaddons-element-text-md"><?= esc_html($this->KeyTypeLabel); ?></span></p> |
| 52 | <button id="spbaddons-license-remove-btn" class="superbaddons-element-button spbaddons-admin-btn-danger" type="button"><!-- JS Overwrites --><?= esc_html__('Remove License Key', 'superbaddons'); ?></button> |
| 53 | </div> |
| 54 | <?php else : ?> |
| 55 | <div class="superbaddons-license-key-body superbaddons-license-key-body-flex"> |
| 56 | <div class="superbaddons-license-key-input-wrapper"> |
| 57 | <img class="spbaddons-license-result-icon spbaddons-license-error" src="<?= SUPERBADDONS_ASSETS_PATH ?>/img/color-warning-octagon.svg" style="display:none;" /> |
| 58 | <input id="superbaddons-license-key-input" type="text" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" maxlength="23" /> |
| 59 | </div> |
| 60 | <button id="spbaddons-license-submit-btn" class="superbaddons-element-button" type="button" disabled><?= esc_html__('Add License Key', 'superbaddons'); ?></button> |
| 61 | </div> |
| 62 | <?php endif; ?> |
| 63 | <div class="superbaddons-spinner-wrapper" style="display:none;"> |
| 64 | <img class="spbaddons-spinner" src="<?= SUPERBADDONS_ASSETS_PATH ?>/img/blocks-spinner.svg" /> |
| 65 | </div> |
| 66 | </div> |
| 67 | <div class="superbaddons-additional-content-wrapper"> |
| 68 | <h4 class="superbaddons-element-text-sm superbaddons-element-text-dark superbaddons-element-text-800 superbaddons-element-m0"><?= esc_html__("Settings", "superbaddons"); ?></h4> |
| 69 | <p class="superbaddons-element-text-xs superbaddons-element-text-gray "><?= esc_html__("Manage your settings for Superb Addons.", "superbaddons"); ?></p> |
| 70 | |
| 71 | <h5 class="superbaddons-element-flex-center superbaddons-element-text-xs superbaddons-element-text-dark superbaddons-element-text-800 superbaddons-element-m0"><img class="superbaddons-admindashboard-content-icon superbaddons-element-mr1" src="<?= esc_url(SUPERBADDONS_ASSETS_PATH . '/img/purple-database.svg'); ?>" /><?= esc_html__("Cache", "superbaddons"); ?></h5> |
| 72 | <p class="superbaddons-element-text-xxs superbaddons-element-text-gray superbaddons-element-mb1"><?= esc_html__("Superb Addons caches data for faster loading and processing. Clearing the cache will force data and images to be refreshed and reloaded. If you are not experiencing any problems with the plugin, the cache should not be cleared.", "superbaddons"); ?></p> |
| 73 | <button type="button" class="superbaddons-element-button spbaddons-admin-btn-danger superbaddons-element-m0 superbaddons-element-mb1" id="superbaddons-clear-cache-btn"><img class="superbaddons-element-button-icon" src="<?= esc_url(SUPERBADDONS_ASSETS_PATH . '/img/trash-light.svg'); ?>" /><?= esc_html__("Clear Cache", "superbaddons"); ?></button> |
| 74 | <div class="superbaddons-element-separator"></div> |
| 75 | |
| 76 | <h5 class="superbaddons-element-flex-center superbaddons-element-text-xs superbaddons-element-text-dark superbaddons-element-text-800 superbaddons-element-mb1"><img class="superbaddons-admindashboard-content-icon superbaddons-element-mr1" src="<?= esc_url(SUPERBADDONS_ASSETS_PATH . '/img/purple-bug.svg'); ?>" /><?= esc_html__("Error Logs", "superbaddons"); ?></h5> |
| 77 | <?php new InputCheckbox(SettingInputKey::ENABLE_LOGS, __("Enable Error Logs", "superbaddons"), __("If issues or errors occur in the plugin when this setting is enabled, the error messages will be logged and can be viewed and shared with our support team and developers."), $this->Settings[SettingsOptionKey::LOGS_ENABLED]); ?> |
| 78 | <div class="superbaddons-maybe-hide-element" <?= $this->Settings[SettingsOptionKey::LOGS_ENABLED] ? '' : 'style="display:none;"'; ?>> |
| 79 | <?php new InputCheckbox(SettingInputKey::SHARE_LOGS, __("Share Error Logs", "superbaddons"), __("When this setting is enabled, error logs will be shared anonymously with our support team and developers to help improve the plugin. Only the error messages shown in the error logs will be shared."), $this->Settings[SettingsOptionKey::LOG_SHARE_ENABLED], '/img/cloud-arrow-up.svg'); ?> |
| 80 | </div> |
| 81 | <button type="button" class="superbaddons-element-button superbaddons-element-mr1" id="superbaddons-view-logs-btn"><img class="superbaddons-element-button-icon" src="<?= esc_url(SUPERBADDONS_ASSETS_PATH . '/img/list-magnifying-glass.svg'); ?>" /><?= esc_html__("View Logs", "superbaddons"); ?></button> |
| 82 | <button type="button" class="superbaddons-element-button spbaddons-admin-btn-danger" id="superbaddons-clear-logs-btn"><img class="superbaddons-element-button-icon" src="<?= esc_url(SUPERBADDONS_ASSETS_PATH . '/img/trash-light.svg'); ?>" /><?= esc_html__("Clear Logs", "superbaddons"); ?></button> |
| 83 | </div> |
| 84 | <div class="superbaddons-admindashboard-linkbox-wrapper"> |
| 85 | <?php new SupportLinkBoxes(); ?> |
| 86 | </div> |
| 87 | </div> |
| 88 | <div class="superbaddons-admindashboard-sidebarlayout-right"> |
| 89 | <?php new ReviewBox(); ?> |
| 90 | </div> |
| 91 | </div> |
| 92 | <?php new Modal(); ?> |
| 93 | <?php |
| 94 | } |
| 95 | |
| 96 | private function MaybeDisplayKeyIssue() |
| 97 | { |
| 98 | if (!$this->KeyStatus['expired'] && $this->KeyStatus['active'] && $this->KeyStatus['verified']) { |
| 99 | return; |
| 100 | } |
| 101 | ?> |
| 102 | <div class="spbaddons-license-issue-wrapper"> |
| 103 | <?php printf('<img src="%s" alt="%s"/>', esc_url(SUPERBADDONS_ASSETS_PATH . '/img/color-warning-octagon.svg'), esc_attr__("Issue Detected", "superbaddons")); ?> |
| 104 | <p> |
| 105 | <?php |
| 106 | if ( |
| 107 | $this->KeyStatus['expired'] |
| 108 | ) { |
| 109 | esc_html_e('It looks like your subscription has expired. Please renew your subscription or contact support for assistance.', 'superbaddons'); |
| 110 | } elseif ( |
| 111 | !$this->KeyStatus['active'] |
| 112 | ) { |
| 113 | esc_html_e('It looks like your license key has been disabled. Please contact support for assistance.', 'superbaddons'); |
| 114 | } elseif ( |
| 115 | !$this->KeyStatus['verified'] |
| 116 | ) { |
| 117 | esc_html_e('It seems that your license key verification for this website is no longer valid. Please click the button below to head to the support section and get started with the troubleshooting process.', 'superbaddons'); |
| 118 | } |
| 119 | ?> |
| 120 | </p> |
| 121 | <?php |
| 122 | if (!$this->KeyStatus['verified']) : ?> |
| 123 | <a href="<?= esc_url(admin_url('admin.php?page=' . DashboardController::SUPPORT)); ?>" class="superbaddons-element-button"> |
| 124 | <?= esc_html__("Go to Troubleshooting page"); ?> |
| 125 | </a> |
| 126 | <?php endif; ?> |
| 127 | </div> |
| 128 | <?php |
| 129 | } |
| 130 | } |
| 131 |