🐛 CRITICAL FIX - Root Cause Found!
The plugin had hardcoded dev mode filters that forced EVERYONE into dev mode:
- add_filter('woonoow/admin_is_dev', '__return_true');
- add_filter('woonoow/admin_dev_server', fn() => 'https://woonoow.local:5173');
This caused:
- ✗ SPA trying to load from localhost:5173
- ✗ Loading @react-refresh and main.tsx (dev files)
- ✗ Not loading app.js and app.css (production files)
✅ Solution:
- Removed hardcoded filters from woonoow.php
- Commented them out with instructions
- Added debug logging to is_dev_mode()
- Updated installation checker to detect this issue
📝 For Developers:
If you need dev mode, add to wp-config.php:
define('WOONOOW_ADMIN_DEV', true);
Or use filter in your development plugin:
add_filter('woonoow/admin_is_dev', '__return_true');
🎯 Result:
- Production mode by default (no config needed)
- Dev mode only when explicitly enabled
- Better UX - plugin works out of the box
🐛 Problem:
- WordPress Media library not loaded in standalone mode
- Error: 'wp.media is not available'
- Image upload functionality broken
✅ Solution:
- Added wp_enqueue_media() in render_standalone_admin()
- Added wpApiSettings global for REST API compatibility
- Print media-editor and media-audiovideo scripts
- Print media-views and imgareaselect styles
📝 Changes:
- StandaloneAdmin.php:
- Enqueue media library
- Output media styles in <head>
- Output media scripts before app.js
- Add wpApiSettings global
🎯 Result:
- WordPress media library now available in standalone mode
- Image upload works correctly
- 'Choose from Media Library' button functional
🐛 Problem:
- SPA not loading in wp-admin
- Trying to load from dev server (localhost:5173)
- Happening in Local by Flywheel (wp_get_environment_type() = 'development')
✅ Solution:
- Changed is_dev_mode() to ONLY enable dev mode if WOONOOW_ADMIN_DEV constant is explicitly set
- Removed wp_get_environment_type() check
- Now defaults to production mode (loads from admin-spa/dist/)
📝 To Enable Dev Mode:
Add to wp-config.php:
define('WOONOOW_ADMIN_DEV', true);
🎯 Result:
- Production mode by default
- Dev mode only when explicitly enabled
- Works correctly in Local by Flywheel and other local environments
## ✅ Issue 1: Standalone Mode Navigation
**Problem:** Standalone mode not getting WNW_NAV_TREE from PHP
**Fixed:** Added WNW_NAV_TREE injection to StandaloneAdmin.php
**Result:** Navigation now works in standalone mode with PHP as single source
## ✅ Issue 2: 404 Errors for branding and customer-settings
**Problem:** REST URLs had trailing slashes causing double slashes
**Root Cause:**
- `rest_url("woonoow/v1")` returns `https://site.com/wp-json/woonoow/v1/`
- Frontend: `restUrl + "/store/branding"` = double slash
- WP-admin missing WNW_CONFIG entirely
**Fixed:**
1. **Removed trailing slashes** from all REST URLs using `untrailingslashit()`
- StandaloneAdmin.php
- Assets.php (dev and prod modes)
2. **Added WNW_CONFIG to wp-admin** for API compatibility
- Dev mode: Added WNW_CONFIG with restUrl, nonce, standaloneMode, etc.
- Prod mode: Added WNW_CONFIG to localize_runtime()
- Now both modes use same config structure
**Result:**
- ✅ `/store/branding` works in all modes
- ✅ `/store/customer-settings` works in all modes
- ✅ Consistent API access across standalone and wp-admin
## ✅ Issue 3: SVG Upload Error 500
**Problem:** WordPress blocks SVG uploads by default
**Security:** "Sorry, you are not allowed to upload this file type"
**Fixed:** Created MediaUpload.php with:
1. **Allow SVG uploads** for users with upload_files capability
2. **Fix SVG mime type detection** (WordPress issue)
3. **Sanitize SVG on upload** - reject files with:
- `<script>` tags
- `javascript:` protocols
- Event handlers (onclick, onload, etc.)
**Result:**
- ✅ SVG uploads work securely
- ✅ Dangerous SVG content blocked
- ✅ Only authorized users can upload
---
## Files Modified:
- `StandaloneAdmin.php` - Add nav tree + fix REST URL
- `Assets.php` - Add WNW_CONFIG + fix REST URLs
- `Bootstrap.php` - Initialize MediaUpload
- `MediaUpload.php` - NEW: SVG upload support with security
## Testing:
1. ✅ Navigation works in standalone mode
2. ✅ Branding endpoint works in all modes
3. ✅ Customer settings endpoint works in all modes
4. ✅ SVG logo upload works
5. ✅ Dangerous SVG files rejected
## ✅ 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!** 🎉
## Issue 1: Submenu Hidden in WP-Admin Modes ✅
**Problem:** Tax and Customer submenus visible in standalone but hidden in wp-admin modes
**Root Cause:** Incorrect `top` positioning calculation
- Was: `top-[calc(7rem+32px)]` (112px + 32px = 144px)
- Should be: `top-16` (64px - header height)
**Fixed:**
- `DashboardSubmenuBar.tsx` - Updated positioning
- `SubmenuBar.tsx` - Updated positioning
**Result:** Submenus now visible in all modes ✅
---
## Issue 2: Inconsistent Title in Standalone ✅
**Problem:** Title should prioritize: Logo → Store Name → WooNooW
**Fixed:**
- `StandaloneAdmin.php` - Use `woonoow_store_name` option first
- Falls back to `blogname`, then "WooNooW"
---
## Issue 3: Dense Card Header on Mobile ✅
**Problem:** Card header with title, description, and button too cramped on mobile
**Solution:** Stack vertically on mobile, horizontal on desktop
**Fixed:**
- `SettingsCard.tsx` - Changed from `flex-row` to `flex-col sm:flex-row`
- Button now full width on mobile, auto on desktop
**Result:** Better mobile UX, readable spacing ✅
---
## Issue 4: Missing "Go to WP Admin" Link ✅
**Added:**
- New button in More page (wp-admin modes only)
- Positioned before Exit Fullscreen/Logout
- Uses `ExternalLink` icon
- Links to `/wp-admin/`
---
## Issue 5: Customer Settings 403 Error ⚠️
**Status:** Backend ready, needs testing
- `CustomerSettingsProvider.php` exists and is autoloaded
- REST endpoints registered in `StoreController.php`
- Permission callback uses `manage_woocommerce`
**Next:** Test endpoint directly to verify
---
## Issue 6: Dark Mode Logo Support ✅
**Added:**
- New field: `store_logo_dark`
- Stored in: `woonoow_store_logo_dark` option
- Added to `StoreSettingsProvider.php`:
- `get_settings()` - Returns dark logo
- `save_settings()` - Saves dark logo
**Frontend:** Ready for implementation (use `useTheme()` to switch)
---
## Issue 7: Consistent Dark Background ✅
**Problem:** Login and Dashboard use different dark backgrounds
- Login: `dark:from-gray-900 dark:to-gray-800` (pure gray)
- Dashboard: `--background: 222.2 84% 4.9%` (dark blue-gray)
**Solution:** Use design system variables consistently
**Fixed:**
- `Login.tsx` - Changed to `dark:from-background dark:to-background`
- Card background: `dark:bg-card` instead of `dark:bg-gray-800`
**Result:** Consistent dark mode across all screens ✅
---
## Summary
✅ **Fixed 6 issues:**
1. Submenu visibility in all modes
2. Standalone title logic
3. Mobile card header density
4. WP Admin link in More page
5. Dark mode logo backend support
6. Consistent dark background colors
⚠️ **Needs Testing:**
- Customer Settings 403 error (backend ready, verify endpoint)
**Files Modified:**
- `DashboardSubmenuBar.tsx`
- `SubmenuBar.tsx`
- `StandaloneAdmin.php`
- `SettingsCard.tsx`
- `More/index.tsx`
- `StoreSettingsProvider.php`
- `Login.tsx`
**All UI/UX polish complete!** 🎨
## 1. Fix Dark Mode Headings ✅
**Issue:** h1-h6 headings not changing color in dark mode
**Fix:**
```css
h1, h2, h3, h4, h5, h6 { @apply text-foreground; }
```
**Result:** All headings now use foreground color (adapts to theme)
---
## 2. Fix Settings Default Route ✅
**Issue:** Main Settings menu goes to /settings with placeholder page
**Fix:**
- Changed /settings to redirect to /settings/store
- Store Details is now the default settings page
- No more placeholder "Settings interface coming soon"
**Code:**
```tsx
useEffect(() => {
navigate('/settings/store', { replace: true });
}, [navigate]);
```
---
## 3. Fix "Cookie check failed" Upload Error ✅
**Issue:** Image upload failing with "Cookie check failed"
**Root Cause:** WordPress REST API nonce not available
**Fix:**
- Added `wpApiSettings` to both dev and prod modes
- Provides `root` and `nonce` for WordPress REST API
- Image upload component already checks multiple nonce sources
**Backend Changes:**
```php
// Dev mode
wp_localize_script($handle, 'wpApiSettings', [
'root' => esc_url_raw(rest_url()),
'nonce' => wp_create_nonce('wp_rest'),
]);
// Prod mode (same)
```
**Result:** Image upload now works with proper authentication
---
## 4. Add Theme Toggle to Mobile ✅
**Recommendation:** Yes, mobile should have theme toggle
**Implementation:** Added to More page (mobile hub)
**UI:**
- 3-column grid with theme cards
- ☀️ Light | 🌙 Dark | 🖥️ System
- Active theme highlighted with primary border
- Placed under "Appearance" section
**Location:**
```
More Page
├── Coupons
├── Settings
├── Appearance (NEW)
│ ├── ☀️ Light
│ ├── 🌙 Dark
│ └── 🖥️ System
└── Exit Fullscreen / Logout
```
**Why More page?**
- Mobile users go there for additional options
- Natural place for appearance settings
- Doesn't clutter main navigation
- Desktop has header toggle, mobile has More page
---
## Summary
✅ **Dark mode headings** - Fixed with text-foreground
✅ **Settings redirect** - /settings → /settings/store
✅ **Upload nonce** - wpApiSettings added (dev + prod)
✅ **Mobile theme toggle** - Added to More page with 3-card grid
**All issues resolved!** 🎉
**Note:** CSS lint warnings (@tailwind, @apply) are false positives - Tailwind directives are valid.