Files
WooNooW/includes/Core/Mail/WooEmailOverride.php
dwindown 232059e928 feat: Complete Dashboard API Integration with Analytics Controller
 Features:
- Implemented API integration for all 7 dashboard pages
- Added Analytics REST API controller with 7 endpoints
- Full loading and error states with retry functionality
- Seamless dummy data toggle for development

📊 Dashboard Pages:
- Customers Analytics (complete)
- Revenue Analytics (complete)
- Orders Analytics (complete)
- Products Analytics (complete)
- Coupons Analytics (complete)
- Taxes Analytics (complete)
- Dashboard Overview (complete)

🔌 Backend:
- Created AnalyticsController.php with REST endpoints
- All endpoints return 501 (Not Implemented) for now
- Ready for HPOS-based implementation
- Proper permission checks

🎨 Frontend:
- useAnalytics hook for data fetching
- React Query caching
- ErrorCard with retry functionality
- TypeScript type safety
- Zero build errors

📝 Documentation:
- DASHBOARD_API_IMPLEMENTATION.md guide
- Backend implementation roadmap
- Testing strategy

🔧 Build:
- All pages compile successfully
- Production-ready with dummy data fallback
- Zero TypeScript errors
2025-11-04 11:19:00 +07:00

51 lines
1.4 KiB
PHP

<?php
namespace WooNooW\Core\Mail;
/**
* Intercepts wp_mail() calls and queues them asynchronously via Action Scheduler.
* This prevents blocking operations (SMTP, DNS lookups) from slowing down API responses.
*/
class WooEmailOverride {
private static $enabled = true;
public static function init() {
// Hook into wp_mail before it's sent
add_filter('pre_wp_mail', [__CLASS__, 'interceptMail'], 10, 2);
}
/**
* Intercept wp_mail() and queue it asynchronously.
* Return non-null to short-circuit wp_mail().
*/
public static function interceptMail($null, $atts) {
if (!self::$enabled) {
return $null; // Allow normal wp_mail if disabled
}
// Queue the email asynchronously
MailQueue::enqueue([
'to' => $atts['to'] ?? '',
'subject' => $atts['subject'] ?? '',
'html' => $atts['message'] ?? '',
'headers' => $atts['headers'] ?? [],
'attachments' => $atts['attachments'] ?? [],
]);
// Return true to indicate success and prevent wp_mail from running
return true;
}
/**
* Temporarily disable async mail (for testing or critical emails).
*/
public static function disable() {
self::$enabled = false;
}
/**
* Re-enable async mail.
*/
public static function enable() {
self::$enabled = true;
}
}