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/Model/ImporterModel.php +39 -3 2.14.23 → 2.15.2 View file →
@@ -1,8 +1,9 @@
1 1 <?php
2 2
3 3 namespace ImportWP\Common\Model;
4 4
5 +use ImportWP\Common\Filesystem\Filesystem;
5 6 use ImportWP\Common\Util\Logger;
6 7
7 8 class ImporterModel
8 9 {
@@ -344,9 +345,9 @@
344 345 public function getAllowedFileTypes()
345 346 {
346 347
347 348 $parser = $this->getParser();
348 - $allowed_file_types = apply_filters('iwp/importer/datasource/allowed_file_types', ['xml', 'csv'], $this);
349 + $allowed_file_types = apply_filters('iwp/importer/datasource/allowed_file_types', ['xml', 'csv', 'json'], $this);
349 350
350 351 if (!is_null($parser)) {
351 352 $allowed_file_types = [$parser];
352 353 }
@@ -392,8 +393,14 @@
392 393 'base_path' => null,
393 394 'setup' => false
394 395 ];
395 396 break;
397 + case 'json':
398 + return [
399 + 'base_path' => null,
400 + 'setup' => false
401 + ];
402 + break;
396 403 case 'csv':
397 404 return [
398 405 'enclosure' => '"',
399 406 'delimiter' => ',',
@@ -484,11 +491,20 @@
484 491 foreach ($results as $result) {
485 492 $key = $result['meta_key'];
486 493 $id = intval(str_replace('_importer_file_', '', $key));
487 494 $value = $result['meta_value'];
488 - if (file_exists($value)) {
489 - $files[$id] = $value;
495 + $resolved = Filesystem::resolve_importer_file_path($value);
496 + if (!$resolved) {
497 + continue;
490 498 }
499 +
500 + $files[$id] = $resolved;
501 +
502 + // Soft-migrate legacy absolute paths to uploads-relative storage.
503 + $relative = Filesystem::to_uploads_relative_path($resolved);
504 + if ($relative !== '' && $relative !== $value) {
505 + update_post_meta($this->getId(), $key, $relative);
506 + }
491 507 }
492 508
493 509 return $files;
494 510 }
@@ -603,8 +619,28 @@
603 619
604 620 public function setMap($key, $value)
605 621 {
606 622 $this->map[$key] = $value;
623 + }
624 +
625 + /**
626 + * Replace the entire field map (skips null values from deleted repeater rows).
627 + *
628 + * @param array $map
629 + */
630 + public function replaceMap($map)
631 + {
632 + $this->map = [];
633 + if (!is_array($map)) {
634 + return;
635 + }
636 +
637 + foreach ($map as $key => $value) {
638 + if ($value === null) {
639 + continue;
640 + }
641 + $this->map[$key] = $value;
642 + }
607 643 }
608 644
609 645 public function getEnabled()
610 646 {