PluginProbe
Import WP – CSV & XML Import Export for WordPress / 2.15.2
Import WP – CSV & XML Import Export for WordPress v2.15.2
2.15.2 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 All 145 releases
← All changes | class/Common/Filesystem/Filesystem.php +14 -2 2.14.24 → 2.15.2 View file →
@@ -126,8 +126,12 @@
126 126 } elseif ($filetype === 'csv') {
127 127 if (preg_match('/\.(csv|zip|gz)$/', $filename) === 0) {
128 128 $filename .= '.csv';
129 129 }
130 + } elseif ($filetype === 'json') {
131 + if (preg_match('/\.(json|zip|gz)$/', $filename) === 0) {
132 + $filename .= '.json';
133 + }
130 134 }
131 135
132 136 $dest = wp_unique_filename($wp_upload_dir['path'], $filename);
133 137 $wp_dest = $wp_upload_dir['path'] . '/' . $dest;
@@ -144,8 +148,11 @@
144 148 $headers['Accept'] = 'text/xml';
145 149 } elseif ($filetype === 'csv') {
146 150 $headers['Content-Type'] = 'text/csv';
147 151 $headers['Accept'] = 'text/csv';
152 + } elseif ($filetype === 'json') {
153 + $headers['Content-Type'] = 'application/json';
154 + $headers['Accept'] = 'application/json';
148 155 }
149 156
150 157 $result = $http->download_file_stream($remote_url, $wp_dest, $headers);
151 158 if (is_wp_error($result)) {
@@ -183,10 +190,10 @@
183 190
184 191 public function file_exists($src)
185 192 {
186 193 try {
187 - if (!file_exists($src)) {
188 - throw new \Exception(sprintf(__("File not found: %s", 'jc-importer'), $src));
194 + if (!is_string($src) || $src === '' || !file_exists($src)) {
195 + throw new \Exception(sprintf(__("File not found: %s", 'jc-importer'), is_string($src) ? $src : ''));
189 196 }
190 197
191 198 $size = filesize($src);
192 199 if ($size == 0) {
@@ -386,8 +393,11 @@
386 393 case 'text/xml':
387 394 case 'application/xml':
388 395 case 'application/x-xml':
389 396 return 'xml';
397 + case 'application/json':
398 + case 'text/json':
399 + return 'json';
390 400 }
391 401
392 402 return $this->event_handler->run('importer.allowed_mime_types', [false, $mime]);
393 403 }
@@ -415,8 +425,10 @@
415 425 if (stripos($file, '.csv')) {
416 426 $filetype = 'csv';
417 427 } elseif (stripos($file, '.xml')) {
418 428 $filetype = 'xml';
429 + } elseif (stripos($file, '.json')) {
430 + $filetype = 'json';
419 431 }
420 432
421 433 $filetype = apply_filters('iwp/get_filetype_from_ext', $filetype, $file);
422 434