fix: Single source nav + dark logo support + customer settings debug

##  Issue 1: Single Source of Truth for Navigation
**Problem:** Confusing dual nav sources (PHP + TypeScript fallback)
**Solution:** Removed static TypeScript fallback tree
**Result:** PHP NavigationRegistry is now the ONLY source
- More flexible (can check WooCommerce settings, extend via addons)
- Easier to maintain
- Clear error if backend data missing

##  Issue 2: Logo in All Modes
**Already Working:** Header component renders in all modes
- Standalone 
- WP-Admin normal 
- WP-Admin fullscreen 

##  Issue 5: Customer Settings 404 Debug
**Added:** Debug logging to track endpoint calls
**Note:** Routes are correctly registered
- May need WordPress permalinks flush
- Check debug.log for errors

##  Issue 6: Dark Mode Logo Support
**Implemented:**
1. **Backend:**
   - Added `store_logo_dark` to branding endpoint
   - Returns both light and dark logos

2. **Header Component:**
   - Detects dark mode via MutationObserver
   - Switches logo based on theme
   - Falls back to light logo if dark not set

3. **Login Screen:**
   - Same dark mode detection
   - Theme-aware logo display
   - Seamless theme switching

4. **SVG Support:**
   - Already supported via `accept="image/*"`
   - Works for all image formats

**Result:** Perfect dark/light logo switching everywhere! 🌓

---

## Files Modified:
- `nav/tree.ts` - Removed static fallback
- `App.tsx` - Dark logo in header
- `Login.tsx` - Dark logo in login
- `StoreController.php` - Dark logo in branding endpoint + debug logs
- `Store.tsx` - Already has dark logo upload field
- `StoreSettingsProvider.php` - Already has dark logo backend

## Testing:
1. Upload dark logo in Store settings
2. Switch theme - logo should change
3. Check customer-settings endpoint in browser console
4. Verify nav items from PHP only
This commit is contained in:
dwindown
2025-11-11 10:12:30 +07:00
parent 9c5bdebf6f
commit 432d84992c
4 changed files with 64 additions and 100 deletions

View File

@@ -114,8 +114,9 @@ class StoreController extends WP_REST_Controller {
*/
public function get_branding(WP_REST_Request $request) {
$branding = [
'store_name' => get_option('blogname', 'WooNooW'),
'store_name' => get_option('woonoow_store_name', '') ?: get_option('blogname', 'WooNooW'),
'store_logo' => get_option('woonoow_store_logo', ''),
'store_logo_dark' => get_option('woonoow_store_logo_dark', ''),
'store_icon' => get_option('woonoow_store_icon', ''),
'store_tagline' => get_option('woonoow_store_tagline', ''),
];
@@ -267,14 +268,17 @@ class StoreController extends WP_REST_Controller {
* @return WP_REST_Response|WP_Error Response object or error
*/
public function get_customer_settings(WP_REST_Request $request) {
error_log('WooNooW: get_customer_settings called');
try {
$settings = CustomerSettingsProvider::get_settings();
error_log('WooNooW: Customer settings retrieved: ' . print_r($settings, true));
$response = rest_ensure_response($settings);
$response->header('Cache-Control', 'max-age=60');
return $response;
} catch (\Exception $e) {
error_log('WooNooW: get_customer_settings exception: ' . $e->getMessage());
return new WP_Error(
'get_customer_settings_failed',
$e->getMessage(),