#!/bin/bash # Script to remove or comment out debug error_log statements for production echo "=== Removing Debug Logs for Production ===" echo "Date: $(date)" echo # Files to process FILES=( "includes/class-hvac-registration.php" "includes/class-hvac-community-events.php" "includes/admin/class-zoho-admin.php" ) # Backup directory BACKUP_DIR="debug-log-backups" mkdir -p "$BACKUP_DIR" for file in "${FILES[@]}"; do if [ -f "$file" ]; then echo "Processing: $file" # Create backup cp "$file" "$BACKUP_DIR/$(basename $file).backup" # Comment out error_log lines with HVAC DEBUG or similar patterns sed -i '' 's/^[[:space:]]*error_log.*\[HVAC/\/\/ &/' "$file" sed -i '' 's/^[[:space:]]*error_log.*Adding hvac_oauth/\/\/ &/' "$file" sed -i '' 's/^[[:space:]]*error_log.*Current vars count:/\/\/ &/' "$file" # Count changes CHANGED=$(diff "$BACKUP_DIR/$(basename $file).backup" "$file" | grep "^>" | wc -l) echo " - Commented out $CHANGED debug log lines" else echo "Warning: $file not found" fi done echo echo "✅ Debug logs removed/commented out" echo "Backups saved in: $BACKUP_DIR/" echo echo "To restore:" echo " cp $BACKUP_DIR/*.backup includes/"