fix: Admin SPA loading and remove MailQueue debug logs
Problem 1: Admin SPA not loading in production Root Cause: Vite builds require type='module' attribute on script tags Solution: Added script_loader_tag filter to add type='module' to admin SPA script Problem 2: Annoying MailQueue debug logs in console Solution: Removed all error_log statements from MailQueue class - Removed init() debug log - Removed enqueue() debug log - Removed all sendNow() debug logs (was 10+ lines) - Kept only essential one-line log after successful send Changes: - includes/Admin/Assets.php: Add type='module' to wnw-admin script - includes/Core/Mail/MailQueue.php: Remove debug logging noise Result: ✅ Admin SPA now loads with proper ES module support ✅ MailQueue logs removed from console ✅ Email functionality still works (kept minimal logging) Note: Production zip is 21M (includes .vite manifests and dynamic imports)
This commit is contained in:
@@ -176,6 +176,15 @@ class Assets {
|
||||
|
||||
if (file_exists($dist_dir . $js)) {
|
||||
wp_enqueue_script('wnw-admin', $base_url . $js, ['wp-element'], $ver_js, true);
|
||||
|
||||
// Add type="module" attribute for Vite build
|
||||
add_filter('script_loader_tag', function($tag, $handle, $src) {
|
||||
if ($handle === 'wnw-admin') {
|
||||
$tag = str_replace('<script ', '<script type="module" ', $tag);
|
||||
}
|
||||
return $tag;
|
||||
}, 10, 3);
|
||||
|
||||
self::localize_runtime('wnw-admin');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user