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
165 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\SettingsController; |
| 9 | use SuperbAddons\Components\Admin\EnhancementSettingsComponent; |
| 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\CompatibilitySettingsOptionKey; |
| 18 | use SuperbAddons\Data\Controllers\SettingsOptionKey; |
| 19 | use SuperbAddons\Data\Utils\KeyType; |
| 20 | |
| 21 | class SettingsPage |
| 22 | { |
| 23 | private $HasRegisteredKey = false; |
| 24 | private $KeyTypeLabel = false; |
| 25 | private $KeyStatus = false; |
| 26 | private $Settings = false; |
| 27 | private $Incompatibilities = false; |
| 28 | private $CompatibilitySettings = false; |
| 29 | |
| 30 | public function __construct() |
| 31 | { |
| 32 | $this->HasRegisteredKey = KeyController::HasRegisteredKey(); |
| 33 | if ($this->HasRegisteredKey) { |
| 34 | $this->KeyTypeLabel = KeyController::GetCurrentKeyTypeLabel(); |
| 35 | $this->KeyStatus = KeyController::GetKeyStatus(); |
| 36 | } |
| 37 | |
| 38 | $this->Settings = SettingsController::GetSettings(); |
| 39 | |
| 40 | $this->Incompatibilities = SettingsController::GetRelevantCompatibilitySettings(); |
| 41 | if (count($this->Incompatibilities) > 0) { |
| 42 | $this->CompatibilitySettings = SettingsController::GetCompatibilitySettings(); |
| 43 | } |
| 44 | |
| 45 | $this->Render(); |
| 46 | } |
| 47 | |
| 48 | private function Render() |
| 49 | { |
| 50 | ?> |
| 51 | <div class="superbaddons-admindashboard-sidebarlayout"> |
| 52 | <div class="superbaddons-admindashboard-sidebarlayout-left"> |
| 53 | <?php |
| 54 | new PremiumBoxLarge(); |
| 55 | ?> |
| 56 | <div class="superbaddons-license-key-wrapper"> |
| 57 | <?php if ($this->HasRegisteredKey) : ?> |
| 58 | <div class="superbaddons-license-key-body"> |
| 59 | <?php $this->MaybeDisplayKeyIssue(); ?> |
| 60 | <p class="superbaddons-element-text-sm"><?= esc_html__('Current License: ', "superb-blocks"); ?><span class="superbaddons-element-text-md"><?= esc_html($this->KeyTypeLabel); ?></span></p> |
| 61 | <button id="spbaddons-license-remove-btn" class="superbaddons-element-button spbaddons-admin-btn-danger" type="button"><!-- JS Overwrites --><?= esc_html__('Remove License Key', "superb-blocks"); ?></button> |
| 62 | </div> |
| 63 | <?php else : ?> |
| 64 | <div class="superbaddons-license-key-body superbaddons-license-key-body-flex"> |
| 65 | <div class="superbaddons-license-key-input-wrapper"> |
| 66 | <img class="spbaddons-license-result-icon spbaddons-license-error" src="<?= SUPERBADDONS_ASSETS_PATH ?>/img/color-warning-octagon.svg" style="display:none;" /> |
| 67 | <input id="superbaddons-license-key-input" type="text" placeholder="XXXXX-XXXXX-XXXXX-XXXXX" maxlength="23" /> |
| 68 | </div> |
| 69 | <button id="spbaddons-license-submit-btn" class="superbaddons-element-button" type="button" disabled><?= esc_html__('Add License Key', "superb-blocks"); ?></button> |
| 70 | </div> |
| 71 | <?php endif; ?> |
| 72 | <div class="superbaddons-spinner-wrapper" style="display:none;"> |
| 73 | <img class="spbaddons-spinner" src="<?= SUPERBADDONS_ASSETS_PATH ?>/img/blocks-spinner.svg" /> |
| 74 | </div> |
| 75 | </div> |
| 76 | <div class="superbaddons-editor-settings-wrapper"> |
| 77 | <?php new EnhancementSettingsComponent(); ?> |
| 78 | </div> |
| 79 | <div class="superbaddons-additional-content-wrapper"> |
| 80 | <h4 class="superbaddons-element-text-sm superbaddons-element-text-dark superbaddons-element-text-800 superbaddons-element-m0"><?= esc_html__("Advanced Settings", "superb-blocks"); ?></h4> |
| 81 | <p class="superbaddons-element-text-xs superbaddons-element-text-gray "><?= esc_html__("Manage your advanced settings for Superb Addons.", "superb-blocks"); ?></p> |
| 82 | |
| 83 | <div class="superbaddons-cache-settings-wrapper"> |
| 84 | <!-- Cache Settings --> |
| 85 | <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", "superb-blocks"); ?></h5> |
| 86 | <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.", "superb-blocks"); ?></p> |
| 87 | <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", "superb-blocks"); ?></button> |
| 88 | </div> |
| 89 | <div class="superbaddons-element-separator"></div> |
| 90 | |
| 91 | <div class="superbaddons-error-logs-settings-wrapper"> |
| 92 | <!-- Error Logs Settings --> |
| 93 | <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", "superb-blocks"); ?></h5> |
| 94 | <?php new InputCheckbox('superbaddons-enable-logs-input', SettingsOptionKey::LOGS_ENABLED, __("Enable Error Logs", "superb-blocks"), __("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.", "superb-blocks"), $this->Settings[SettingsOptionKey::LOGS_ENABLED]); ?> |
| 95 | <div class="superbaddons-maybe-hide-element" <?= $this->Settings[SettingsOptionKey::LOGS_ENABLED] ? '' : 'style="display:none;"'; ?>> |
| 96 | <?php new InputCheckbox('superbaddons-share-logs-input', SettingsOptionKey::LOG_SHARE_ENABLED, __("Share Error Logs", "superb-blocks"), __("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.", "superb-blocks"), $this->Settings[SettingsOptionKey::LOG_SHARE_ENABLED], '/img/cloud-arrow-up.svg'); ?> |
| 97 | </div> |
| 98 | <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", "superb-blocks"); ?></button> |
| 99 | <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", "superb-blocks"); ?></button> |
| 100 | </div> |
| 101 | <div class="superbaddons-compatibility-settings-wrapper"> |
| 102 | <!-- Compatibility Settings --> |
| 103 | <?php if (count($this->Incompatibilities) > 0) : ?> |
| 104 | <div class="superbaddons-element-separator"></div> |
| 105 | <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-plugs.svg'); ?>" /><?= esc_html__("Compatibility", "superb-blocks"); ?></h5> |
| 106 | <?php if (isset($this->Incompatibilities[CompatibilitySettingsOptionKey::SPECTRA_BLOCK_SPACING])) : |
| 107 | new InputCheckbox('superbaddons-spectra-compat', CompatibilitySettingsOptionKey::SPECTRA_BLOCK_SPACING, __("Fix Block Spacing", "superb-blocks"), __("The Spectra plugin features an option to apply a fixed block spacing between all blocks while in the editor. Unfortunately this option overrides custom block spacing and can result in blocks and patterns appearing strange in the editor. When this setting is enabled, custom block spacing will appear correctly in the editor.", "superb-blocks"), $this->CompatibilitySettings[CompatibilitySettingsOptionKey::SPECTRA_BLOCK_SPACING]); |
| 108 | endif; ?> |
| 109 | <?php endif; ?> |
| 110 | </div> |
| 111 | </div> |
| 112 | <div class="superbaddons-admindashboard-linkbox-wrapper"> |
| 113 | <?php new SupportLinkBoxes(); ?> |
| 114 | </div> |
| 115 | </div> |
| 116 | <div class="superbaddons-admindashboard-sidebarlayout-right"> |
| 117 | <?php new ReviewBox(); ?> |
| 118 | </div> |
| 119 | </div> |
| 120 | <?php new Modal(); ?> |
| 121 | <?php |
| 122 | } |
| 123 | |
| 124 | private function MaybeDisplayKeyIssue() |
| 125 | { |
| 126 | if (!$this->KeyStatus['expired'] && $this->KeyStatus['active'] && $this->KeyStatus['verified'] && !$this->KeyStatus['exceeded']) { |
| 127 | return; |
| 128 | } |
| 129 | ?> |
| 130 | <div class="spbaddons-license-issue-wrapper"> |
| 131 | <?php printf('<img src="%s" alt="%s"/>', esc_url(SUPERBADDONS_ASSETS_PATH . '/img/color-warning-octagon.svg'), esc_attr__("Issue Detected", "superb-blocks")); ?> |
| 132 | <p> |
| 133 | <?php |
| 134 | if ($this->KeyStatus['expired'] && $this->KeyStatus['exceeded'] && $this->KeyStatus['type'] === KeyType::STANDARD) { |
| 135 | esc_html_e('It looks like your subscription has expired and your license key is active on too many domains. Please renew your subscription, deactivate your license key on some of your domains, or contact support for assistance.', "superb-blocks"); |
| 136 | } elseif ( |
| 137 | $this->KeyStatus['expired'] |
| 138 | ) { |
| 139 | esc_html_e('It looks like your subscription has expired. Please renew your subscription or contact support for assistance.', "superb-blocks"); |
| 140 | } elseif ( |
| 141 | !$this->KeyStatus['active'] |
| 142 | ) { |
| 143 | esc_html_e('It looks like your license key has been disabled. Please contact support for assistance.', "superb-blocks"); |
| 144 | } elseif ( |
| 145 | !$this->KeyStatus['verified'] |
| 146 | ) { |
| 147 | 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.', "superb-blocks"); |
| 148 | } elseif ( |
| 149 | $this->KeyStatus['exceeded'] |
| 150 | ) { |
| 151 | esc_html_e('It looks like your license key has been activated on too many domains. Please renew your subscription, deactivate your license key on some of your domains, or contact support for assistance.', "superb-blocks"); |
| 152 | } |
| 153 | ?> |
| 154 | </p> |
| 155 | <?php |
| 156 | if (!$this->KeyStatus['verified']) : ?> |
| 157 | <a href="<?= esc_url(admin_url('admin.php?page=' . DashboardController::SUPPORT)); ?>" class="superbaddons-element-button"> |
| 158 | <?= esc_html__("Go to Troubleshooting page"); ?> |
| 159 | </a> |
| 160 | <?php endif; ?> |
| 161 | </div> |
| 162 | <?php |
| 163 | } |
| 164 | } |
| 165 |