fix: Settings submenu standalone-only, dashboard path, add admin bar link
This commit is contained in:
@@ -328,7 +328,8 @@ function AppRoutes() {
|
|||||||
return (
|
return (
|
||||||
<Routes>
|
<Routes>
|
||||||
{/* Dashboard */}
|
{/* Dashboard */}
|
||||||
<Route path="/" element={<Dashboard />} />
|
<Route path="/" element={<Navigate to="/dashboard" replace />} />
|
||||||
|
<Route path="/dashboard" element={<Dashboard />} />
|
||||||
<Route path="/dashboard/revenue" element={<DashboardRevenue />} />
|
<Route path="/dashboard/revenue" element={<DashboardRevenue />} />
|
||||||
<Route path="/dashboard/orders" element={<DashboardOrders />} />
|
<Route path="/dashboard/orders" element={<DashboardOrders />} />
|
||||||
<Route path="/dashboard/products" element={<DashboardProducts />} />
|
<Route path="/dashboard/products" element={<DashboardProducts />} />
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ function getStaticFallbackTree(): MainNode[] {
|
|||||||
{
|
{
|
||||||
key: 'dashboard',
|
key: 'dashboard',
|
||||||
label: 'Dashboard',
|
label: 'Dashboard',
|
||||||
path: '/',
|
path: '/dashboard',
|
||||||
icon: 'layout-dashboard',
|
icon: 'layout-dashboard',
|
||||||
children: [
|
children: [
|
||||||
{ label: 'Overview', mode: 'spa', path: '/', exact: true },
|
{ label: 'Overview', mode: 'spa', path: '/dashboard', exact: true },
|
||||||
{ label: 'Revenue', mode: 'spa', path: '/dashboard/revenue' },
|
{ label: 'Revenue', mode: 'spa', path: '/dashboard/revenue' },
|
||||||
{ label: 'Orders', mode: 'spa', path: '/dashboard/orders' },
|
{ label: 'Orders', mode: 'spa', path: '/dashboard/orders' },
|
||||||
{ label: 'Products', mode: 'spa', path: '/dashboard/products' },
|
{ label: 'Products', mode: 'spa', path: '/dashboard/products' },
|
||||||
@@ -102,7 +102,8 @@ function getStaticFallbackTree(): MainNode[] {
|
|||||||
label: 'Settings',
|
label: 'Settings',
|
||||||
path: '/settings',
|
path: '/settings',
|
||||||
icon: 'settings',
|
icon: 'settings',
|
||||||
children: [
|
// Only show submenu in standalone mode
|
||||||
|
children: (window as any).WNW_CONFIG?.standaloneMode ? [
|
||||||
// WooNooW Settings
|
// WooNooW Settings
|
||||||
{ label: 'WooNooW', mode: 'spa', path: '/settings' },
|
{ label: 'WooNooW', mode: 'spa', path: '/settings' },
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ function getStaticFallbackTree(): MainNode[] {
|
|||||||
{ label: 'Integration', mode: 'bridge', href: `${admin}?page=wc-settings&tab=integration` },
|
{ label: 'Integration', mode: 'bridge', href: `${admin}?page=wc-settings&tab=integration` },
|
||||||
{ label: 'Status', mode: 'bridge', href: `${admin}?page=wc-status` },
|
{ label: 'Status', mode: 'bridge', href: `${admin}?page=wc-status` },
|
||||||
{ label: 'Extensions', mode: 'bridge', href: `${admin}?page=wc-addons` },
|
{ label: 'Extensions', mode: 'bridge', href: `${admin}?page=wc-addons` },
|
||||||
],
|
] : [],
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class Menu {
|
|||||||
add_action('admin_menu', [__CLASS__, 'register']);
|
add_action('admin_menu', [__CLASS__, 'register']);
|
||||||
// After all plugins/themes add their menus, collect Woo menus for SPA
|
// After all plugins/themes add their menus, collect Woo menus for SPA
|
||||||
add_action('admin_head', [__CLASS__, 'localize_wc_menus'], 999);
|
add_action('admin_head', [__CLASS__, 'localize_wc_menus'], 999);
|
||||||
|
// Add link to standalone admin in admin bar
|
||||||
|
add_action('admin_bar_menu', [__CLASS__, 'add_admin_bar_link'], 100);
|
||||||
}
|
}
|
||||||
public static function register() {
|
public static function register() {
|
||||||
add_menu_page(
|
add_menu_page(
|
||||||
@@ -92,4 +94,23 @@ class Menu {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add link to standalone admin in WordPress admin bar
|
||||||
|
*/
|
||||||
|
public static function add_admin_bar_link( $wp_admin_bar ) {
|
||||||
|
// Only show for users with WooCommerce permissions
|
||||||
|
if ( ! current_user_can( 'manage_woocommerce' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wp_admin_bar->add_node( [
|
||||||
|
'id' => 'woonoow-standalone',
|
||||||
|
'title' => '<span class="ab-icon dashicons-store"></span><span class="ab-label">WooNooW</span>',
|
||||||
|
'href' => home_url( '/admin' ),
|
||||||
|
'meta' => [
|
||||||
|
'title' => __( 'WooNooW Standalone Admin', 'woonoow' ),
|
||||||
|
],
|
||||||
|
] );
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user