class-content-box-large.php
10 months ago
class-enhancement-settings-component.php
10 months ago
class-feature-request-box.php
10 months ago
class-input-checkbox.php
10 months ago
class-link-box.php
10 months ago
class-modal-editor-previews.php
10 months ago
class-modal-feedback.php
10 months ago
class-modal.php
10 months ago
class-navigation.php
10 months ago
class-newsletter-form.php
10 months ago
class-outdated-browser-warning.php
10 months ago
class-premium-box-large.php
10 months ago
class-premium-box.php
10 months ago
class-premium-feature-list.php
10 months ago
class-review-box.php
10 months ago
class-support-box.php
10 months ago
class-support-link-boxes.php
10 months ago
class-navigation.php
96 lines
| 1 | <?php |
| 2 | |
| 3 | namespace SuperbAddons\Components\Admin; |
| 4 | |
| 5 | use SuperbAddons\Admin\Controllers\DashboardController; |
| 6 | use SuperbAddons\Admin\Utils\AdminLinkSource; |
| 7 | use SuperbAddons\Admin\Utils\AdminLinkUtil; |
| 8 | use SuperbAddons\Data\Controllers\KeyController; |
| 9 | |
| 10 | defined('ABSPATH') || exit(); |
| 11 | |
| 12 | class Navigation |
| 13 | { |
| 14 | private $pages; |
| 15 | private $active_page; |
| 16 | private $issue_detected = false; |
| 17 | private $has_premium = false; |
| 18 | private $hide_navigation_items = false; |
| 19 | private $subtitle = false; |
| 20 | |
| 21 | public function __construct($hide_navigation_items = false, $subtitle = false) |
| 22 | { |
| 23 | $HasRegisteredKey = KeyController::HasRegisteredKey(); |
| 24 | if ($HasRegisteredKey) { |
| 25 | $this->has_premium = KeyController::HasValidPremiumKey(); |
| 26 | $KeyStatus = KeyController::GetKeyStatus(); |
| 27 | if (!$KeyStatus['active'] || $KeyStatus['expired'] || !$KeyStatus['verified'] || $KeyStatus['exceeded']) { |
| 28 | $this->issue_detected = true; |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | $this->subtitle = $subtitle; |
| 33 | |
| 34 | if ($hide_navigation_items) { |
| 35 | $this->hide_navigation_items = true; |
| 36 | $this->pages = array(); |
| 37 | $this->Render(); |
| 38 | return; |
| 39 | } |
| 40 | |
| 41 | // No need to verify nonce here, as we are simply reading the value to determine the current page |
| 42 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 43 | $this->active_page = isset($_GET['page']) ? sanitize_text_field(wp_unslash($_GET['page'])) : DashboardController::DASHBOARD; |
| 44 | $pages = array_merge(array(DashboardController::MENU_SLUG => __("Dashboard", "superb-blocks")), apply_filters('superbaddons/admin/navigation/pages', array())); |
| 45 | $this->pages = array_merge($pages, array( |
| 46 | DashboardController::PAGE_WIZARD => __("Theme Designer", "superb-blocks"), |
| 47 | DashboardController::ADDITIONAL_CSS => __("Custom CSS", "superb-blocks"), |
| 48 | DashboardController::SETTINGS => __("Settings", "superb-blocks"), |
| 49 | DashboardController::SUPPORT => __("Support", "superb-blocks"), |
| 50 | )); |
| 51 | $this->Render(); |
| 52 | } |
| 53 | |
| 54 | private function Render() |
| 55 | { |
| 56 | ?> |
| 57 | <div class="superbaddons-admindashboard-navigation <?php echo $this->hide_navigation_items ? 'superbaddons-admindashboard-navigation-items-hidden' : ''; ?>"> |
| 58 | <div class="superbaddons-admindashboard-navigation-toplevel"> |
| 59 | <a href="<?php echo esc_url(admin_url('admin.php?page=' . DashboardController::MENU_SLUG)); ?>" class="superbaddons-admindashboard-navigation-logo-wrapper"> |
| 60 | <img src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/icon-superb.svg'); ?>" /> |
| 61 | <span class="superbaddons-element-text-md superbaddons-element-text-800 superbaddons-element-text-dark">Superb Addons</span> |
| 62 | </a> |
| 63 | <?php if ($this->subtitle) : ?> |
| 64 | <span class="superbthemes-module-purple-badge"><?php echo esc_html($this->subtitle); ?></span> |
| 65 | <?php endif; ?> |
| 66 | <div class="superbaddons-admindashboard-navigation-shortcuts"> |
| 67 | <?php if (!$this->has_premium) : ?> |
| 68 | <a class="superbaddons-admindashboard-navigation-shortcuts-item" target="_blank" href="<?php echo esc_url(AdminLinkUtil::GetLink(AdminLinkSource::NAVIGATION)); ?>" title="<?php echo esc_attr__("Get Premium", "superb-blocks"); ?>"><img src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/color-crown.svg'); ?>" alt="<?php echo esc_attr__("Get Premium", "superb-blocks"); ?>" /></a> |
| 69 | <?php endif; ?> |
| 70 | <a class="superbaddons-admindashboard-navigation-shortcuts-item" target="_blank" href="<?php echo esc_url(AdminLinkUtil::GetLink(AdminLinkSource::DEFAULT, array("url" => "https://superbthemes.com/contact/"))); ?>" title="<?php echo esc_attr__("Contact Support", "superb-blocks"); ?>"><img src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/help.svg'); ?>" alt="<?php echo esc_attr__("Contact Support", "superb-blocks"); ?>" /></a> |
| 71 | <a class="superbaddons-admindashboard-navigation-shortcuts-item" target="_blank" href="<?php echo esc_url(AdminLinkUtil::GetLink(AdminLinkSource::DEFAULT, array("url" => "https://superbthemes.com/documentation/"))); ?>" title="<?php echo esc_attr__("View Documentation", "superb-blocks"); ?>"><img src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/file.svg'); ?>" alt="<?php echo esc_attr__("View Documentation", "superb-blocks"); ?>" /></a> |
| 72 | <span class="superbaddons-admindashboard-navigation-shortcuts-item"> |
| 73 | <?php echo esc_html(SUPERBADDONS_VERSION); ?> |
| 74 | <?php if ($this->has_premium) : ?> |
| 75 | <img class="superbaddons-element-ml1" src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/purple-crown.svg'); ?>" alt="<?php echo esc_attr__("Premium License", "superb-blocks"); ?>" /> |
| 76 | <?php endif; ?> |
| 77 | </span> |
| 78 | </div> |
| 79 | </div> |
| 80 | <?php if (!$this->hide_navigation_items) : ?> |
| 81 | <div class="superbaddons-admindashboard-navigation-bottomlevel"> |
| 82 | <?php foreach ($this->pages as $pagekey => $pagetitle) : ?> |
| 83 | <a href="<?php echo esc_url(admin_url('admin.php?page=' . $pagekey)); ?>" class="superbaddons-admindashboard-navigation-bottomlevel-item <?php echo $pagekey == $this->active_page ? 'superbaddons-admindashboard-active' : ''; ?>"> |
| 84 | <?php echo esc_html($pagetitle); ?> |
| 85 | <?php if ($pagekey == DashboardController::SETTINGS && $this->issue_detected) : ?> |
| 86 | <img class="superbaddons-admindashboard-navigation-bottomlevel-item-issue-img" src="<?php echo esc_url(SUPERBADDONS_ASSETS_PATH . '/img/color-warning-octagon.svg'); ?>" alt="<?php echo esc_attr__("Issue Detected", "superb-blocks"); ?>" /> |
| 87 | <?php endif; ?> |
| 88 | </a> |
| 89 | <?php endforeach; ?> |
| 90 | </div> |
| 91 | <?php endif; ?> |
| 92 | </div> |
| 93 | <?php |
| 94 | } |
| 95 | } |
| 96 |