PluginProbe
Search Atlas SEO – OTTO AI SEO Automation for WordPress / 2.7.2
Search Atlas SEO – OTTO AI SEO Automation for WordPress v2.7.2
2.7.1 2.7.2 2.7.0 2.6.26 2.6.25 2.6.24 2.6.23 2.6.22 2.6.21 2.6.20 2.6.19 2.6.18 2.6.17 2.6.16 2.6.15 2.6.14 2.6.13 2.6.12 2.6.11 2.6.10 2.6.9 2.6.8 2.6.7 2.6.6 2.6.5 All 141 releases
← All changes | includes/class-metasync-admin-navigation.php +277 -142 2.6.11 → 2.7.2 View file →
@@ -20,8 +20,107 @@
20 20
21 21 const CACHE_KEY = 'metasync_admin_bar_status';
22 22
23 23 /**
24 + * Menu item keys that retain a WordPress admin sidebar row in short mode.
25 + *
26 + * Everything else is registered with an empty parent slug
27 + * (add_submenu_page('', ...)) so the page stays reachable at its
28 + * existing URL but does not claim a sidebar row. The in-page sidebar
29 + * (render_sidenav) continues to show every item.
30 + */
31 + const WP_MENU_KEEP_LIST = [
32 + 'dashboard', // Dashboard
33 + 'seo_controls', // Indexation Control
34 + 'redirections', // Redirections
35 + 'monitor_404', // 404 Monitor
36 + 'xml_sitemap', // XML Sitemap
37 + 'robots_txt', // Robots.txt
38 + 'schema_markup', // Schema Markup
39 + 'seo_health', // SEO Health
40 + 'general', // Settings
41 + ];
42 +
43 + /**
44 + * Whether the Settings page (general) is reachable for the current user.
45 + *
46 + * Settings is the floor — the top-level "Search Atlas" menu item is
47 + * registered with the Settings callback, so it must always point at a
48 + * page the user is permitted to see. When Settings is hidden by access
49 + * control, the top-level callback falls back to the first reachable
50 + * keep-list page (see resolve_top_level_callback()).
51 + *
52 + * @return bool
53 + */
54 + public static function is_settings_reachable()
55 + {
56 + return Metasync_Access_Control::user_can_access('hide_settings');
57 + }
58 +
59 + /**
60 + * Resolve the callback the top-level menu item should use.
61 + *
62 + * The top-level "Search Atlas" menu item is the floor — the plugin must
63 + * always present at least one working entry point. When Settings is
64 + * reachable it is the floor (its callback also renders the Settings
65 + * page). When Settings is hidden, fall back to the first reachable
66 + * keep-list page callback so the parent never leads to a permission
67 + * error or blank page.
68 + *
69 + * @param Metasync_Admin $admin The admin instance whose callbacks are used.
70 + * @return array WordPress-style callback array ([$admin, 'method']).
71 + */
72 + public static function resolve_top_level_callback($admin)
73 + {
74 + if (self::is_settings_reachable()) {
75 + return array($admin, 'create_admin_settings_page');
76 + }
77 +
78 + // Fall back to the first reachable keep-list item callback. The
79 + // keep-list is ordered by priority (Dashboard, Indexation Control,
80 + // Redirections, 404 Monitor, XML Sitemap, Robots.txt, SEO Health,
81 + // Settings). We reuse get_available_menu_items() so access-control
82 + // and connection-state gates are respected identically to the
83 + // sidebar.
84 + $available = self::instance()->get_available_menu_items();
85 + foreach (self::WP_MENU_KEEP_LIST as $key) {
86 + if (isset($available[$key])) {
87 + return array($admin, $available[$key]['callback']);
88 + }
89 + }
90 +
91 + // No keep-list item is reachable — keep Settings as the last resort
92 + // so the menu never leads to a blank page. Settings itself handles
93 + // its own access-control rendering.
94 + return array($admin, 'create_admin_settings_page');
95 + }
96 +
97 + /**
98 + * The ordered keep-list of menu item keys that always retain a
99 + * WordPress admin sidebar row (in short mode).
100 + *
101 + * @return string[]
102 + */
103 + public static function get_wp_menu_keep_list()
104 + {
105 + return self::WP_MENU_KEEP_LIST;
106 + }
107 +
108 + /**
109 + * Whether a given menu item key retains a WordPress admin sidebar row.
110 + *
111 + * Only keep-list items retain a WordPress sidebar row. All other pages
112 + * remain registered and available from the in-page navigation.
113 + *
114 + * @param string $item_key Menu item key from get_available_menu_items().
115 + * @return bool
116 + */
117 + public static function item_keeps_wp_sidebar_row($item_key)
118 + {
119 + return in_array($item_key, self::WP_MENU_KEEP_LIST, true);
120 + }
121 +
122 + /**
24 123 * Get singleton instance.
25 124 *
26 125 * @return self
27 126 */
@@ -34,8 +133,24 @@
34 133 }
35 134
36 135 private function __construct() {}
37 136
137 + /**
138 + * Whether the Dashboard is hidden by the "Hide Dashboard" general setting
139 + * (hide_dashboard_framework).
140 + *
141 + * When enabled this removes the Dashboard from the WordPress admin submenu
142 + * and from the in-plugin SEO feature navigation, matching the setting's
143 + * description "Hide the main dashboard from the WordPress admin menu".
144 + *
145 + * @return bool
146 + */
147 + public static function is_dashboard_hidden_by_framework()
148 + {
149 + $general_options = Metasync::get_option('general') ?? [];
150 + return filter_var($general_options['hide_dashboard_framework'] ?? false, FILTER_VALIDATE_BOOLEAN);
151 + }
152 +
38 153 // ------------------------------------------------------------------
39 154 // Logo resolution helper
40 155 // ------------------------------------------------------------------
41 156
@@ -75,9 +190,9 @@
75 190 $data['show_logo'] = true;
76 191 $data['url'] = $single;
77 192 } elseif (!$is_whitelabel) {
78 193 $data['show_logo'] = true;
79 - $data['url'] = Metasync::HOMEPAGE_DOMAIN . '/wp-content/uploads/2023/12/white.svg';
194 + $data['url'] = plugin_dir_url(dirname(__FILE__)) . 'assets/images/searchatlas-logo.svg';
80 195 $data['is_default'] = true;
81 196 }
82 197 }
83 198
@@ -107,10 +222,11 @@
107 222 $logo = $this->resolve_logo_data();
108 223
109 224 $current_theme = get_option('metasync_theme', 'dark');
110 225 $general_settings = Metasync::get_option('general');
111 - $searchatlas_api_key = isset($general_settings['searchatlas_api_key']) ? $general_settings['searchatlas_api_key'] : '';
112 - $is_integrated = !empty($searchatlas_api_key);
226 + // derive the badge from confirmed heartbeat health, not from
227 + // mere API-key presence (which stays set after Search Atlas revokes it).
228 + $badge = Metasync_Heartbeat_Manager::instance()->get_connection_badge($general_settings);
113 229 ?>
114 230 <div class="metasync-header" data-current-theme="<?php echo esc_attr($current_theme); ?>">
115 231 <div class="metasync-header-left">
116 232 <?php if ($logo['show_logo'] && $logo['use_dual']): ?>
@@ -124,11 +240,11 @@
124 240 </div>
125 241 <?php endif; ?>
126 242 </div>
127 243 <div class="metasync-header-right">
128 - <div class="metasync-status <?php echo $is_integrated ? 'connected' : 'disconnected'; ?>">
244 + <div class="metasync-status <?php echo esc_attr($badge['class']); ?>">
129 245 <span class="status-dot"></span>
130 - <span class="status-text"><?php echo $is_integrated ? 'Connected' : 'Not Connected'; ?></span>
246 + <span class="status-text"><?php echo esc_html($badge['text']); ?></span>
131 247 </div>
132 248 <button type="button" class="metasync-theme-toggle" onclick="toggleMetasyncTheme()" title="Toggle theme">
133 249 <span class="theme-icon-light">&#9728;</span>
134 250 <span class="theme-icon-dark">&#9790;</span>
@@ -150,9 +266,8 @@
150 266 $menu_items = [];
151 267 $menu_icons = [
152 268 'dashboard' => 'dashboard',
153 269 'seo_controls' => 'search',
154 - 'optimal_settings' => 'superhero-alt',
155 270 'instant_index' => 'performance',
156 271 'google_console' => 'chart-area',
157 272 'compatibility' => 'admin-tools',
158 273 'sync_log' => 'list-view',
@@ -163,9 +278,9 @@
163 278 'report_issue' => 'sos',
164 279 'general' => 'admin-settings',
165 280 ];
166 281
167 - if (empty($whitelabel_settings['hide_dashboard'])) {
282 + if (empty($whitelabel_settings['hide_dashboard']) && !self::is_dashboard_hidden_by_framework()) {
168 283 $menu_items['dashboard'] = ['title' => 'Dashboard', 'slug_suffix' => '-dashboard'];
169 284 }
170 285
171 286 if (empty($whitelabel_settings['hide_indexation_control'])) {
@@ -170,17 +285,9 @@
170 285
171 286 if (empty($whitelabel_settings['hide_indexation_control'])) {
172 287 $menu_items['seo_controls'] = ['title' => 'Indexation Control', 'slug_suffix' => '-seo-controls'];
173 288 }
174 -
175 - if ($general_options['enable_optimal_settings'] ?? false) {
176 - $menu_items['optimal_settings'] = ['title' => 'Optimal Settings', 'slug_suffix' => '-optimal-settings'];
177 - }
178 -
179 - if ($general_options['enable_googleinstantindex'] ?? false) {
180 - $menu_items['instant_index'] = ['title' => 'Instant Indexing', 'slug_suffix' => '-instant-index'];
181 - }
182 -
289 +
183 290 if ($general_options['enable_google_console'] ?? false) {
184 291 $menu_items['google_console'] = ['title' => 'Google Console', 'slug_suffix' => '-google-console'];
185 292 }
186 293
@@ -206,9 +313,9 @@
206 313 <div class="metasync-nav-tabs">
207 314 <div class="metasync-nav-left">
208 315 <?php foreach ($menu_items as $key => $menu_item):
209 316 $is_active = ($current_page === $key);
210 - $icon = $menu_icons[$key] ?? 'admin-generic';
317 + $icon = $menu_icons[$key];
211 318 $page_url = '?page=' . $page_slug . $menu_item['slug_suffix'];
212 319 ?>
213 320 <a href="<?php echo esc_url($page_url); ?>" class="metasync-nav-tab <?php echo $is_active ? 'active' : ''; ?>">
214 321 <span class="tab-icon"><span class="dashicons dashicons-<?php echo esc_attr($icon); ?>"></span></span>
@@ -373,10 +480,10 @@
373 480 $menu_items = [];
374 481
375 482 // === SEO FEATURES GROUP ===
376 483
377 - // Dashboard (check access control)
378 - if (Metasync_Access_Control::user_can_access('hide_dashboard')) {
484 + // Dashboard (check access control + "Hide Dashboard" general setting)
485 + if (Metasync_Access_Control::user_can_access('hide_dashboard') && !self::is_dashboard_hidden_by_framework()) {
379 486 $menu_items['dashboard'] = [
380 487 'title' => 'Dashboard',
381 488 'slug_suffix' => '-dashboard',
382 489 'callback' => 'create_admin_dashboard_iframe',
@@ -395,20 +502,8 @@
395 502 'group' => 'seo'
396 503 ];
397 504 }
398 505
399 - // Instant Indexing - setting now stored in seo_controls (moved from Settings to Indexation Control)
400 - $seo_controls = Metasync::get_option('seo_controls');
401 - if ($seo_controls['enable_googleinstantindex'] ?? false) {
402 - $menu_items['instant_index'] = [
403 - 'title' => 'Instant Indexing',
404 - 'slug_suffix' => '-instant-index',
405 - 'callback' => 'create_admin_google_instant_index_page',
406 - 'internal_nav' => 'Instant Indexing',
407 - 'group' => 'seo'
408 - ];
409 - }
410 -
411 506 if ($general_options['enable_google_console'] ?? false) {
412 507 $menu_items['google_console'] = [
413 508 'title' => 'Google Console',
414 509 'slug_suffix' => '-google-console',
@@ -576,18 +671,8 @@
576 671 'group' => 'plugin'
577 672 ];
578 673 }
579 674
580 - if ($general_options['enable_optimal_settings'] ?? false) {
581 - $menu_items['optimal_settings'] = [
582 - 'title' => 'Optimal Settings',
583 - 'slug_suffix' => '-optimal-settings',
584 - 'callback' => 'create_admin_optimal_settings_page',
585 - 'internal_nav' => 'Optimal Settings',
586 - 'group' => 'plugin'
587 - ];
588 - }
589 -
590 675 // Compatibility page (check access control)
591 676 if (Metasync_Access_Control::user_can_access('hide_compatibility')) {
592 677 $menu_items['compatibility'] = [
593 678 'title' => 'Compatibility',
@@ -646,9 +731,11 @@
646 731 $data = Metasync::get_option('general');
647 732 $plugin_name = Metasync::get_effective_plugin_name();
648 733 $menu_name = $plugin_name;
649 734 $menu_title = $plugin_name;
650 - $menu_slug = !isset($data['white_label_plugin_menu_slug']) || $data['white_label_plugin_menu_slug'] == "" ? Metasync_Admin::$page_slug : $data['white_label_plugin_menu_slug'];
735 + // Sanitize so a URL-shaped legacy value still yields a valid WP menu slug
736 + $menu_slug = !isset($data['white_label_plugin_menu_slug']) || $data['white_label_plugin_menu_slug'] == "" ? Metasync_Admin::$page_slug : sanitize_title($data['white_label_plugin_menu_slug']);
737 + $menu_slug = $menu_slug === '' ? Metasync_Admin::$page_slug : $menu_slug;
651 738 $menu_icon = !isset($data['white_label_plugin_menu_icon']) || $data['white_label_plugin_menu_icon'] == "" ? 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzQiIHZpZXdCb3g9IjAgMCAzMiAzNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGcgY2xpcC1wYXRoPSJ1cmwoI2NsaXAwXzE4NzlfMTcyNzcpIj4KPHBhdGggZD0iTTI5LjAyMTUgMi4xNjc2NkwzMC4wMTAxIDIuMTIyNDFMMjkuMTYyNyA4LjcyNzA1TDI5LjExNTcgOC44MTc0M0w1LjI5NTA0IDMzLjI0NTJMNC43MzAxMiAzMy4yOTA1TDQuMDcxMDQgMzMuOTY5MUgxLjk1MjYyTDIuMjM1MDggMzIuMjk1M0wyLjA5Mzg0IDMyLjM0MDZMMi4xODggMzEuNjYySDEuNjIzMDhDMS41NzYgMzEuNjYyIDEuNDgxODUg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UgNi4zMTUxNFpNNS4zMjA0NyA2LjA5MDM5TDUuNjg3NSA0LjQ0OThINS40NTgxMkM1LjQzNTE3IDQuNDQ5OCA1LjQxMjI0IDQuNDcyMjggNS4zODkyOSA0LjQ5NDc1QzUuMzQzNDIgNC41MTcyMyA1LjM0MzQyIDQuNTYyMTggNS4zMjA0NyA0LjU4NDY0TDQuOTk5MzMgNi4wOTAzOUg1LjMyMDQ3Wk0xNy41OTI5IDMuOTc3ODZDMTcuNjg0NyAzLjQzODQ5IDE3LjYzODcgMi45NDQwNyAxNy40NTUyIDIuNDk0NTlDMTcuNDU1MiAyLjQ3MjExIDE3LjQwOTQgMi40NDk2NSAxNy40MDk0IDIuNDA0NjhDMTcuNDc4MyAyLjc2NDI3IDE3LjUwMTEgMy4xNDYzNCAxNy40MzIzIDMuNTUwODVMMTcuMjAzIDQuODk5MjhIMTcuMTM0MUwxNy4wODgzIDUuMTY4OTdIMTcuNDA5NEwxNy41OTI5IDMuOTc3ODZaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzE4NzlfMTcyNzciPgo8cmVjdCB3aWR0aD0iMzEuNzQ0OSIgaGVpZ2h0PSIzNCIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K' : $data['white_label_plugin_menu_icon'];
652 739
653 740 // Use 'read' capability since actual access is controlled by current_user_has_plugin_access() check above
654 741 $menu_capability = 'read';
@@ -658,15 +745,19 @@
658 745 global $menu;
659 746 $menu['100'] = array('', 'read', 'separator-metasync-before', '', 'wp-menu-separator');
660 747 }, 5);
661 748
662 - // Main menu page at position 100.1 — bottom of the menu after all standard items
749 + // Main menu page at position 100.1 — bottom of the menu after all standard items.
750 + // The top-level callback is the floor: when Settings is reachable it renders
751 + // Settings; when Settings is hidden it falls back to the first reachable
752 + // keep-list page so the menu never leads to a blank page.
753 + $top_level_callback = self::resolve_top_level_callback($admin);
663 754 add_menu_page(
664 755 $menu_name,
665 756 $menu_title,
666 757 $menu_capability,
667 758 $menu_slug,
668 - array($admin, 'create_admin_settings_page'),
759 + $top_level_callback,
669 760 $menu_icon,
670 761 '100.1'
671 762 );
672 763
@@ -680,122 +771,157 @@
680 771
681 772 // ── Connect slug ──────────────────────────────────────────────────
682 773 $connect_slug = $menu_slug . '-connect';
683 774
684 - // Dashboard
685 - if (Metasync_Access_Control::user_can_access('hide_dashboard')) {
686 - add_submenu_page($menu_slug, 'Dashboard', 'Dashboard', $menu_capability, $menu_slug . '-dashboard', array($admin, 'create_admin_dashboard_iframe'));
775 + // Keep a slug-to-title map so hidden pages can still provide WordPress
776 + // with a browser-tab title when they are registered without a parent.
777 + $admin_page_titles = array();
778 +
779 + // Local helper: register a submenu page under the plugin parent slug
780 + // when the item keeps its WordPress admin sidebar row, or under an
781 + // empty parent slug (hidden from the sidebar but still reachable)
782 + // otherwise. The Settings page (general) is registered against the
783 + // bare $menu_slug so it doubles as the parent menu callback.
784 + $register_submenu = function($item_key, $page_title, $menu_title, $capability, $menu_page_slug, $callback) use ($menu_slug, &$admin_page_titles) {
785 + $admin_page_titles[$menu_page_slug] = $page_title;
786 + $parent = self::item_keeps_wp_sidebar_row($item_key) ? $menu_slug : '';
787 + add_submenu_page($parent, $page_title, $menu_title, $capability, $menu_page_slug, $callback);
788 + };
789 +
790 + // Dashboard (check access control + "Hide Dashboard" general setting)
791 + if (Metasync_Access_Control::user_can_access('hide_dashboard') && !self::is_dashboard_hidden_by_framework()) {
792 + $register_submenu('dashboard', 'Dashboard', 'Dashboard', $menu_capability, $menu_slug . '-dashboard', array($admin, 'create_admin_dashboard_iframe'));
687 793 }
688 794
689 795 // Indexation Control
690 796 if (Metasync_Access_Control::user_can_access('hide_indexation_control')) {
691 - add_submenu_page($menu_slug, 'Indexation Control', 'Indexation Control', $menu_capability, $menu_slug . '-seo-controls', array($admin, 'create_admin_seo_controls_page'));
797 + $register_submenu('seo_controls', 'Indexation Control', 'Indexation Control', $menu_capability, $menu_slug . '-seo-controls', array($admin, 'create_admin_seo_controls_page'));
692 798 }
693 799
694 800 // 404 Monitor
695 - add_submenu_page($menu_slug, '404 Monitor', '404 Monitor', $menu_capability, $menu_slug . '-404-monitor', array($admin, 'create_admin_404_monitor_page'));
801 + $register_submenu('monitor_404', '404 Monitor', '404 Monitor', $menu_capability, $menu_slug . '-404-monitor', array($admin, 'create_admin_404_monitor_page'));
696 802
697 803 // Redirections
698 804 if (Metasync_Access_Control::user_can_access('hide_redirections')) {
699 - add_submenu_page($menu_slug, 'Redirections', 'Redirections', $menu_capability, $menu_slug . '-redirections', array($admin, 'create_admin_redirections_page'));
805 + $register_submenu('redirections', 'Redirections', 'Redirections', $menu_capability, $menu_slug . '-redirections', array($admin, 'create_admin_redirections_page'));
700 806 }
701 807
702 808 // XML Sitemap
703 809 if (Metasync_Access_Control::user_can_access('hide_xml_sitemap')) {
704 - add_submenu_page($menu_slug, 'XML Sitemap', 'XML Sitemap', $menu_capability, $menu_slug . '-xml-sitemap', array($admin, 'create_admin_xml_sitemap_page'));
810 + $register_submenu('xml_sitemap', 'XML Sitemap', 'XML Sitemap', $menu_capability, $menu_slug . '-xml-sitemap', array($admin, 'create_admin_xml_sitemap_page'));
705 811 }
706 812
707 813 // Robots.txt
708 814 if (Metasync_Access_Control::user_can_access('hide_robots')) {
709 - add_submenu_page($menu_slug, 'Robots.txt', 'Robots.txt', $menu_capability, $menu_slug . '-robots-txt', array($admin, 'create_admin_robots_txt_page'));
815 + $register_submenu('robots_txt', 'Robots.txt', 'Robots.txt', $menu_capability, $menu_slug . '-robots-txt', array($admin, 'create_admin_robots_txt_page'));
710 816 }
711 817
712 - // Site Verification
713 - add_submenu_page($menu_slug, 'Site Verification', 'Site Verification', $menu_capability, $menu_slug . '-search-engine-verify', array($admin, 'create_admin_search_engine_verification_page'));
818 + // Site Verification (in-page sidebar only in short mode)
819 + $register_submenu('site_verification', 'Site Verification', 'Site Verification', $menu_capability, $menu_slug . '-search-engine-verify', array($admin, 'create_admin_search_engine_verification_page'));
714 820
715 - // Instant Indexing (conditional)
716 - if ($seo_controls['enable_googleinstantindex'] ?? false) {
717 - add_submenu_page($menu_slug, 'Instant Indexing', 'Instant Indexing', $menu_capability, $menu_slug . '-instant-index', array($admin, 'create_admin_google_instant_index_page'));
718 - }
719 -
720 821 // Google Console (conditional)
721 822 if ($general_options['enable_google_console'] ?? false) {
722 - add_submenu_page($menu_slug, 'Google Console', 'Google Console', $menu_capability, $menu_slug . '-google-console', array($admin, 'create_admin_google_console_page'));
823 + $register_submenu('google_console', 'Google Console', 'Google Console', $menu_capability, $menu_slug . '-google-console', array($admin, 'create_admin_google_console_page'));
723 824 }
724 825
725 826 // Bing Console (conditional)
726 827 if ($seo_controls['enable_binginstantindex'] ?? false) {
727 - add_submenu_page($menu_slug, 'Bing Console', 'Bing Console', $menu_capability, $menu_slug . '-bing-console', array($admin, 'create_admin_bing_console_page'));
828 + $register_submenu('bing_console', 'Bing Console', 'Bing Console', $menu_capability, $menu_slug . '-bing-console', array($admin, 'create_admin_bing_console_page'));
728 829 }
729 830
730 831 // Schema Markup
731 - add_submenu_page($menu_slug, 'Schema Markup', 'Schema Markup', $menu_capability, $menu_slug . '-schema-markup', array($admin, 'create_admin_schema_markup_page'));
832 + $register_submenu('schema_markup', 'Schema Markup', 'Schema Markup', $menu_capability, $menu_slug . '-schema-markup', array($admin, 'create_admin_schema_markup_page'));
732 833
733 834 // Import SEO Data
734 835 if (Metasync_Access_Control::user_can_access('hide_import_seo')) {
735 - add_submenu_page($menu_slug, 'Import SEO Data', 'Import SEO Data', $menu_capability, $menu_slug . '-import-external', array($admin, 'render_import_external_data_page'));
836 + $register_submenu('import_seo', 'Import SEO Data', 'Import SEO Data', $menu_capability, $menu_slug . '-import-external', array($admin, 'render_import_external_data_page'));
736 837 }
737 838
738 - // Settings
839 + // Settings — registered against the bare $menu_slug (parent menu floor).
840 + // It always keeps its sidebar row so the plugin always has at least
841 + // one working entry point (see is_settings_reachable()).
739 842 if (Metasync_Access_Control::user_can_access('hide_settings')) {
740 - add_submenu_page($menu_slug, 'Settings', 'Settings', $menu_capability, $menu_slug, array($admin, 'create_admin_settings_page'));
843 + $register_submenu('general', 'Settings', 'Settings', $menu_capability, $menu_slug, array($admin, 'create_admin_settings_page'));
741 844 }
742 845
743 - // Optimal Settings (conditional)
744 - if ($general_options['enable_optimal_settings'] ?? false) {
745 - add_submenu_page($menu_slug, 'Optimal Settings', 'Optimal Settings', $menu_capability, $menu_slug . '-optimal-settings', array($admin, 'create_admin_optimal_settings_page'));
746 - }
846 + // Local Business (in-page sidebar only in short mode)
847 + $register_submenu('local_business', 'Local Business', 'Local Business', $menu_capability, $menu_slug . '-local-business', array($admin, 'create_admin_local_business_page'));
747 848
748 - // Local Business
749 - add_submenu_page($menu_slug, 'Local Business', 'Local Business', $menu_capability, $menu_slug . '-local-business', array($admin, 'create_admin_local_business_page'));
849 + // Breadcrumbs (in-page sidebar only in short mode)
850 + $register_submenu('breadcrumbs', 'Breadcrumbs', 'Breadcrumbs', $menu_capability, $menu_slug . '-breadcrumbs', array($admin, 'create_admin_breadcrumbs_page'));
750 851
751 - // Breadcrumbs
752 - add_submenu_page($menu_slug, 'Breadcrumbs', 'Breadcrumbs', $menu_capability, $menu_slug . '-breadcrumbs', array($admin, 'create_admin_breadcrumbs_page'));
852 + // Code Snippets (in-page sidebar only in short mode)
853 + $register_submenu('code_snippets', 'Code Snippets', 'Code Snippets', $menu_capability, $menu_slug . '-code-snippets', array($admin, 'create_admin_code_snippets_page'));
753 854
754 - // Code Snippets
755 - add_submenu_page($menu_slug, 'Code Snippets', 'Code Snippets', $menu_capability, $menu_slug . '-code-snippets', array($admin, 'create_admin_code_snippets_page'));
855 + // Code Minification (in-page sidebar only in short mode)
856 + $register_submenu('code_minification', 'Code Minification', 'Code Minification', $menu_capability, $menu_slug . '-code-minification', array($admin, 'create_admin_code_minification_page'));
756 857
757 - // Code Minification
758 - add_submenu_page($menu_slug, 'Code Minification', 'Code Minification', $menu_capability, $menu_slug . '-code-minification', array($admin, 'create_admin_code_minification_page'));
858 + // Media Optimization (in-page sidebar only in short mode)
859 + $register_submenu('media_optimization', 'Media Optimization', 'Media Optimization', $menu_capability, $menu_slug . '-media-optimization', array($admin, 'create_admin_media_optimization_page'));
759 860
760 - // Media Optimization
761 - add_submenu_page($menu_slug, 'Media Optimization', 'Media Optimization', $menu_capability, $menu_slug . '-media-optimization', array($admin, 'create_admin_media_optimization_page'));
762 -
763 861 // Custom Pages
764 862 if (Metasync_Access_Control::user_can_access('hide_custom_pages')) {
765 - add_submenu_page($menu_slug, 'Custom Pages', 'Custom Pages', $menu_capability, $menu_slug . '-custom-pages', array($admin, 'create_admin_custom_pages_page'));
863 + $register_submenu('custom_pages', 'Custom Pages', 'Custom Pages', $menu_capability, $menu_slug . '-custom-pages', array($admin, 'create_admin_custom_pages_page'));
766 864 }
767 865
768 - // Bot Statistics
769 - add_submenu_page($menu_slug, 'Bot Statistics', 'Bot Statistics', $menu_capability, $menu_slug . '-bot-statistics', array($admin, 'create_admin_bot_statistics_page'));
866 + // Bot Statistics (in-page sidebar only in short mode)
867 + $register_submenu('bot_statistics', 'Bot Statistics', 'Bot Statistics', $menu_capability, $menu_slug . '-bot-statistics', array($admin, 'create_admin_bot_statistics_page'));
770 868
771 869 // SEO Health dashboard
772 - add_submenu_page($menu_slug, 'SEO Health', 'SEO Health', $menu_capability, $menu_slug . '-seo-health', array($admin, 'create_admin_seo_health_page'));
870 + $register_submenu('seo_health', 'SEO Health', 'SEO Health', $menu_capability, $menu_slug . '-seo-health', array($admin, 'create_admin_seo_health_page'));
773 871
774 872 // Compatibility
775 873 if (Metasync_Access_Control::user_can_access('hide_compatibility')) {
776 - add_submenu_page($menu_slug, 'Compatibility', 'Compatibility', $menu_capability, $menu_slug . '-compatibility', array($admin, 'create_admin_compatibility_page'));
874 + $register_submenu('compatibility', 'Compatibility', 'Compatibility', $menu_capability, $menu_slug . '-compatibility', array($admin, 'create_admin_compatibility_page'));
777 875 }
778 876
779 877 // Changes Log
780 878 if (Metasync_Access_Control::user_can_access('hide_sync_log')) {
781 - add_submenu_page($menu_slug, 'Changes Log', 'Changes Log', $menu_capability, $menu_slug . '-sync-log', array($admin, 'create_admin_sync_log_page'));
879 + $register_submenu('sync_log', 'Changes Log', 'Changes Log', $menu_capability, $menu_slug . '-sync-log', array($admin, 'create_admin_sync_log_page'));
782 880 }
783 881
784 882 // Report Issue
785 883 if (Metasync_Access_Control::user_can_access('hide_report_issue')) {
786 - add_submenu_page($menu_slug, 'Report Issue', 'Report Issue', $menu_capability, $menu_slug . '-report-issue', array($admin, 'create_admin_report_issue_page'));
884 + $register_submenu('report_issue', 'Report Issue', 'Report Issue', $menu_capability, $menu_slug . '-report-issue', array($admin, 'create_admin_report_issue_page'));
787 885 }
788 886
789 887 // ── Connect CTA (shown when not authenticated) ────────────────────
888 + // Kept as a sidebar row so an unconnected site always has a visible
889 + // entry point alongside the top-level menu item.
790 890 if (!$is_fully_connected) {
791 - add_submenu_page($menu_slug, 'Connect to SearchAtlas', 'Connect to SearchAtlas', $menu_capability, $connect_slug, array($admin, 'create_admin_settings_page'));
891 + $connect_label = sprintf('Connect to %s', Metasync::get_effective_plugin_name());
892 + add_submenu_page($menu_slug, $connect_label, $connect_label, $menu_capability, $connect_slug, array($admin, 'create_admin_settings_page'));
792 893 }
793 894
794 895 // ── Hidden pages (no sidebar entry needed) ────────────────────────
896 + $admin_page_titles[$menu_slug . '-setup-wizard'] = 'Setup Wizard';
795 897 add_submenu_page('', 'Setup Wizard', 'Setup Wizard', $menu_capability, $menu_slug . '-setup-wizard', array($admin->setup_wizard, 'render_wizard_page'));
796 898
899 + // WordPress cannot resolve titles for pages registered under an empty
900 + // parent, even though those pages remain reachable by URL. Restore the
901 + // standard admin title format for our registered pages only.
902 + add_filter('admin_title', function($admin_title, $title) use (&$admin_page_titles) {
903 + $current_page = isset($_GET['page']) && is_string($_GET['page']) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page slug for the admin title
904 + ? sanitize_text_field(wp_unslash($_GET['page'])) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page slug for the admin title
905 + : '';
797 906
907 + if (empty($title) && isset($admin_page_titles[$current_page])) {
908 + $site_title = is_network_admin() || is_user_admin()
909 + ? get_network()->site_name
910 + : get_bloginfo('name');
911 +
912 + $admin_title = sprintf(
913 + /* translators: 1: Admin page title, 2: Site or network title. */
914 + __('%1$s &lsaquo; %2$s &#8212; WordPress', 'metasync'),
915 + $admin_page_titles[$current_page],
916 + $site_title
917 + );
918 + }
919 +
920 + return $admin_title;
921 + }, 10, 2);
922 +
923 +
798 924 // Rename auto-generated first submenu from plugin name to "Settings" and reorder
799 925 add_action('admin_menu', function() use ($menu_slug) {
800 926 global $submenu;
801 927 if (!isset($submenu[$menu_slug])) {
@@ -825,9 +951,8 @@
825 951 'dashboard' => 'dashboard',
826 952 'compatibility' => 'admin-tools',
827 953 'sync_log' => 'list-view',
828 954 'seo_controls' => 'search',
829 - 'optimal_settings' => 'superhero-alt',
830 955 'instant_index' => 'performance',
831 956 'google_console' => 'chart-area',
832 957 'bing_console' => 'chart-bar',
833 958 'redirections' => 'undo',
@@ -867,9 +992,9 @@
867 992 <?php
868 993 // Dashboard tab (standalone)
869 994 if (isset($seo_items['dashboard'])) {
870 995 $is_active = ($current_page === 'dashboard');
871 - $icon = $menu_icons['dashboard'] ?? 'admin-generic';
996 + $icon = $menu_icons['dashboard'];
872 997 $page_url = '?page=' . $page_slug . $seo_items['dashboard']['slug_suffix'];
873 998 ?>
874 999 <a href="<?php echo esc_url($page_url); ?>" class="metasync-nav-tab <?php echo $is_active ? 'active' : ''; ?>">
875 1000 <span class="tab-icon"><span class="dashicons dashicons-<?php echo esc_attr($icon); ?>"></span></span>
@@ -1250,9 +1375,9 @@
1250 1375 $status_title_header = 'Not Synced - Heartbeat API not responding or unreachable';
1251 1376 $status_text_header = 'Not Synced';
1252 1377 }
1253 1378 ?>
1254 - <div class="metasync-integration-status <?php echo $status_class_header; ?>"
1379 + <div class="metasync-integration-status <?php echo esc_attr($status_class_header); ?>"
1255 1380 title="<?php echo esc_attr($status_title_header); ?>">
1256 1381 <span class="status-indicator"></span>
1257 1382 <span class="status-text"><?php echo esc_html($status_text_header); ?></span>
1258 1383 </div>
@@ -1332,10 +1457,10 @@
1332 1457
1333 1458 <?php
1334 1459 $page_slug = Metasync_Admin::$page_slug;
1335 1460 $is_plugin_page = (
1336 - (isset($_GET['page']) && strpos($_GET['page'], $page_slug) !== false) ||
1337 - (isset($_GET['page']) && strpos($_GET['page'], 'searchatlas') !== false)
1461 + (isset($_GET['page']) && strpos($_GET['page'], $page_slug) !== false) || // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check for an inline config script
1462 + (isset($_GET['page']) && strpos($_GET['page'], 'searchatlas') !== false) // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only page check for an inline config script
1338 1463 );
1339 1464 if ($is_plugin_page):
1340 1465 ?>
1341 1466 <script type="text/javascript">
@@ -1512,18 +1637,20 @@
1512 1637 * @param string $description Optional subtitle shown below the title.
1513 1638 */
1514 1639 public function render_layout_open($page_title = '', $current_page = '', $description = '')
1515 1640 {
1516 - $theme = esc_attr(get_option('metasync_theme', 'dark'));
1641 + $theme = get_option('metasync_theme', 'dark');
1517 1642 $plugin_name = Metasync::get_effective_plugin_name();
1518 1643 $general = Metasync::get_option('general') ?? [];
1519 1644 $is_connected = Metasync_Heartbeat_Manager::instance()->is_heartbeat_connected($general);
1645 + // badge reflects confirmed heartbeat health (connected / stale /
1646 + // disconnected), not raw API-key presence.
1647 + $badge = Metasync_Heartbeat_Manager::instance()->get_connection_badge($general);
1520 1648 $logo = $this->resolve_logo_data();
1521 1649
1522 1650 $current_theme = get_option('metasync_theme', 'dark');
1523 - $api_key = $general['searchatlas_api_key'] ?? '';
1524 1651 ?>
1525 - <div class="wrap metasync-dashboard-wrap" data-theme="<?php echo $theme; ?>">
1652 + <div class="wrap metasync-dashboard-wrap" data-theme="<?php echo esc_attr($theme); ?>">
1526 1653
1527 1654 <?php
1528 1655 // Inject whitelabel color palette overrides
1529 1656 $wl_settings = Metasync::get_whitelabel_settings();
@@ -1553,8 +1680,9 @@
1553 1680 $vars .= '--' . esc_attr($grad_var) . ':linear-gradient(135deg,' . esc_attr($from) . ' 0%,' . esc_attr($to) . ' 100%);';
1554 1681 }
1555 1682 }
1556 1683 if ($vars) {
1684 + // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- CSS custom properties inside a raw <style> element; every value is a regex-validated hex color and HTML entities are not decoded in raw text elements
1557 1685 echo $selector . '{' . $vars . '}';
1558 1686 }
1559 1687 }
1560 1688 }
@@ -1574,11 +1702,11 @@
1574 1702 <strong style="font-size:15px;color:var(--dashboard-text-primary);"><?php echo esc_html($plugin_name); ?></strong>
1575 1703 <?php endif; ?>
1576 1704 </div>
1577 1705 <div class="metasync-header-compact-right">
1578 - <div class="metasync-status <?php echo !empty($api_key) ? 'connected' : 'disconnected'; ?>">
1706 + <div class="metasync-status <?php echo esc_attr($badge['class']); ?>">
1579 1707 <span class="status-dot"></span>
1580 - <span class="status-text"><?php echo !empty($api_key) ? 'Connected' : 'Not Connected'; ?></span>
1708 + <span class="status-text"><?php echo esc_html($badge['text']); ?></span>
1581 1709 </div>
1582 1710 <button type="button" class="metasync-theme-toggle" onclick="toggleMetasyncTheme()" title="Toggle theme">
1583 1711 <span class="theme-icon-light">&#9728;</span>
1584 1712 <span class="theme-icon-dark">&#9790;</span>
@@ -1595,8 +1723,17 @@
1595 1723 </aside>
1596 1724
1597 1725 <!-- Main content -->
1598 1726 <main class="metasync-layout-main">
1727 + <?php
1728 + // Anchor for WP core's notice relocation (common.js). Without it, core
1729 + // moves admin notices after the first .wrap h1 only on DOM-ready, after
1730 + // the server has already painted them at the top of #wpbody-content —
1731 + // causing a flash above the header and layout shift. Providing
1732 + // an explicit .wp-header-end inside this (FOUC-hidden) wrap makes core
1733 + // relocate notices here deterministically, so they fade in with the page.
1734 + ?>
1735 + <hr class="wp-header-end">
1599 1736 <?php if ($page_title || $description): ?>
1600 1737 <div class="metasync-page-header">
1601 1738 <?php if ($page_title): ?>
1602 1739 <h1><?php echo esc_html($page_title); ?></h1>
@@ -1620,15 +1757,19 @@
1620 1757 {
1621 1758 ?>
1622 1759 </main><!-- /.metasync-layout-main -->
1623 1760
1624 - <?php if ($show_promo):
1625 - $general = Metasync::get_option('general') ?? [];
1626 - $is_connected = Metasync_Heartbeat_Manager::instance()->is_heartbeat_connected($general);
1761 + <?php
1762 + // The sidebar exists to get an unconnected site connected. Once the
1763 + // site is linked it has nothing further to offer, so the whole
1764 + // column is dropped and the grid reflows to two columns.
1765 + $show_promo = $show_promo && ! Metasync_Heartbeat_Manager::instance()
1766 + ->is_heartbeat_connected(Metasync::get_option('general') ?? []);
1767 + if ($show_promo):
1627 1768 ?>
1628 1769 <!-- Right promo sidebar -->
1629 1770 <aside class="metasync-layout-promo">
1630 - <?php $this->render_promo_sidebar($is_connected); ?>
1771 + <?php $this->render_promo_sidebar(); ?>
1631 1772 </aside>
1632 1773 <?php endif; ?>
1633 1774
1634 1775 </div><!-- /.metasync-layout -->
@@ -1665,9 +1806,8 @@
1665 1806 'breadcrumbs' => 'menu',
1666 1807 'code_snippets' => 'editor-code',
1667 1808 'code_minification'=> 'media-code',
1668 1809 'custom_pages' => 'admin-page',
1669 - 'optimal_settings' => 'superhero-alt',
1670 1810 'compatibility' => 'admin-tools',
1671 1811 'sync_log' => 'list-view',
1672 1812 'bot_statistics' => 'visibility',
1673 1813 'report_issue' => 'sos',
@@ -1683,11 +1823,20 @@
1683 1823 } else {
1684 1824 $plugin_items[$key] = $item;
1685 1825 }
1686 1826 }
1827 +
1828 + $total_items = count($seo_items) + count($plugin_items);
1829 +
1687 1830 ?>
1688 1831 <nav class="metasync-sidenav">
1689 1832
1833 + <?php if ($total_items === 0): ?>
1834 + <div class="metasync-sidenav-empty">
1835 + <?php esc_html_e('No pages are available.', 'metasync'); ?>
1836 + </div>
1837 + <?php else: ?>
1838 +
1690 1839 <!-- SEO Features group -->
1691 1840 <div class="metasync-sidenav-group">
1692 1841 <div class="metasync-sidenav-group-title">SEO Features</div>
1693 1842 <ul>
@@ -1693,12 +1842,12 @@
1693 1842 <ul>
1694 1843 <?php foreach ($seo_items as $key => $item):
1695 1844 $is_active = ($current_page === $key);
1696 1845 $icon = $icons[$key] ?? 'admin-generic';
1697 - $url = esc_url(admin_url('admin.php?page=' . $page_slug . $item['slug_suffix']));
1846 + $url = admin_url('admin.php?page=' . $page_slug . $item['slug_suffix']);
1698 1847 ?>
1699 1848 <li class="<?php echo $is_active ? 'metasync-sidenav-active' : ''; ?>">
1700 - <a href="<?php echo $url; ?>">
1849 + <a href="<?php echo esc_url($url); ?>">
1701 1850 <span class="metasync-sidenav-icon"><span class="dashicons dashicons-<?php echo esc_attr($icon); ?>"></span></span>
1702 1851 <?php echo esc_html($item['title']); ?>
1703 1852 </a>
1704 1853 </li>
@@ -1713,12 +1862,12 @@
1713 1862 <?php foreach ($plugin_items as $key => $item):
1714 1863 if ($key === 'report_issue') continue;
1715 1864 $is_active = ($current_page === $key);
1716 1865 $icon = $icons[$key] ?? 'admin-generic';
1717 - $url = esc_url(admin_url('admin.php?page=' . $page_slug . $item['slug_suffix']));
1866 + $url = admin_url('admin.php?page=' . $page_slug . $item['slug_suffix']);
1718 1867 ?>
1719 1868 <li class="<?php echo $is_active ? 'metasync-sidenav-active' : ''; ?>">
1720 - <a href="<?php echo $url; ?>">
1869 + <a href="<?php echo esc_url($url); ?>">
1721 1870 <span class="metasync-sidenav-icon"><span class="dashicons dashicons-<?php echo esc_attr($icon); ?>"></span></span>
1722 1871 <?php echo esc_html($item['title']); ?>
1723 1872 </a>
1724 1873 </li>
@@ -1753,8 +1902,10 @@
1753 1902 </ul>
1754 1903 </div>
1755 1904 <?php endif; ?>
1756 1905
1906 + <?php endif; ?>
1907 +
1757 1908 </nav>
1758 1909 <?php
1759 1910 }
1760 1911
@@ -1760,17 +1911,22 @@
1760 1911
1761 1912 /**
1762 1913 * Render the right promotional sidebar.
1763 1914 *
1764 - * @param bool $is_connected Whether the plugin is authenticated.
1915 + * Only reached while the site is unconnected; the caller drops the
1916 + * whole column once the plugin is linked.
1765 1917 */
1766 - public function render_promo_sidebar($is_connected = false)
1918 + public function render_promo_sidebar()
1767 1919 {
1768 1920 $plugin_name = Metasync::get_effective_plugin_name();
1769 1921 $otto_name = Metasync::get_whitelabel_otto_name();
1770 - $settings_url = esc_url(admin_url('admin.php?page=' . Metasync_Admin::$page_slug));
1922 + $settings_url = admin_url('admin.php?page=' . Metasync_Admin::$page_slug);
1771 1923 $homepage = Metasync::HOMEPAGE_DOMAIN;
1772 - $is_default_brand = ( $plugin_name === 'Search Atlas' );
1924 + $docs_url = Metasync::DOCUMENTATION_DOMAIN;
1925 + // These links point at Search Atlas properties, so they only belong
1926 + // here while the plugin runs under its own name AND branding — a
1927 + // reseller can leave the name untouched and still be whitelabeled.
1928 + $is_default_brand = ( $plugin_name === 'Search Atlas' ) && ! Metasync::is_whitelabel_enabled();
1773 1929 $whitelabel = Metasync::get_whitelabel_settings();
1774 1930 $custom_links = isset($whitelabel['quick_links']) && is_array($whitelabel['quick_links'])
1775 1931 ? array_filter($whitelabel['quick_links'], function($l) { return !empty($l['url']); })
1776 1932 : [];
@@ -1775,9 +1931,8 @@
1775 1931 ? array_filter($whitelabel['quick_links'], function($l) { return !empty($l['url']); })
1776 1932 : [];
1777 1933 ?>
1778 1934
1779 - <?php if (!$is_connected): ?>
1780 1935 <!-- Connect CTA card -->
1781 1936 <div class="metasync-promo-card metasync-promo-card--connect">
1782 1937 <div class="metasync-promo-card-header">
1783 1938 <div class="metasync-promo-card-icon">
@@ -1793,40 +1948,12 @@
1793 1948 <li><span class="promo-check">&#10003;</span> Real-time keyword tracking</li>
1794 1949 <li><span class="promo-check">&#10003;</span> Automated schema markup</li>
1795 1950 <li><span class="promo-check">&#10003;</span> Instant Google indexing</li>
1796 1951 </ul>
1797 - <a href="<?php echo $settings_url; ?>" class="metasync-promo-btn metasync-promo-btn--primary">
1952 + <a href="<?php echo esc_url($settings_url); ?>" class="metasync-promo-btn metasync-promo-btn--primary">
1798 1953 Connect Now
1799 1954 </a>
1800 1955 </div>
1801 - <?php else: ?>
1802 - <!-- Connected — feature highlights -->
1803 - <div class="metasync-promo-card metasync-promo-card--accent">
1804 - <div class="metasync-promo-card-header">
1805 - <div class="metasync-promo-card-icon">
1806 - <span class="dashicons dashicons-performance"></span>
1807 - </div>
1808 - <div>
1809 - <h3><?php echo esc_html($otto_name); ?> Active</h3>
1810 - </div>
1811 - </div>
1812 - <p class="metasync-promo-tagline">Your site is connected and <?php echo esc_html($otto_name); ?> is optimizing pages automatically.</p>
1813 - <ul class="metasync-promo-benefits">
1814 - <li><span class="promo-check">&#10003;</span> Schema markup auto-applied</li>
1815 - <li><span class="promo-check">&#10003;</span> Meta titles &amp; descriptions optimized</li>
1816 - <li><span class="promo-check">&#10003;</span> Internal linking suggestions active</li>
1817 - </ul>
1818 - <?php if ($is_default_brand): ?>
1819 - <a href="<?php echo esc_url($homepage); ?>" target="_blank" rel="noopener" class="metasync-promo-btn metasync-promo-btn--outline">
1820 - View <?php echo esc_html($plugin_name); ?> Dashboard
1821 - </a>
1822 - <?php elseif (!empty($whitelabel['domain'])): ?>
1823 - <a href="<?php echo esc_url($whitelabel['domain']); ?>" target="_blank" rel="noopener" class="metasync-promo-btn metasync-promo-btn--outline">
1824 - View <?php echo esc_html($plugin_name); ?> Dashboard
1825 - </a>
1826 - <?php endif; ?>
1827 - </div>
1828 - <?php endif; ?>
1829 1956
1830 1957 <?php
1831 1958 // Quick Links: show default links for default brand, custom links if whitelabeled + provided, hide if whitelabeled + none
1832 1959 $show_quick_links = $is_default_brand || !empty($custom_links);
@@ -1836,12 +1963,20 @@
1836 1963 <div class="metasync-promo-card">
1837 1964 <h3 style="margin:0 0 12px;font-size:13px;font-weight:700;color:var(--dashboard-text-primary);">Quick Links</h3>
1838 1965 <ul class="metasync-promo-links">
1839 1966 <?php if ($is_default_brand): ?>
1967 + <li><a href="<?php echo esc_url($docs_url); ?>" target="_blank" rel="noopener"><span class="dashicons dashicons-book-alt"></span> Documentation</a></li>
1840 1968 <li><a href="<?php echo esc_url($homepage . '/blog/'); ?>" target="_blank" rel="noopener"><span class="dashicons dashicons-rss"></span> SEO Blog</a></li>
1841 - <li><a href="<?php echo esc_url($homepage . '/academy/'); ?>" target="_blank" rel="noopener"><span class="dashicons dashicons-welcome-learn-more"></span> SEO Academy</a></li>
1969 + <li><a href="<?php echo esc_url($homepage . '/contact/'); ?>" target="_blank" rel="noopener"><span class="dashicons dashicons-email-alt"></span> Contact Support</a></li>
1842 1970 <li><a href="<?php echo esc_url(admin_url('admin.php?page=' . Metasync_Admin::$page_slug . '-setup-wizard')); ?>"><span class="dashicons dashicons-admin-customizer"></span> Setup Wizard</a></li>
1971 + <?php
1972 + // Mirrors the gate that decides whether the page is registered
1973 + // at all. Without it the link outlives the page for any user
1974 + // the access rules hide it from, and leads nowhere.
1975 + if (Metasync_Access_Control::user_can_access('hide_report_issue')):
1976 + ?>
1843 1977 <li><a href="<?php echo esc_url(admin_url('admin.php?page=' . Metasync_Admin::$page_slug . '-report-issue')); ?>"><span class="dashicons dashicons-sos"></span> Report Issue</a></li>
1978 + <?php endif; ?>
1844 1979 <?php else: ?>
1845 1980 <?php foreach ($custom_links as $link): ?>
1846 1981 <li><a href="<?php echo esc_url($link['url']); ?>" <?php echo !empty($link['external']) ? 'target="_blank" rel="noopener"' : ''; ?>><span class="dashicons dashicons-admin-links"></span> <?php echo esc_html($link['label'] ?: $link['url']); ?></a></li>
1847 1982 <?php endforeach; ?>