From a2717d56d9f87a7f833cc5d9cfac198d74edf19e Mon Sep 17 00:00:00 2001 From: dwindown Date: Thu, 28 May 2026 10:23:37 +0700 Subject: [PATCH] Fix CSV header whitespace causing exact match to fail Trim CSV headers and row values in fetch_remote_csv_data() to prevent whitespace in column names (e.g. "OTP ") from breaking the validation lookup against sanitized field config keys. --- includes/class-Shortcode.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-Shortcode.php b/includes/class-Shortcode.php index 1a19dc0..d627dbb 100644 --- a/includes/class-Shortcode.php +++ b/includes/class-Shortcode.php @@ -529,8 +529,8 @@ class CHECKER_SHORTCODE extends SHEET_DATA_CHECKER_PRO return $data; } - // Get headers from first line - $keys = str_getcsv($lines[0], $delimiter); + // Get headers from first line (trim to handle whitespace in column names) + $keys = array_map('trim', str_getcsv($lines[0], $delimiter)); // Process data rows $count = 0; @@ -539,7 +539,7 @@ class CHECKER_SHORTCODE extends SHEET_DATA_CHECKER_PRO continue; // Skip empty lines } - $row = str_getcsv($lines[$i], $delimiter); + $row = array_map('trim', str_getcsv($lines[$i], $delimiter)); if (count($keys) === count($row)) { $data[] = array_combine($keys, $row); $count++;