fix: Force production mode for admin SPA assets
🐛 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
This commit is contained in:
170
MARKDOWN_SYNTAX_AND_VARIABLES.md
Normal file
170
MARKDOWN_SYNTAX_AND_VARIABLES.md
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
# Markdown Syntax & Variables - Analysis & Recommendations
|
||||||
|
|
||||||
|
## Current Issues
|
||||||
|
|
||||||
|
### 1. Card & Button Syntax
|
||||||
|
**Current:**
|
||||||
|
```markdown
|
||||||
|
[card type="hero"]
|
||||||
|
Content here
|
||||||
|
[/card]
|
||||||
|
|
||||||
|
[button url="https://example.com" style="solid"]Click me[/button]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Problem:** Not standard Markdown - uses WordPress-style shortcodes
|
||||||
|
|
||||||
|
### 2. Variable Naming Mismatch
|
||||||
|
**Template uses:** `{order_item_table}` (singular)
|
||||||
|
**Preview defines:** `order_items_table` (plural)
|
||||||
|
**Result:** Variable not replaced, shows as `{orderitemtable}` (underscores removed by some HTML sanitizer)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## All Variables Used in Templates
|
||||||
|
|
||||||
|
### Order Variables
|
||||||
|
- `{order_number}` - Order ID
|
||||||
|
- `{order_date}` - Order date
|
||||||
|
- `{order_total}` - Total amount
|
||||||
|
- `{order_status}` - Current status
|
||||||
|
- `{order_url}` - Link to view order
|
||||||
|
- `{order_item_table}` ⚠️ **MISMATCH** - Should be `order_items_table`
|
||||||
|
|
||||||
|
### Customer Variables
|
||||||
|
- `{customer_name}` - Customer full name
|
||||||
|
- `{customer_email}` - Customer email
|
||||||
|
- `{customer_username}` - Username (for new accounts)
|
||||||
|
- `{customer_password}` - Temporary password (for new accounts)
|
||||||
|
|
||||||
|
### Store Variables
|
||||||
|
- `{store_name}` - Store name
|
||||||
|
- `{store_url}` - Store URL
|
||||||
|
- `{store_email}` - Store contact email
|
||||||
|
|
||||||
|
### Payment Variables
|
||||||
|
- `{payment_method}` - Payment method used
|
||||||
|
- `{payment_status}` - Payment status
|
||||||
|
- `{transaction_id}` - Transaction ID
|
||||||
|
|
||||||
|
### Shipping Variables
|
||||||
|
- `{shipping_address}` - Full shipping address
|
||||||
|
- `{tracking_number}` - Shipment tracking number
|
||||||
|
- `{carrier}` - Shipping carrier
|
||||||
|
|
||||||
|
### Date Variables
|
||||||
|
- `{completion_date}` - Order completion date
|
||||||
|
- `{cancellation_date}` - Order cancellation date
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Recommendations
|
||||||
|
|
||||||
|
### Option 1: Keep Current Syntax (Easiest)
|
||||||
|
**Pros:**
|
||||||
|
- No changes needed
|
||||||
|
- Users already familiar
|
||||||
|
- Clear boundaries for cards
|
||||||
|
|
||||||
|
**Cons:**
|
||||||
|
- Not standard Markdown
|
||||||
|
- Verbose
|
||||||
|
|
||||||
|
**Action:** Just fix the variable mismatch
|
||||||
|
|
||||||
|
### Option 2: Simplified Shortcode
|
||||||
|
```markdown
|
||||||
|
[card:hero]
|
||||||
|
Content here
|
||||||
|
[/card]
|
||||||
|
|
||||||
|
[button:solid](https://example.com)Click me[/button]
|
||||||
|
```
|
||||||
|
|
||||||
|
**Pros:**
|
||||||
|
- Shorter, cleaner
|
||||||
|
- Still clear
|
||||||
|
|
||||||
|
**Cons:**
|
||||||
|
- Still not standard Markdown
|
||||||
|
- Requires converter changes
|
||||||
|
|
||||||
|
### Option 3: HTML + Markdown (Hybrid)
|
||||||
|
```html
|
||||||
|
<div class="card card-hero">
|
||||||
|
|
||||||
|
**Content** with markdown
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<a href="url" class="button">Click me</a>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Pros:**
|
||||||
|
- Standard Markdown allows inline HTML
|
||||||
|
- No custom parsing needed
|
||||||
|
|
||||||
|
**Cons:**
|
||||||
|
- Verbose
|
||||||
|
- Less user-friendly
|
||||||
|
|
||||||
|
### Option 4: Attributes Syntax (Most Markdown-like)
|
||||||
|
```markdown
|
||||||
|
> **Order Number:** #{order_number}
|
||||||
|
> **Order Date:** {order_date}
|
||||||
|
{: .card .card-hero}
|
||||||
|
|
||||||
|
[Click me](https://example.com){: .button .button-solid}
|
||||||
|
```
|
||||||
|
|
||||||
|
**Pros:**
|
||||||
|
- More Markdown-like
|
||||||
|
- Compact
|
||||||
|
|
||||||
|
**Cons:**
|
||||||
|
- Complex to parse
|
||||||
|
- Not widely supported
|
||||||
|
- Users may not understand
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Recommended Action Plan
|
||||||
|
|
||||||
|
### Immediate Fixes (Priority 1)
|
||||||
|
1. ✅ **Fix `<br>` rendering** - DONE!
|
||||||
|
2. ⚠️ **Fix variable mismatch:**
|
||||||
|
- Change `order_item_table` → `order_items_table` in DefaultTemplates.php
|
||||||
|
- OR change `order_items_table` → `order_item_table` in EditTemplate.tsx preview
|
||||||
|
3. **Add all missing variables to preview sample data**
|
||||||
|
|
||||||
|
### Short-term (Priority 2)
|
||||||
|
1. **Document all variables** - Create user-facing documentation
|
||||||
|
2. **Add variable autocomplete** in markdown editor
|
||||||
|
3. **Add variable validation** - warn if variable doesn't exist
|
||||||
|
|
||||||
|
### Long-term (Priority 3)
|
||||||
|
1. **Consider syntax improvements** - Get user feedback first
|
||||||
|
2. **Add visual card/button inserter** - UI buttons to insert syntax
|
||||||
|
3. **Add syntax highlighting** in markdown editor
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Variable Replacement Issue
|
||||||
|
|
||||||
|
The underscore removal (`{order_item_table}` → `{orderitemtable}`) suggests HTML sanitization is happening somewhere. Need to check:
|
||||||
|
|
||||||
|
1. **Frontend:** DOMPurify or similar sanitizer?
|
||||||
|
2. **Backend:** WordPress `wp_kses()` or similar?
|
||||||
|
3. **Email client:** Some email clients strip underscores?
|
||||||
|
|
||||||
|
**Solution:** Use consistent naming without underscores OR fix sanitizer to preserve variable syntax.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Next Steps
|
||||||
|
|
||||||
|
1. Fix variable naming mismatch
|
||||||
|
2. Test all variables in preview
|
||||||
|
3. Document syntax for users
|
||||||
|
4. Get feedback on syntax preferences
|
||||||
|
5. Consider improvements based on feedback
|
||||||
26
PHASE_COMPLETE.md
Normal file
26
PHASE_COMPLETE.md
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
# Phase Complete ✅
|
||||||
|
|
||||||
|
**Date:** November 15, 2025
|
||||||
|
|
||||||
|
## Completed
|
||||||
|
|
||||||
|
### 1. Email Queue ✅
|
||||||
|
- Already implemented via MailQueue + WooEmailOverride
|
||||||
|
- Prevents 30s timeout
|
||||||
|
|
||||||
|
### 2. Documentation ✅
|
||||||
|
- Reduced 56 → 27 files (52% reduction)
|
||||||
|
- Created NOTIFICATION_SYSTEM.md (consolidated)
|
||||||
|
- Deleted 30 obsolete docs
|
||||||
|
|
||||||
|
### 3. Git Push ✅
|
||||||
|
- 3 commits pushed to main
|
||||||
|
- Remote: git.backoffice.biz.id
|
||||||
|
|
||||||
|
### 4. Plugin Zip ✅
|
||||||
|
- File: woonoow.zip
|
||||||
|
- Size: 1.4MB
|
||||||
|
- Location: /wp-content/plugins/woonoow.zip
|
||||||
|
- Guide: PLUGIN_ZIP_GUIDE.md
|
||||||
|
|
||||||
|
## Ready for Distribution! 🚀
|
||||||
@@ -225,20 +225,21 @@ class Assets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Determine dev mode:
|
/** Determine dev mode:
|
||||||
* - WP environment 'development'
|
* - ONLY enabled if constant WOONOOW_ADMIN_DEV=true is explicitly set
|
||||||
* - or constant WOONOOW_ADMIN_DEV=true
|
|
||||||
* - or filter override (woonoow/admin_is_dev)
|
* - or filter override (woonoow/admin_is_dev)
|
||||||
|
*
|
||||||
|
* Note: We don't check WP_ENV to avoid accidentally enabling dev mode
|
||||||
|
* in Local by Flywheel or other local dev environments.
|
||||||
*/
|
*/
|
||||||
private static function is_dev_mode(): bool {
|
private static function is_dev_mode(): bool {
|
||||||
$env_is_dev = function_exists('wp_get_environment_type') && wp_get_environment_type() === 'development';
|
// Only enable dev mode if explicitly set via constant
|
||||||
$const_dev = defined('WOONOOW_ADMIN_DEV') && WOONOOW_ADMIN_DEV === true;
|
$const_dev = defined('WOONOOW_ADMIN_DEV') && WOONOOW_ADMIN_DEV === true;
|
||||||
$is_dev = $env_is_dev || $const_dev;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter: force dev/prod mode for WooNooW admin assets.
|
* Filter: force dev/prod mode for WooNooW admin assets.
|
||||||
* Return true to use Vite dev server, false to use built assets.
|
* Return true to use Vite dev server, false to use built assets.
|
||||||
*/
|
*/
|
||||||
return (bool) apply_filters('woonoow/admin_is_dev', $is_dev);
|
return (bool) apply_filters('woonoow/admin_is_dev', $const_dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Dev server URL (filterable) */
|
/** Dev server URL (filterable) */
|
||||||
|
|||||||
Reference in New Issue
Block a user