__('Dashboard', 'zbridge'), 'cloudflare' => __('Cloudflare', 'zbridge'), 'recipes' => __('Recipes', 'zbridge'), 'tracking' => __('Event Tracking', 'zbridge'), 'consent' => __('Privacy & Consent', 'zbridge'), 'diagnostics' => __('Diagnostics', 'zbridge'), 'license' => $isProEdition ? __('License', 'zbridge') : __('Upgrade', 'zbridge'), ]; } /** * Normalizes a tab slug, mapping legacy routes to consolidated tabs. * * @param string $tabKey * @return string */ public function normalizeTab(string $tabKey): string { $aliases = [ 'setup' => 'cloudflare', 'tools' => 'diagnostics', ]; if (isset($aliases[$tabKey])) { $tabKey = $aliases[$tabKey]; } $tabs = $this->getTabs(); return array_key_exists($tabKey, $tabs) ? $tabKey : 'dashboard'; } /** * Returns contextual upgrade or license renewal message. * * @return string */ public function getProNotice(): string { $isProEdition = class_exists('\WPZaraz\Licensing\Updater') && class_exists('\WPZaraz\Licensing\LicenseManager'); if ($isProEdition) { if (\WPZaraz\Licensing\LicenseManager::isExpired()) { return '(License expired. Renew license to re-enable)'; } return '(Requires active license. Activate license to enable)'; } return '(Available in WP Zbridge Pro)'; } /** * Maps each tab key to a corresponding Dashicon class. * * @param string $tabKey * @return string */ public function getTabIcon(string $tabKey): string { $isProEdition = class_exists('\WPZaraz\Licensing\Updater') && class_exists('\WPZaraz\Licensing\LicenseManager'); $icons = [ 'dashboard' => 'dashicons-chart-bar', 'cloudflare' => 'dashicons-cloud', 'recipes' => 'dashicons-rest-api', 'tracking' => 'dashicons-visibility', 'consent' => 'dashicons-shield', 'diagnostics' => 'dashicons-admin-tools', 'license' => $isProEdition ? 'dashicons-lock' : 'dashicons-star-filled', ]; return $icons[$tabKey] ?? 'dashicons-admin-generic'; } /** * Renders the entire admin page HTML. */ public function render(): void { $tabs = $this->getTabs(); // phpcs:ignore WordPress.Security.NonceVerification.Recommended $rawTab = isset($_GET['tab']) ? sanitize_key(wp_unslash($_GET['tab'])) : 'dashboard'; $currentTab = $this->normalizeTab($rawTab); $isPro = class_exists('\WPZaraz\Licensing\LicenseManager') && LicenseManager::isPro(); ?>

v

·

render(); ?>

render(); ?>

render(); ?>

render(); ?>

render(); ?>

render(); ?>