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/Exporter/File/JSONFile.php +17 -0 2.7.12.15.0 View file →
@@ -9,8 +9,9 @@
9 9 'open' => '{' . PHP_EOL,
10 10 'close' => PHP_EOL . '}',
11 11 'parent' => 0
12 12 ];
13 + private $setup = false;
13 14
14 15 public function start()
15 16 {
16 17 // write headers
@@ -29,10 +30,23 @@
29 30 }
30 31
31 32 fputs($this->fh, $this->parts['open'] . PHP_EOL);
32 33 $this->counter = 0;
34 +
35 + update_option('iwp_exporter_json_config', [
36 + 'parts' => $this->parts
37 + ]);
33 38 }
34 39
40 + public function loadConfig()
41 + {
42 + if (!$this->setup) {
43 + $config = get_option('iwp_exporter_json_config', []);
44 + $this->parts = $config['parts'];
45 + $this->setup = true;
46 + }
47 + }
48 +
35 49 public function generate_wrapper($fields, $output = [], $parent = 0, $depth = 0)
36 50 {
37 51
38 52 $current_items = array_filter($fields, function ($item) use ($parent) {
@@ -58,8 +72,9 @@
58 72 }
59 73
60 74 public function add($mapper)
61 75 {
76 + $this->loadConfig();
62 77
63 78 // $data = array_map(function($value){
64 79 // if(is_array($value)){
65 80 // $value = implode('|', $value);
@@ -77,8 +92,10 @@
77 92 }
78 93
79 94 public function end()
80 95 {
96 + $this->loadConfig();
97 +
81 98 fputs($this->fh, PHP_EOL . $this->parts['close']);
82 99 fclose($this->fh);
83 100 }
84 101