PluginProbe
WebberZone Top 10 — Popular Posts / 4.5.2
WebberZone Top 10 — Popular Posts v4.5.2
4.5.2 4.5.1 4.5.0 4.4.3 4.4.2 4.4.1 4.4.0 4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 trunk 1.0 1.0.1 1.1 1.2 1.3 1.4 1.4.1 1.5 1.5.1 1.5.2 1.5.3 1.6 All 118 releases
← All changes | includes/util/class-csv-helper.php +6 -14 4.3.4 → 4.5.2 View file →
@@ -25,14 +25,11 @@
25 25
26 26 /**
27 27 * Write count rows to an open file handle in the Top 10 CSV format.
28 28 *
29 - * Writes UTF-8 BOM (for Excel compatibility), a header row, then one
30 - * data row per result. The positional column layout is:
29 + * Column layout: Overall = Post ID, Visits, Blog ID[, URL]. Daily = Post ID, Visits,
30 + * Date, Blog ID[, URL].
31 31 *
32 - * Overall: Post ID, Visits, Blog ID[, URL]
33 - * Daily: Post ID, Visits, Date, Blog ID[, URL]
34 - *
35 32 * @since 4.3.0
36 33 *
37 34 * @param resource $fh Open file handle (writable).
38 35 * @param array $rows Result rows from the database. Each row
@@ -84,16 +81,11 @@
84 81
85 82 /**
86 83 * Parse an import CSV file and return structured rows.
87 84 *
88 - * Strips any UTF-8 BOM from the beginning of the file, reads the header
89 - * to auto-detect whether the file targets the overall or daily table
90 - * (by the presence of a "Date" column), then returns every data row in
91 - * a canonical associative format.
85 + * Auto-detects overall vs. daily table by the presence of a "Date" column. Caller
86 + * handles URL resolution, date normalisation, blog filtering, and database writes.
92 87 *
93 - * The caller is responsible for URL resolution, date normalisation,
94 - * blog filtering, and database writes.
95 - *
96 88 * @since 4.3.0
97 89 *
98 90 * @param string $file_path Path to the CSV file.
99 91 * @return array An associative array with the keys:
@@ -157,12 +149,12 @@
157 149 'blog_id' => isset( $line[ $col_blog_id ] ) ? absint( $line[ $col_blog_id ] ) : get_current_blog_id(),
158 150 );
159 151
160 152 if ( $daily ) {
161 - $row['dp_date'] = isset( $line[ $col_date ] ) ? trim( $line[ $col_date ] ) : '';
153 + $row['dp_date'] = isset( $line[ $col_date ] ) ? trim( $line[ $col_date ], " \t\n\r\0\x0B" ) : '';
162 154 }
163 155 if ( $has_url && isset( $line[ $col_url ] ) ) {
164 - $row['url'] = trim( $line[ $col_url ] );
156 + $row['url'] = trim( $line[ $col_url ], " \t\n\r\0\x0B" );
165 157 }
166 158
167 159 $rows[] = $row;
168 160 ++$total;