fix: PHP errors and clean up error_log statements

- Fixed redirect_wc_pages_to_spa: added spa_mode check (only redirect when 'full')
- Fixed PHP fatal error: use get_queried_object() instead of global $product
- Removed all error_log debug statements from codebase
- Fixed broken syntax in PaymentGatewaysProvider.php after error_log removal
This commit is contained in:
Dwindi Ramadhana
2026-01-04 10:49:47 +07:00
parent 75a82cf16c
commit 670bd7d351
12 changed files with 11 additions and 73 deletions

View File

@@ -58,7 +58,6 @@ class Installer {
$wc_page_id = get_option($page_data['wc_option']);
if ($wc_page_id && get_post($wc_page_id)) {
$page_id = $wc_page_id;
error_log("WooNooW: Found existing WooCommerce {$page_data['title']} page (ID: {$page_id})");
}
}
@@ -67,7 +66,6 @@ class Installer {
$woonoow_page_id = get_option('woonoow_' . $key . '_page_id');
if ($woonoow_page_id && get_post($woonoow_page_id)) {
$page_id = $woonoow_page_id;
error_log("WooNooW: Found existing WooNooW {$page_data['title']} page (ID: {$page_id})");
}
}
@@ -76,7 +74,6 @@ class Installer {
$existing_page = get_page_by_title($page_data['title'], OBJECT, 'page');
if ($existing_page) {
$page_id = $existing_page->ID;
error_log("WooNooW: Found existing {$page_data['title']} page by title (ID: {$page_id})");
}
}
@@ -95,9 +92,7 @@ class Installer {
'post_content' => $page_data['content'],
]);
error_log("WooNooW: Updated {$page_data['title']} page with WooNooW shortcode");
} else {
error_log("WooNooW: {$page_data['title']} page already has WooNooW shortcode");
}
} else {
// No existing page found, create new one
@@ -111,7 +106,6 @@ class Installer {
]);
if ($page_id && !is_wp_error($page_id)) {
error_log("WooNooW: Created new {$page_data['title']} page (ID: {$page_id})");
}
}
@@ -162,7 +156,6 @@ class Installer {
// Remove backup
delete_post_meta($page_id, '_woonoow_original_content');
error_log("WooNooW: Restored original content for page ID: {$page_id}");
}
}
}

View File

@@ -119,7 +119,6 @@ class EmailManager {
*/
public function send_order_processing_email($order_id, $order = null) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] send_order_processing_email triggered for order #' . $order_id);
}
if (!$order) {
@@ -128,7 +127,6 @@ class EmailManager {
if (!$order) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Order not found for ID: ' . $order_id);
}
return;
}
@@ -136,13 +134,11 @@ class EmailManager {
// Check if event is enabled
if (!$this->is_event_enabled('order_processing', 'email', 'customer')) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] order_processing email is disabled in settings');
}
return;
}
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Sending order_processing email for order #' . $order_id);
}
// Send email
@@ -397,7 +393,6 @@ class EmailManager {
if (!$email) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Password reset email rendering failed for user: ' . $user->user_login);
}
return;
}
@@ -411,7 +406,6 @@ class EmailManager {
$sent = wp_mail($email['to'], $email['subject'], $email['body'], $headers);
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Password reset email sent to ' . $email['to'] . ' - Result: ' . ($sent ? 'success' : 'failed'));
}
// Log email sent
@@ -484,7 +478,6 @@ class EmailManager {
// This allows the plugin to work out-of-the-box with default templates
if ($channel_id === 'email') {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Event not configured, using default: enabled');
}
return true; // Enable by default
}
@@ -502,7 +495,6 @@ class EmailManager {
*/
private function send_email($event_id, $recipient_type, $data, $extra_data = []) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] send_email called - Event: ' . $event_id . ', Recipient: ' . $recipient_type);
}
// Get email renderer
@@ -513,13 +505,11 @@ class EmailManager {
if (!$email) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Email rendering failed for event: ' . $event_id);
}
return;
}
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] Email rendered successfully - To: ' . $email['to'] . ', Subject: ' . $email['subject']);
}
// Send email via wp_mail
@@ -531,7 +521,6 @@ class EmailManager {
$sent = wp_mail($email['to'], $email['subject'], $email['body'], $headers);
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailManager] wp_mail called - Result: ' . ($sent ? 'success' : 'failed'));
}
// Log email sent

View File

@@ -86,13 +86,11 @@ class EmailRenderer {
if (!$template) {
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailRenderer] No template found for event: ' . $event_id . ', recipient: ' . $recipient_type);
}
return null;
}
if (defined('WP_DEBUG') && WP_DEBUG) {
error_log('[EmailRenderer] Template found - Subject: ' . ($template['subject'] ?? 'no subject'));
}
// Get design template preference

View File

@@ -229,7 +229,6 @@ class PushNotificationHandler {
self::queue_notification($subscription_id, $payload);
$sent++;
} catch (\Exception $e) {
error_log('Push notification error: ' . $e->getMessage());
}
}