## ✅ Issue 1: Customers Submenu Missing in WP-Admin **Problem:** Tax and Customer submenus only visible in standalone mode **Root Cause:** PHP navigation registry did not include Customers **Fixed:** Added Customers to NavigationRegistry.php settings children **Result:** Customers submenu now shows in all modes ## ✅ Issue 2: App Logo/Title in Topbar **Problem:** Should show logo → store name → "WooNooW" fallback **Fixed:** Header component now: - Fetches branding from /store/branding endpoint - Shows logo image if available - Falls back to store name text - Updates on store settings change event **Result:** Proper branding hierarchy in app header ## ✅ Issue 3: Zone Card Header Density on Mobile **Problem:** "Indonesia Addons" row with 3 icons too cramped on mobile **Fixed:** Shipping.tsx zone card header: - Reduced gap from gap-3 to gap-2/gap-1 on mobile - Smaller font size on mobile (text-sm md:text-lg) - Added min-w-0 for proper text truncation - flex-shrink-0 on icon buttons **Result:** Better mobile spacing and readability ## ✅ Issue 4: Go to WP Admin Button **Problem:** Should show in standalone mode, not wp-admin **Fixed:** More page now shows "Go to WP Admin" button: - Only in standalone mode - Before Logout button - Links to /wp-admin **Result:** Easy access to WP Admin from standalone mode ## ✅ Issue 5: Customer Settings 403 Error **Problem:** Permission check failing for customer-settings endpoint **Fixed:** StoreController.php check_permission(): - Added fallback: manage_woocommerce OR manage_options - Ensures administrators always have access **Result:** Customer Settings page loads successfully ## ✅ Issue 6: Dark Mode Logo Upload Field **Problem:** No UI to upload dark mode logo **Fixed:** Store settings page now has: - "Store logo (Light mode)" field - "Store logo (Dark mode)" field (optional) - Backend support in StoreSettingsProvider - Full save/load functionality **Result:** Users can upload separate logos for light/dark modes ## ✅ Issue 7: Login Card Background Too Dark **Problem:** Login card same color as background in dark mode **Fixed:** Login.tsx card styling: - Changed from dark:bg-gray-800 (solid) - To dark:bg-gray-900/50 (semi-transparent) - Added backdrop-blur-xl for glass effect - Added border for definition **Result:** Login card visually distinct with modern glass effect --- ## Summary **All 7 Issues Resolved:** 1. ✅ Customers submenu in all modes 2. ✅ Logo/title hierarchy in topbar 3. ✅ Mobile zone card spacing 4. ✅ Go to WP Admin in standalone 5. ✅ Customer Settings permission fix 6. ✅ Dark mode logo upload field 7. ✅ Lighter login card background **Files Modified:** - NavigationRegistry.php - Added Customers to nav - App.tsx - Logo/branding in header - Shipping.tsx - Mobile spacing - More/index.tsx - WP Admin button - StoreController.php - Permission fallback - Store.tsx - Dark logo field - StoreSettingsProvider.php - Dark logo backend - Login.tsx - Card background **Ready for production!** 🎉
228 lines
8.4 KiB
PHP
228 lines
8.4 KiB
PHP
<?php
|
|
namespace WooNooW\Compat;
|
|
|
|
if ( ! defined('ABSPATH') ) exit;
|
|
|
|
/**
|
|
* Navigation Registry
|
|
*
|
|
* Manages dynamic navigation tree building. Allows addons to inject
|
|
* menu items into the main navigation or existing sections.
|
|
*
|
|
* @since 1.0.0
|
|
*/
|
|
class NavigationRegistry {
|
|
const NAV_OPTION = 'wnw_nav_tree';
|
|
const NAV_VERSION = '1.0.0';
|
|
|
|
/**
|
|
* Initialize hooks
|
|
*/
|
|
public static function init() {
|
|
// Use 'init' hook instead of 'plugins_loaded' to avoid translation loading warnings (WP 6.7+)
|
|
add_action('init', [__CLASS__, 'build_nav_tree'], 10);
|
|
add_action('activated_plugin', [__CLASS__, 'flush']);
|
|
add_action('deactivated_plugin', [__CLASS__, 'flush']);
|
|
}
|
|
|
|
/**
|
|
* Build the complete navigation tree
|
|
*/
|
|
public static function build_nav_tree() {
|
|
// Base navigation tree (core WooNooW sections)
|
|
$tree = self::get_base_tree();
|
|
|
|
/**
|
|
* Filter: woonoow/nav_tree
|
|
*
|
|
* Allows addons to modify the entire navigation tree.
|
|
*
|
|
* @param array $tree Array of main navigation nodes
|
|
*
|
|
* Example:
|
|
* add_filter('woonoow/nav_tree', function($tree) {
|
|
* $tree[] = [
|
|
* 'key' => 'subscriptions',
|
|
* 'label' => 'Subscriptions',
|
|
* 'path' => '/subscriptions',
|
|
* 'icon' => 'repeat', // lucide icon name
|
|
* 'children' => [
|
|
* ['label' => 'All Subscriptions', 'mode' => 'spa', 'path' => '/subscriptions'],
|
|
* ['label' => 'New', 'mode' => 'spa', 'path' => '/subscriptions/new'],
|
|
* ],
|
|
* ];
|
|
* return $tree;
|
|
* });
|
|
*/
|
|
$tree = apply_filters('woonoow/nav_tree', $tree);
|
|
|
|
// Allow per-section modification
|
|
foreach ($tree as &$section) {
|
|
$key = $section['key'] ?? '';
|
|
if ($key) {
|
|
/**
|
|
* Filter: woonoow/nav_tree/{key}/children
|
|
*
|
|
* Allows addons to inject items into specific sections.
|
|
*
|
|
* Example:
|
|
* add_filter('woonoow/nav_tree/products/children', function($children) {
|
|
* $children[] = [
|
|
* 'label' => 'Bundles',
|
|
* 'mode' => 'spa',
|
|
* 'path' => '/products/bundles',
|
|
* ];
|
|
* return $children;
|
|
* });
|
|
*/
|
|
$section['children'] = apply_filters(
|
|
"woonoow/nav_tree/{$key}/children",
|
|
$section['children'] ?? []
|
|
);
|
|
}
|
|
}
|
|
|
|
// Store in option
|
|
update_option(self::NAV_OPTION, [
|
|
'version' => self::NAV_VERSION,
|
|
'tree' => $tree,
|
|
'updated' => time(),
|
|
], false);
|
|
}
|
|
|
|
/**
|
|
* Get base navigation tree (core sections)
|
|
*
|
|
* @return array Base navigation tree
|
|
*/
|
|
private static function get_base_tree(): array {
|
|
return [
|
|
[
|
|
'key' => 'dashboard',
|
|
'label' => __('Dashboard', 'woonoow'),
|
|
'path' => '/',
|
|
'icon' => 'layout-dashboard',
|
|
'children' => [
|
|
['label' => __('Overview', 'woonoow'), 'mode' => 'spa', 'path' => '/', 'exact' => true],
|
|
['label' => __('Revenue', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/revenue'],
|
|
['label' => __('Orders', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/orders'],
|
|
['label' => __('Products', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/products'],
|
|
['label' => __('Customers', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/customers'],
|
|
['label' => __('Coupons', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/coupons'],
|
|
['label' => __('Taxes', 'woonoow'), 'mode' => 'spa', 'path' => '/dashboard/taxes'],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'orders',
|
|
'label' => __('Orders', 'woonoow'),
|
|
'path' => '/orders',
|
|
'icon' => 'receipt-text',
|
|
'children' => [], // Orders has no submenu by design
|
|
],
|
|
[
|
|
'key' => 'products',
|
|
'label' => __('Products', 'woonoow'),
|
|
'path' => '/products',
|
|
'icon' => 'package',
|
|
'children' => [
|
|
['label' => __('All products', 'woonoow'), 'mode' => 'spa', 'path' => '/products'],
|
|
['label' => __('New', 'woonoow'), 'mode' => 'spa', 'path' => '/products/new'],
|
|
['label' => __('Categories', 'woonoow'), 'mode' => 'spa', 'path' => '/products/categories'],
|
|
['label' => __('Tags', 'woonoow'), 'mode' => 'spa', 'path' => '/products/tags'],
|
|
['label' => __('Attributes', 'woonoow'), 'mode' => 'spa', 'path' => '/products/attributes'],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'coupons',
|
|
'label' => __('Coupons', 'woonoow'),
|
|
'path' => '/coupons',
|
|
'icon' => 'tag',
|
|
'children' => [
|
|
['label' => __('All coupons', 'woonoow'), 'mode' => 'spa', 'path' => '/coupons'],
|
|
['label' => __('New', 'woonoow'), 'mode' => 'spa', 'path' => '/coupons/new'],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'customers',
|
|
'label' => __('Customers', 'woonoow'),
|
|
'path' => '/customers',
|
|
'icon' => 'users',
|
|
'children' => [
|
|
['label' => __('All customers', 'woonoow'), 'mode' => 'spa', 'path' => '/customers'],
|
|
],
|
|
],
|
|
[
|
|
'key' => 'settings',
|
|
'label' => __('Settings', 'woonoow'),
|
|
'path' => '/settings',
|
|
'icon' => 'settings',
|
|
'children' => self::get_settings_children(),
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Get settings submenu children
|
|
*
|
|
* @return array Settings submenu items
|
|
*/
|
|
private static function get_settings_children(): array {
|
|
$admin = admin_url('admin.php');
|
|
|
|
$children = [
|
|
// Core Settings (Shopify-inspired)
|
|
['label' => __('Store Details', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/store'],
|
|
['label' => __('Payments', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/payments'],
|
|
['label' => __('Shipping & Delivery', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/shipping'],
|
|
['label' => __('Tax', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/tax'],
|
|
['label' => __('Customers', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/customers'],
|
|
['label' => __('Notifications', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/notifications'],
|
|
['label' => __('Developer', 'woonoow'), 'mode' => 'spa', 'path' => '/settings/developer'],
|
|
];
|
|
|
|
return $children;
|
|
}
|
|
|
|
/**
|
|
* Get the complete navigation tree
|
|
*
|
|
* @return array Navigation tree
|
|
*/
|
|
public static function get_nav_tree(): array {
|
|
$data = get_option(self::NAV_OPTION, []);
|
|
return $data['tree'] ?? self::get_base_tree();
|
|
}
|
|
|
|
/**
|
|
* Get a specific section by key
|
|
*
|
|
* @param string $key Section key
|
|
* @return array|null Section data or null if not found
|
|
*/
|
|
public static function get_section(string $key): ?array {
|
|
$tree = self::get_nav_tree();
|
|
foreach ($tree as $section) {
|
|
if (($section['key'] ?? '') === $key) {
|
|
return $section;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Flush the navigation cache
|
|
*/
|
|
public static function flush() {
|
|
delete_option(self::NAV_OPTION);
|
|
}
|
|
|
|
/**
|
|
* Get navigation tree for frontend
|
|
*
|
|
* @return array Array suitable for JSON encoding
|
|
*/
|
|
public static function get_frontend_nav_tree(): array {
|
|
return self::get_nav_tree();
|
|
}
|
|
}
|