PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.0
Import WP – CSV & XML Import Export for WordPress v2.15.0
2.15.1 2.15.0 2.14.24 2.14.23 2.7.0 2.7.1 2.7.10 2.7.11 2.7.12 2.7.13 2.7.14 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 2.7.8 2.7.9 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 2.9.1 All 144 releases
← All changes | class/Common/Importer/Preview/CSVPreview.php +15 -4 2.7.12 → 2.15.0 View file →
@@ -21,9 +21,9 @@
21 21 */
22 22 public function __construct(CSVFile $file, $args = array())
23 23 {
24 24 $this->file = $file;
25 - $this->file->processing(true);
25 + // Do not enable processing mode — preview navigation needs the full record index.
26 26 }
27 27
28 28 /**
29 29 * Generate a return a table based on the CSV data being previewed.
@@ -59,20 +59,31 @@
59 59
60 60 public function data($record_index = 0, $show_headings = true)
61 61 {
62 62 $result = [];
63 - $headings = str_getcsv($this->file->getRecord(0), $this->file->getDelimiter(), $this->file->getEnclosure());
63 + $headings = str_getcsv($this->file->getRecord(0), $this->file->getDelimiter(), $this->file->getEnclosure(), $this->file->getEscape());
64 + $count = $this->file->getRecordCount();
65 + $total = true === $show_headings ? max(0, $count - 1) : $count;
66 + $record_index = max(0, intval($record_index));
67 + if ($total > 0) {
68 + $record_index = min($record_index, $total - 1);
69 + } else {
70 + $record_index = 0;
71 + }
64 72
65 73 if (true === $show_headings) {
66 74 $result['headings'] = $headings;
67 - $record_index++;
75 + $file_index = $record_index + 1;
68 76 } else {
69 77 $result['headings'] = [];
70 78 for ($i = 0; $i < count($headings); $i++) {
71 79 $result['headings'][] = $i;
72 80 }
81 + $file_index = $record_index;
73 82 }
74 83
75 - $result['row'] = str_getcsv($this->file->getRecord($record_index), $this->file->getDelimiter(), $this->file->getEnclosure());
84 + $result['row'] = str_getcsv($this->file->getRecord($file_index), $this->file->getDelimiter(), $this->file->getEnclosure(), $this->file->getEscape());
85 + $result['record'] = $record_index;
86 + $result['total'] = $total;
76 87 return $result;
77 88 }
78 89 }