Import any XML or CSV File to WordPress - Version 3.1.0

Version Description

  • Compatibility with WP 3.8
  • Compatibility with WPAI WooCommerce add-on (paid) 1.2.4
  • Performance Improvements
  • Improved UI
  • Lots of bug fixes
  • New Record Matching section
  • Added option to set Post Status with XPath (the value of presented XPath should be one of the following: publish, draft, trash)
  • Preview navigation
Download this release

Release Info

Developer soflyy
Plugin Icon 128x128 Import any XML or CSV File to WordPress
Version 3.1.0
Comparing to
See all releases

Code changes from version 3.0.4 to 3.1.0

Files changed (66) hide show
  1. actions/admin_init.php +1 -1
  2. actions/admin_menu.php +6 -5
  3. actions/admin_notices.php +20 -0
  4. actions/shutdown.php +0 -7
  5. actions/wp_loaded.php +3 -2
  6. classes/chunk.php +163 -354
  7. classes/helper.php +2 -2
  8. classes/session.php +1 -1
  9. config/options.php +4 -2
  10. controllers/admin/addons.php +100 -0
  11. controllers/admin/cron.php +12 -0
  12. controllers/admin/import.php +611 -479
  13. controllers/admin/manage.php +92 -142
  14. controllers/admin/settings.php +32 -3
  15. controllers/controller/admin.php +12 -3
  16. helpers/get_file_curl.php +5 -8
  17. helpers/is_exists_term.php +3 -19
  18. helpers/pmxi_findDuplicates.php +62 -0
  19. helpers/pmxi_functions.php +63 -84
  20. helpers/pmxi_insert_attachment.php +131 -0
  21. helpers/pmxi_insert_post.php +188 -0
  22. helpers/pmxi_recursion_taxes.php +63 -0
  23. helpers/reverse_taxonomies_html.php +33 -0
  24. helpers/wp_delete_attachments.php +22 -17
  25. libraries/XmlImportCsvParse.php +5 -63
  26. models/file/record.php +1 -1
  27. models/import/record.php +546 -572
  28. plugin.php +142 -46
  29. readme.txt +27 -15
  30. schema.php +6 -5
  31. static/css/admin-wp-3.8.css +13 -0
  32. static/css/admin.css +232 -24
  33. static/img/add-ons/acf-thumb.jpg +0 -0
  34. static/img/add-ons/woo-commerce-thumb.jpg +0 -0
  35. static/js/admin.js +409 -63
  36. static/js/jquery/css/select2/select2-bootstrap.css +87 -0
  37. static/js/jquery/css/select2/select2-spinner.gif +0 -0
  38. static/js/jquery/css/select2/select2.css +617 -0
  39. static/js/jquery/css/select2/select2.png +0 -0
  40. static/js/jquery/jquery.mjs.nestedSortable.js +1 -1
  41. static/js/jquery/select2.min.js +22 -0
  42. static/js/pmxi.js +1 -20
  43. views/admin/addons/index.php +115 -0
  44. views/admin/cron/index.php +2 -0
  45. views/admin/help/index.php +1 -1
  46. views/admin/import/element.php +107 -1
  47. views/admin/import/element_after.php +25 -11
  48. views/admin/import/evaluate.php +1 -1
  49. views/admin/import/evaluate_variations.php +2 -2
  50. views/admin/import/index.php +4 -13
  51. views/admin/import/options.php +206 -176
  52. views/admin/import/options/_buttons_template.php +6 -5
  53. views/admin/import/options/_custom_fields_template.php +37 -19
  54. views/admin/import/options/_featured_template.php +28 -23
  55. views/admin/import/options/_main_options_template.php +39 -8
  56. views/admin/import/options/_reimport_template.php +199 -111
  57. views/admin/import/options/_scheduling_template.php +4 -4
  58. views/admin/import/options/_settings_template.php +50 -31
  59. views/admin/import/options/_taxonomies_template.php +1 -1
  60. views/admin/import/preview.php +10 -1
  61. views/admin/import/process.php +100 -60
  62. views/admin/import/tag.php +5 -5
  63. views/admin/import/template.php +6 -4
  64. views/admin/manage/index.php +39 -7
  65. views/admin/manage/scheduling.php +48 -0
  66. views/admin/settings/index.php +4 -18
actions/admin_init.php CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
 
3
  function pmxi_admin_init(){
4
- wp_enqueue_script('pmxi-script', PMXI_ROOT_URL . '/static/js/pmxi.js', array('jquery'), PMXI_VERSION);
5
  }
1
  <?php
2
 
3
  function pmxi_admin_init(){
4
+ wp_enqueue_script('pmxi-script', PMXI_ROOT_URL . '/static/js/pmxi.js', array('jquery'), PMXI_VERSION);
5
  }
actions/admin_menu.php CHANGED
@@ -5,17 +5,18 @@
5
 
6
  function pmxi_admin_menu() {
7
  global $menu, $submenu;
8
-
9
  if (current_user_can('manage_options')) { // admin management options
10
-
11
  add_menu_page(__('WP All Import', 'pmxi_plugin'), __('All Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-home', array(PMXI_Plugin::getInstance(), 'adminDispatcher'), PMXI_Plugin::ROOT_URL . '/static/img/xmlicon.png');
12
  // workaround to rename 1st option to `Home`
13
- $submenu['pmxi-admin-home'] = array();
14
  add_submenu_page('pmxi-admin-home', __('Import XML', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('New Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-import', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
15
  add_submenu_page('pmxi-admin-home', __('Manage Previous Imports', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Manage Imports', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-manage', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
16
  add_submenu_page('pmxi-admin-home', __('Settings', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Settings', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-settings', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
17
  add_submenu_page('pmxi-admin-home', __('Support', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Support', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-help', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
18
-
19
- }
 
20
  }
21
 
5
 
6
  function pmxi_admin_menu() {
7
  global $menu, $submenu;
8
+
9
  if (current_user_can('manage_options')) { // admin management options
10
+
11
  add_menu_page(__('WP All Import', 'pmxi_plugin'), __('All Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-home', array(PMXI_Plugin::getInstance(), 'adminDispatcher'), PMXI_Plugin::ROOT_URL . '/static/img/xmlicon.png');
12
  // workaround to rename 1st option to `Home`
13
+ $submenu['pmxi-admin-home'] = array();
14
  add_submenu_page('pmxi-admin-home', __('Import XML', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('New Import', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-import', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
15
  add_submenu_page('pmxi-admin-home', __('Manage Previous Imports', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Manage Imports', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-manage', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
16
  add_submenu_page('pmxi-admin-home', __('Settings', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Settings', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-settings', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
17
  add_submenu_page('pmxi-admin-home', __('Support', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Support', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-help', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
18
+ //add_submenu_page('pmxi-admin-home', __('Scheduled Imports', 'pmxi_plugin') . ' &lsaquo; ' . __('WP All Import', 'pmxi_plugin'), __('Scheduled Imports', 'pmxi_plugin'), 'manage_options', 'pmxi-admin-cron', array(PMXI_Plugin::getInstance(), 'adminDispatcher'));
19
+
20
+ }
21
  }
22
 
actions/admin_notices.php CHANGED
@@ -25,6 +25,26 @@ function pmxi_admin_notices() {
25
  ) ?>
26
  </p></div>
27
  <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  }
29
 
30
  $input = new PMXI_Input();
25
  ) ?>
26
  </p></div>
27
  <?php
28
+ }
29
+
30
+ if ( class_exists( 'PMWI_Plugin' ) and ( version_compare(PMWI_VERSION, '1.2.3') <= 0 and PMWI_EDITION == 'paid' or version_compare(PMWI_FREE_VERSION, '1.1.0') < 0 and PMWI_EDITION == 'free') ) {
31
+ ?>
32
+ <div class="error"><p>
33
+ <?php printf(
34
+ __('<b>%s Plugin</b>: Please update your WP All Import WooCommerce add-on to the latest version</a>', 'pmwi_plugin'),
35
+ PMWI_Plugin::getInstance()->getName()
36
+ ) ?>
37
+ </p></div>
38
+ <?php
39
+
40
+ if (PMWI_EDITION == 'paid')
41
+ {
42
+ deactivate_plugins( PMWI_ROOT_DIR . '/plugin.php');
43
+ }
44
+ else
45
+ {
46
+ deactivate_plugins( PMWI_FREE_ROOT_DIR . '/plugin.php');
47
+ }
48
  }
49
 
50
  $input = new PMXI_Input();
actions/shutdown.php DELETED
@@ -1,7 +0,0 @@
1
- <?php
2
-
3
- function pmxi_shutdown() {
4
- PMXI_Plugin::$session = PMXI_Session::get_instance();
5
- PMXI_Plugin::$session->write_data();
6
- do_action( 'pmxi_session_commit' );
7
- }
 
 
 
 
 
 
 
actions/wp_loaded.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
 
3
- function pmxi_wp_loaded() {
4
-
 
5
  }
1
  <?php
2
 
3
+ function pmxi_wp_loaded() {
4
+
5
+
6
  }
classes/chunk.php CHANGED
@@ -4,27 +4,9 @@
4
  *
5
  * Reads a large file in as chunks for easier parsing.
6
  *
7
- * The chunks returned are whole <$this->options['element']/>s found within file.
8
- *
9
- * Each call to read() returns the whole element including start and end tags.
10
- *
11
- * Tested with a 1.8MB file, extracted 500 elements in 0.11s
12
- * (with no work done, just extracting the elements)
13
- *
14
- * Usage:
15
- * <code>
16
- * // initialize the object
17
- * $file = new Chunk('chunk-test.xml', array('element' => 'Chunk'));
18
- *
19
- * // loop through the file until all lines are read
20
- * while ($xml = $file->read()) {
21
- * // do whatever you want with the string
22
- * $o = simplexml_load_string($xml);
23
- * }
24
- * </code>
25
  *
26
  * @package default
27
- * @author Dom Hastings
28
  */
29
  class PMXI_Chunk {
30
  /**
@@ -35,10 +17,11 @@ class PMXI_Chunk {
35
  */
36
  public $options = array(
37
  'path' => './', // string The path to check for $file in
38
- 'element' => '', // string The XML element to return
39
- 'chunkSize' => 1024, // integer The amount of bytes to retrieve in each chunk
40
  'type' => 'upload',
41
- 'is_remove_colons' => false
 
 
42
  );
43
 
44
  /**
@@ -54,19 +37,9 @@ class PMXI_Chunk {
54
  * @var integer The current position the file is being read from
55
  * @access public
56
  */
57
- public $pointer = 0;
58
-
59
- public $cloud = array();
60
-
61
- public $is_validate = true;
62
-
63
- public $open_counter = 0;
64
-
65
- public $encoding = "";
66
-
67
- public $case_sensitive = 1;
68
-
69
- public $return_with_encoding = true;
70
 
71
  /**
72
  * handle
@@ -80,15 +53,7 @@ class PMXI_Chunk {
80
  *
81
  * @var boolean Whether the script is currently reading the file
82
  * @access private
83
- */
84
- private $reading = false;
85
- /**
86
- * readBuffer
87
- *
88
- * @var string Used to make sure start tags aren't missed
89
- * @access private
90
- */
91
- private $readBuffer = '';
92
 
93
  /**
94
  * __construct
@@ -100,42 +65,106 @@ class PMXI_Chunk {
100
  * @author Dom Hastings
101
  * @access public
102
  */
103
- public function __construct($file, $options = array(), $pointer = 0, $return_with_encoding = true) {
104
- // merge the options together
105
- $this->options = array_merge($this->options, (is_array($options) ? $options : array()));
106
- $this->return_with_encoding = $return_with_encoding;
107
- // check that the path ends with a /
108
- if (substr($this->options['path'], -1) != '/') {
109
- $this->options['path'] .= '/';
110
- }
111
-
112
- // normalize the filename
113
- $file_base = basename($file);
114
 
115
- // make sure chunkSize is an int
116
- $this->options['chunkSize'] = intval($this->options['chunkSize']);
117
-
118
- // check it's valid
119
- if ($this->options['chunkSize'] < 64) {
120
- $this->options['chunkSize'] = 1024;
121
- }
122
-
123
- $chunk_size = PMXI_Plugin::getInstance()->getOption('chunk_size');
124
 
125
- $this->options['chunkSize'] *= $chunk_size;
126
-
127
- $this->pointer = $pointer;
128
 
129
  // set the filename
130
  $this->file = $file;
131
 
132
- $this->case_sensitive = PMXI_Plugin::getInstance()->getOption('case_sensitive');
133
-
134
- // open the file
135
- $this->handle = @fopen($this->file, 'rb');
136
-
137
- }
138
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  /**
140
  * __destruct
141
  *
@@ -147,7 +176,7 @@ class PMXI_Chunk {
147
  */
148
  public function __destruct() {
149
  // close the file resource
150
- if ($this->handle) @fclose($this->handle);
151
  }
152
 
153
  /**
@@ -159,295 +188,75 @@ class PMXI_Chunk {
159
  * @author Dom Hastings
160
  * @access public
161
  */
162
- public function read() {
163
- // check we have an element specified
164
- if (!empty($this->options['element'])) {
165
- // trim it
166
- $element = trim($this->options['element']);
167
-
168
- } else {
169
- $element = '';
170
- }
171
-
172
- // initialize the buffer
173
- $buffer = false;
174
-
175
- // if the element is empty, then start auto detect root element tag name
176
- if (empty($element)) {
177
- // let the script know we're reading
178
- $this->reading = true;
179
- $founded_tags = array();
180
- // read in the whole doc, cos we don't know what's wanted
181
- while ($this->reading and (count($founded_tags) < 500)) {
182
- $c = @fread($this->handle, $this->options['chunkSize']);
183
-
184
- if ( $this->options['is_remove_colons'] === false ) {
185
- $this->options['is_remove_colons'] = strpos($c, ":");
186
- }
187
-
188
- if ($this->options['is_remove_colons'] !== false)
189
- $c = $this->removeColonsFromRSS($c);
190
-
191
- if ($this->is_validate) {
192
- if (stripos($c, "xmlns") !== false){
193
- $this->is_validate = false;
194
- }
195
- }
196
- if ( @preg_match_all("/<\\w+\\s*[^<|^\n|^>]*\\s*\/?>/" . ($this->case_sensitive ? "i" : ""), $c, $matches, PREG_PATTERN_ORDER) ){
197
- foreach ($matches[0] as $tag) {
198
- if ( strpos($tag, "<br") === false and strpos($tag, "?xml") === false and strpos($tag, "!--") === false and strpos($tag, "<p>") === false and strpos($tag, "<li>") === false and strpos($tag, "<ul>") === false and strpos($tag, "<a ") === false) {
199
- $tag = explode(" ", trim(str_replace(array('<','>','/'), '', $tag)));
200
- array_push($founded_tags, $tag[0]);
201
- }
202
- }
203
- }
204
- $this->reading = (!@feof($this->handle));
205
- }
206
- // we must be looking for a specific element
207
- }
208
-
209
- if (empty($this->encoding)) {
210
- fseek($this->handle, 0);
211
- $this->reading = true;
212
- // read in the whole doc, cos we don't know what's wanted
213
- while ($this->reading) {
214
- $c = @fread($this->handle, $this->options['chunkSize']);
215
- $enc = @preg_match("/<\?xml[^<]*\?>/" . ($this->case_sensitive ? "i" : ""), $c, $enc_matches);
216
- if ($enc)
217
- $this->encoding = $enc_matches[0];
218
- $this->reading = false;
219
- }
220
- }
221
-
222
- if (empty($this->encoding) or strpos($this->encoding, 'encoding') === false) $this->encoding = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
223
-
224
- if (empty($element) and !empty($founded_tags)) {
225
-
226
- $element_counts = array_count_values($founded_tags);
227
-
228
- if (!empty($element_counts)){
229
-
230
- foreach ($element_counts as $tag => $count) {
231
- if (strpos($tag, ":") === false)
232
- $this->cloud[$tag] = $count;
233
- }
234
-
235
- $element_counts = array_flip($element_counts);
236
- krsort($element_counts);
237
-
238
  }
239
-
 
240
  }
241
-
242
- $main_elements = array('node', 'product', 'job', 'deal', 'entry', 'item', 'property', 'listing', 'hotel', 'record', 'article');
243
-
244
- // return it all if element doesn't founded
245
- if (empty($element)){
246
- if (!empty($this->cloud)){
247
- foreach ($this->cloud as $element_name => $value) {
248
- if ( in_array(strtolower($element_name), $main_elements) ){
249
- $this->options['element'] = $element = $element_name;
250
- break;
251
- }
252
- }
253
- if (empty($element)){
254
- if (count($element_counts) > 1) array_shift($element_counts);
255
- foreach ($element_counts as $el) {
256
- if ( ! preg_match("%[\'\/~`\!@#\$\^&\*\(\)\-\+=\{\}\[\]\|;:\"\<\>,\.\?\\\]%", $el) ) {
257
- $this->options['element'] = $element = $el;
258
- break;
259
- }
260
- }
261
- }
262
- }
263
- else return false;
264
- }
265
 
266
- // we must be looking for a specific element
267
-
268
- // initialize the buffer
269
- $buffer = false;
270
-
271
- // set up the strings to find
272
- $open = '<'.$element;
273
- $close = '</'.$element.'>';
274
-
275
- // let the script know we're reading
276
- $this->reading = true;
277
-
278
- // reset the global buffer
279
- $this->readBuffer = '';
280
-
281
- // this is used to ensure all data is read, and to make sure we don't send the start data again by mistake
282
- $store = false;
283
-
284
- $checkOpen = false;
285
-
286
- // seek to the position we need in the file
287
- fseek($this->handle, $this->pointer);
288
-
289
- // start reading
290
- while ($this->reading && !@feof($this->handle)) {
291
-
292
- // store the chunk in a temporary variable
293
- $tmp = @fread($this->handle, $this->options['chunkSize']);
294
-
295
- if ( $this->options['is_remove_colons'] === false ) $this->options['is_remove_colons'] = strpos($tmp, ":");
296
 
297
- if ($this->options['is_remove_colons'] !== false) $tmp = $this->removeColonsFromRSS($tmp);
298
-
299
- // update the global buffer
300
- $this->readBuffer .= $tmp;
301
-
302
- if ($checkOpen === false) {
303
-
304
- $checkOpen = @preg_match_all( "/". $open ."[\s|>]{1}/" . ($this->case_sensitive ? "i" : ""), $tmp, $checkOpenmatches, PREG_OFFSET_CAPTURE);
305
-
306
- $checkOpen = (!empty($checkOpenmatches[0])) ? $checkOpenmatches[0][0][1] : false;
307
-
308
- // if it wasn't in the new buffer
309
- if ($checkOpen === false && !($store)) {
310
-
311
- // check the full buffer (in case it was only half in this buffer)
312
- $checkOpen = @preg_match_all("/".$open."[\s|>]{1}/" . ($this->case_sensitive ? "i" : ""), $this->readBuffer, $checkOpenmatches, PREG_OFFSET_CAPTURE);
313
-
314
- $checkOpen = (!empty($checkOpenmatches[0])) ? $checkOpenmatches[0][0][1] : false;
315
-
316
- // if it was in there
317
- if ($checkOpen !== false) $checkOpen = $checkOpen % $this->options['chunkSize'];
318
-
319
- }
320
- }
321
 
322
- // check for the close string
323
- $checkClose = @preg_match_all("/<\/".$element.">/" . ($this->case_sensitive ? "i" : ""), $tmp, $closematches, PREG_OFFSET_CAPTURE);
324
- $withoutcloseelement = (@preg_match("/(<".$element."\s{1}[^<]*\/>|<".$element."\/>)/" . ($this->case_sensitive ? "i" : ""), $tmp, $matches)) ? strpos($tmp, $matches[0]) : false;
 
 
 
 
 
 
 
 
 
 
 
 
 
325
 
326
- if ($withoutcloseelement and $checkClose and $closematches[0][0][1] > $withoutcloseelement) $checkClose = false;
327
 
328
- if (!$checkClose){
329
- $checkClose = $withoutcloseelement;
330
 
331
- if ($checkClose === false){
332
- $checkClose = (@preg_match_all("/(<".$element."\s{1}[^<]*\/>|<".$element."\/>)/" . ($this->case_sensitive ? "i" : ""), $this->readBuffer, $matches)) ? strpos($this->readBuffer, $matches[0][count($matches[0]) - 1]) : false;
333
- if ($checkClose !== false) {
334
- $withoutcloseelement = true;
335
- $matches[0] = $matches[0][count($matches[0]) - 1];
336
- }
337
- }
338
- }
339
- else{
340
-
341
- $close_finded = false;
342
- $length = $closematches[0][0][1] - $checkOpen;
343
-
344
- $checkDuplicateOpen = @preg_match_all("/".$open."[\s|>]{1}/" . ($this->case_sensitive ? "i" : ""), substr($this->readBuffer, $checkOpen, $length), $matches, PREG_OFFSET_CAPTURE);
345
-
346
- while (!$close_finded){
347
- if ($checkDuplicateOpen > 1 and !empty($closematches[0][$checkDuplicateOpen - 1])){
348
- $secondcheckDuplicateOpen = @preg_match_all("/".$open."[\s|>]{1}/" . ($this->case_sensitive ? "i" : ""), substr($this->readBuffer, $checkOpen, $closematches[0][$checkDuplicateOpen - 1][1] - $checkOpen), $matches, PREG_OFFSET_CAPTURE);
349
- if ($secondcheckDuplicateOpen == $checkDuplicateOpen){
350
- $checkClose = $closematches[0][$checkDuplicateOpen - 1][1];
351
- $close_finded = true;
352
- }
353
- else{
354
- $checkClose = false;
355
- $checkDuplicateOpen = $secondcheckDuplicateOpen;
356
- }
357
- }
358
- elseif ($checkDuplicateOpen > 1){
359
- $checkClose = false;
360
- $close_finded = true;
361
- $store = true;
362
- }
363
- else{
364
- $checkClose = $closematches[0][0][1];
365
- $close_finded = true;
366
- }
367
- }
368
- }
369
 
370
- if ($checkClose !== false) {
371
- // add the length of the close string itself
372
- if ( ! $withoutcloseelement or ( !empty($closematches[0][0][1]) and $closematches[0][0][1] < $withoutcloseelement))
373
- $checkClose += strlen($close);
374
- else
375
- $checkClose += strlen($matches[0]); // "/>" symbols
376
 
 
 
 
 
 
 
377
  }
378
-
379
- // if we've found the opening string and we're not already reading another element
380
- if ($checkOpen !== false && !($store)) {
381
- // if we're found the end element too
382
- if ($checkClose !== false) {
383
- // append the string only between the start and end element
384
- $buffer .= substr($tmp, $checkOpen, ($checkClose - $checkOpen));
385
-
386
- // update the pointer
387
- $this->pointer += $checkClose;
388
-
389
- // let the script know we're done
390
- $this->reading = false;
391
-
392
- } else {
393
- // append the data we know to be part of this element
394
- $buffer .= substr($tmp, $checkOpen);
395
-
396
- // update the pointer
397
- $this->pointer += $this->options['chunkSize'];
398
-
399
- // let the script know we're gonna be storing all the data until we find the close element
400
- $store = true;
401
-
402
- }
403
-
404
- // if we've found the closing element
405
- } elseif ($checkClose !== false) {
406
- // update the buffer with the data upto and including the close tag
407
- $buffer .= substr($tmp, 0, $checkClose);
408
-
409
- // update the pointer
410
- $this->pointer += $checkClose;
411
-
412
- // let the script know we're done
413
- $this->reading = false;
414
-
415
- // if we've found the closing element, but half in the previous chunk
416
- } elseif ($store) {
417
- // update the buffer
418
- $buffer .= $tmp;
419
-
420
- // and the pointer
421
- $this->pointer += $this->options['chunkSize'];
422
- }
423
-
424
- }
425
-
426
- // return the element (or the whole file if we're not looking for elements)
427
- return $buffer;
428
- }
429
 
430
- function removeColonsFromRSS($feed) {
431
-
432
- /*$pattern = '/(<[^<:>]*):/' . ($this->case_sensitive ? 'i' : '');
433
- $replacement = '$1_';
434
- $feed = preg_replace($pattern, $replacement, $feed); */
435
-
436
- // pull out colons from start tags
437
- // (<\w+):(\w+>)
438
- $pattern = '/(<\w+):(\w+[ |>]{1})/' . ($this->case_sensitive ? 'i' : '');
439
- $replacement = '$1_$2';
440
- $feed = preg_replace($pattern, $replacement, $feed);
441
- // pull out colons from end tags
442
- // (<\/\w+):(\w+>)
443
- $pattern = '/(<\/\w+):(\w+>)/' . ($this->case_sensitive ? 'i' : '');
444
- $replacement = '$1_$2';
445
- $feed = preg_replace($pattern, $replacement, $feed);
446
- // pull out colons from attributes
447
- $pattern = '/(\s+\w+):(\w+[=]{1})/' . ($this->case_sensitive ? 'i' : '');
448
- $replacement = '$1_$2';
449
- $feed = preg_replace($pattern, $replacement, $feed);
450
-
451
- return $feed;
452
- }
453
  }
4
  *
5
  * Reads a large file in as chunks for easier parsing.
6
  *
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  *
8
  * @package default
9
+ * @author Max Tsiplyakov
10
  */
11
  class PMXI_Chunk {
12
  /**
17
  */
18
  public $options = array(
19
  'path' => './', // string The path to check for $file in
20
+ 'element' => '', // string The XML element to return
 
21
  'type' => 'upload',
22
+ 'encoding' => 'UTF-8',
23
+ 'pointer' => 1,
24
+ 'chunkSize' => 1024
25
  );
26
 
27
  /**
37
  * @var integer The current position the file is being read from
38
  * @access public
39
  */
40
+ public $reader;
41
+ public $cloud = array();
42
+ public $loop = 1;
 
 
 
 
 
 
 
 
 
 
43
 
44
  /**
45
  * handle
53
  *
54
  * @var boolean Whether the script is currently reading the file
55
  * @access private
56
+ */
 
 
 
 
 
 
 
 
57
 
58
  /**
59
  * __construct
65
  * @author Dom Hastings
66
  * @access public
67
  */
68
+ public function __construct($file, $options = array()) {
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // merge the options together
71
+ $this->options = array_merge($this->options, (is_array($options) ? $options : array()));
 
 
 
 
 
 
 
72
 
73
+ $this->options['chunkSize'] *= PMXI_Plugin::getInstance()->getOption('chunk_size');
 
 
74
 
75
  // set the filename
76
  $this->file = $file;
77
 
78
+ if (empty($this->options['element'])){
79
+ $founded_tags = array();
80
+
81
+ $reader = new XMLReader();
82
+ $reader->open($this->file);
83
+ $reader->setParserProperty(XMLReader::VALIDATE, false);
84
+ while ( @$reader->read()) {
85
+ switch ($reader->nodeType) {
86
+ case (XMLREADER::ELEMENT):
87
+ array_push($founded_tags, str_replace(":", "_", $reader->localName));
88
+ if (count($founded_tags) > 100) break(2);
89
+ break;
90
+ default:
91
+
92
+ break;
93
+ }
94
+ }
95
+ unset($reader);
96
+
97
+ if (!empty($founded_tags)) {
98
+ $element_counts = array_count_values($founded_tags);
99
+ if (!empty($element_counts)){
100
+ foreach ($element_counts as $tag => $count)
101
+ if (strpos($tag, ":") === false)
102
+ $this->cloud[$tag] = $count;
103
+
104
+ arsort($element_counts);
105
+ }
106
+ }
107
+
108
+ if (!empty($this->cloud)){
109
+
110
+ $main_elements = array('node', 'product', 'job', 'deal', 'entry', 'item', 'property', 'listing', 'hotel', 'record', 'article');
111
+
112
+ foreach ($this->cloud as $element_name => $value) {
113
+ if ( in_array(strtolower($element_name), $main_elements) ){
114
+ $this->options['element'] = $element_name;
115
+ break;
116
+ }
117
+ }
118
+ if (empty($this->options['element'])){
119
+ //if (count($element_counts) > 1) array_shift($element_counts);
120
+ foreach ($element_counts as $el => $count) {
121
+ $this->options['element'] = $el;
122
+ break;
123
+ }
124
+ }
125
+ }
126
+ }
127
+
128
+ // we must be looking for a specific element
129
+ /*if (empty($this->options['encoding'])) {
130
+
131
+ // open the file
132
+ $this->handle = @fopen($this->file, 'rb');
133
+
134
+ fseek($this->handle, 0);
135
+ $this->reading = true;
136
+ // read in the whole doc, cos we don't know what's wanted
137
+ while ($this->reading) {
138
+ $c = @fread($this->handle, $this->options['chunkSize']);
139
+
140
+ $enc = @preg_match("/<\?xml[^<]*\?>/i", $c, $enc_matches);
141
+ if ($enc)
142
+ $this->options['encoding'] = $enc_matches[0];
143
+
144
+ $this->reading = false;
145
+ }
146
+ if ($this->handle) @fclose($this->handle);
147
+ }
148
+
149
+ $encoding = '';
150
+
151
+ if (empty($this->options['encoding']) or strpos($this->options['encoding'], 'encoding') === false)
152
+ $encoding = "UTF-8";
153
+ else
154
+ preg_match('~encoding=["|\']{1}([-a-z0-9_]+)["|\']{1}~i', $this->options['encoding'], $encoding);
155
+
156
+ $this->options['encoding'] = (is_array($encoding)) ? $encoding[1] : $encoding; */
157
+
158
+ /*stream_filter_register("removecolons", "removecolons_filter");
159
+
160
+ $path = 'php://filter/read=removecolons/resource=' . $this->file;*/
161
+
162
+ $this->reader = new XMLReader();
163
+ $this->reader->open($this->file);
164
+ $this->reader->setParserProperty(XMLReader::VALIDATE, false);
165
+
166
+ }
167
+
168
  /**
169
  * __destruct
170
  *
176
  */
177
  public function __destruct() {
178
  // close the file resource
179
+ unset($this->reader);
180
  }
181
 
182
  /**
188
  * @author Dom Hastings
189
  * @access public
190
  */
191
+ public function read($debug = false) {
192
+
193
+ // trim it
194
+ $element = trim($this->options['element']);
195
+
196
+ $xml = '';
197
+
198
+ try {
199
+ while ( @$this->reader->read() ) {
200
+ switch ($this->reader->nodeType) {
201
+ case (XMLREADER::ELEMENT):
202
+ if ( strtolower(str_replace(":", "_", $this->reader->localName)) == strtolower($element) ) {
203
+
204
+ if ($this->loop < $this->options['pointer']){
205
+ $this->loop++;
206
+ continue;
207
+ }
208
+
209
+ $xml = @$this->reader->readOuterXML();
210
+
211
+ break(2);
212
+ }
213
+ break;
214
+ default:
215
+ // code ...
216
+ break;
217
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  }
219
+ } catch (XmlImportException $e) {
220
+ $xml = false;
221
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
+ return ( ! empty($xml) ) ? $this->removeColonsFromRSS(preg_replace('%xmlns.*=\s*([\'"]).*\1%sU', '', $xml)) : false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
 
227
+ function removeColonsFromRSS($feed) {
228
+
229
+ // pull out colons from start tags
230
+ // (<\w+):(\w+>)
231
+ $pattern = '/(<\w+):(\w+[ |>]{1})/i';
232
+ $replacement = '<$2';
233
+ $feed = preg_replace($pattern, $replacement, $feed);
234
+ // pull out colons from end tags
235
+ // (<\/\w+):(\w+>)
236
+ $pattern = '/(<\/\w+):(\w+>)/i';
237
+ $replacement = '</$2';
238
+ $feed = preg_replace($pattern, $replacement, $feed);
239
+ // pull out colons from attributes
240
+ $pattern = '/(\s+\w+):(\w+[=]{1})/i';
241
+ $replacement = '$1_$2';
242
+ $feed = preg_replace($pattern, $replacement, $feed);
243
 
244
+ return $feed;
245
 
246
+ }
 
247
 
248
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
249
 
250
+ class removecolons_filter extends php_user_filter {
 
 
 
 
 
251
 
252
+ function filter($in, $out, &$consumed, $closing)
253
+ {
254
+ while ($bucket = stream_bucket_make_writeable($in)) {
255
+ $bucket->data = $this->removeColonsFromRSS(preg_replace('%xmlns.*=\s*([\'"]).*\1%sU', '', $bucket->data)); //preg_replace ('/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}]+/u', ' ', $bucket->data);
256
+ $consumed += $bucket->datalen;
257
+ stream_bucket_append($out, $bucket);
258
  }
259
+ return PSFS_PASS_ON;
260
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  }
classes/helper.php CHANGED
@@ -35,7 +35,7 @@ class PMXI_Helper {
35
  public static function safe_glob($pattern, $flags=0) {
36
  $split = explode('/', str_replace('\\', '/', $pattern));
37
  $mask = array_pop($split);
38
- $path = implode('/', $split);
39
 
40
  if (($dir = @opendir($path . '/')) !== false or ($dir = @opendir($path)) !== false) {
41
  $glob = array();
@@ -58,7 +58,7 @@ class PMXI_Helper {
58
  if ( ! ($flags & self::GLOB_NOSORT)) sort($glob);
59
  return $glob;
60
  } else {
61
- return false;
62
  }
63
  }
64
 
35
  public static function safe_glob($pattern, $flags=0) {
36
  $split = explode('/', str_replace('\\', '/', $pattern));
37
  $mask = array_pop($split);
38
+ $path = implode('/', $split);
39
 
40
  if (($dir = @opendir($path . '/')) !== false or ($dir = @opendir($path)) !== false) {
41
  $glob = array();
58
  if ( ! ($flags & self::GLOB_NOSORT)) sort($glob);
59
  return $glob;
60
  } else {
61
+ return (strpos($pattern, "*") === false) ? array($pattern) : false;
62
  }
63
  }
64
 
classes/session.php CHANGED
@@ -217,7 +217,7 @@ final class PMXI_Session extends PMXI_ArrayAccess implements Iterator, Countable
217
  }
218
  }
219
  else{
220
- $session = $this->toArray(); $_SESSION['pmxi_import'] = $session['pmxi_import'];
221
  }
222
 
223
  }
217
  }
218
  }
219
  else{
220
+ $session = $this->toArray(); $_SESSION['pmxi_import'] = (!empty($session['pmxi_import'])) ? $session['pmxi_import'] : array();
221
  }
222
 
223
  }
config/options.php CHANGED
@@ -17,9 +17,11 @@ $config = array(
17
  "html_entities" => 0,
18
  "utf8_decode" => 0,
19
  "cron_job_key" => url_title(rand_char(12)),
20
- "chunk_size" => 64,
21
  "pingbacks" => 1,
22
  "legacy_special_character_handling" => 1,
23
  "case_sensitive" => 1,
24
- "session_mode" => 'default'
 
 
25
  );
17
  "html_entities" => 0,
18
  "utf8_decode" => 0,
19
  "cron_job_key" => url_title(rand_char(12)),
20
+ "chunk_size" => 32,
21
  "pingbacks" => 1,
22
  "legacy_special_character_handling" => 1,
23
  "case_sensitive" => 1,
24
+ "session_mode" => 'default',
25
+ "enable_ftp_import" => 0,
26
+ "large_feed_limit" => 1000
27
  );
controllers/admin/addons.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Add-ons page
4
+ *
5
+ * @author Max Tsiplyakov <makstsiplyakov@gmail.com>
6
+ */
7
+ class PMXI_Admin_Addons extends PMXI_Controller_Admin {
8
+
9
+ public static $addons = array('PMWI_Plugin' => 0, 'PMAI_Plugin' => 0, 'PMWITabs_Plugin' => 0, 'PMLI_Plugin' => 0); // inactive by default
10
+
11
+ public function __construct() {
12
+
13
+ parent::__construct();
14
+
15
+ }
16
+
17
+ public function index() {
18
+
19
+ $this->data['premium'] = array();
20
+ $this->data['premium']['PMWI_Plugin'] = array(
21
+ 'title' => __("WooCommerce Addon",'pmxi_plugin'),
22
+ 'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
23
+ 'thumbnail' => 'http://placehold.it/220x220',
24
+ 'active' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'paid'),
25
+ 'free_installed' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'free'),
26
+ 'required_plugins' => false,
27
+ 'url' => 'http://www.wpallimport.com/woocommerce-product-import'
28
+ );
29
+ $this->data['premium']['PMAI_Plugin'] = array(
30
+ 'title' => __("ACF Addon",'pmxi_plugin'),
31
+ 'description' => __("Import to advanced custom fields",'pmxi_plugin'),
32
+ 'thumbnail' => 'http://placehold.it/220x220',
33
+ 'active' => class_exists('PMAI_Plugin'),
34
+ 'free_installed' => (class_exists('PMAI_Plugin') and PMAI_EDITION == 'free'),
35
+ 'required_plugins' => array('Advanced Custom Fields' => class_exists('acf')),
36
+ 'url' => 'http://www.wpallimport.com'
37
+ );
38
+ $this->data['premium']['PMLI_Plugin'] = array(
39
+ 'title' => __("WPML Addon",'pmxi_plugin'),
40
+ 'description' => __("Import to WPML",'pmxi_plugin'),
41
+ 'thumbnail' => 'http://placehold.it/220x220',
42
+ 'active' => class_exists('PMLI_Plugin'),
43
+ 'free_installed' => (class_exists('PMLI_Plugin') and PMLI_EDITION == 'free'),
44
+ 'required_plugins' => array('WPML' => class_exists('SitePress')),
45
+ 'url' => 'http://www.wpallimport.com'
46
+ );
47
+
48
+ $this->data['free'] = array();
49
+ $this->data['free']['PMWI_Plugin'] = array(
50
+ 'title' => __("WooCommerce Addon - free edition",'pmxi_plugin'),
51
+ 'description' => __("Import Products from any XML or CSV to WooCommerce",'pmxi_plugin'),
52
+ 'thumbnail' => 'http://placehold.it/220x220',
53
+ 'active' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'free'),
54
+ 'paid_installed' => (class_exists('PMWI_Plugin') and PMWI_EDITION == 'paid'),
55
+ 'required_plugins' => false,
56
+ 'url' => 'http://wordpress.org/plugins/woocommerce-xml-csv-product-import'
57
+ );
58
+
59
+ $this->data['free']['PMWITabs_Plugin'] = array(
60
+ 'title' => __("WooCommerce Tabs Addon",'pmxi_plugin'),
61
+ 'description' => __("Import data to WooCommerce tabs",'pmxi_plugin'),
62
+ 'thumbnail' => 'http://placehold.it/220x220',
63
+ 'active' => class_exists('PMWITabs_Plugin'),
64
+ 'paid_installed' => false,
65
+ 'required_plugins' => array('WooCommerce Addon' => class_exists('PMWI_Plugin')),
66
+ 'url' => 'http://www.wpallimport.com'
67
+ );
68
+
69
+ $this->render();
70
+ }
71
+
72
+ protected static function set_addons_status(){
73
+ foreach (self::$addons as $class => $active)
74
+ self::$addons[$class] = class_exists($class);
75
+ }
76
+
77
+ public static function get_all_addons(){
78
+
79
+ self::set_addons_status();
80
+
81
+ return self::$addons;
82
+ }
83
+
84
+ public static function get_addon($addon = false){
85
+
86
+ self::set_addons_status();
87
+
88
+ return ($addon) ? self::$addons[$addon] : false;
89
+ }
90
+
91
+ public static function get_active_addons(){
92
+
93
+ self::set_addons_status();
94
+ $active_addons = array();
95
+ foreach (self::$addons as $class => $active) if ($active) $active_addons[] = $class;
96
+
97
+ return $active_addons;
98
+ }
99
+
100
+ }
controllers/admin/cron.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Cron page
4
+ *
5
+ * @author Pavel Kulbakin <p.kulbakin@gmail.com>
6
+ */
7
+ class PMXI_Admin_Cron extends PMXI_Controller_Admin {
8
+
9
+ public function index() {
10
+ $this->render();
11
+ }
12
+ }
controllers/admin/import.php CHANGED
@@ -10,7 +10,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
10
  protected $isTemplateEdit = false; // indicates whether controlled is deligated by manage imports controller
11
 
12
  protected function init() {
13
- parent::init();
14
 
15
  if ('PMXI_Admin_Manage' == PMXI_Plugin::getInstance()->getAdminCurrentScreen()->base) { // prereqisites are not checked when flow control is deligated
16
  $id = $this->input->get('id');
@@ -30,6 +30,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
30
 
31
  // preserve id parameter as part of baseUrl
32
  $id = $this->input->get('id') and $this->baseUrl = add_query_arg('id', $id, $this->baseUrl);
 
 
33
  }
34
 
35
  public function set($var, $val)
@@ -53,12 +55,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
53
  $this->data['dom'] = $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
54
  $this->data['update_previous'] = $update_previous = new PMXI_Import_Record();
55
  $old = libxml_use_internal_errors(true);
56
-
57
- if ( ! in_array($action, array('evaluate_variations', 'process')) ){
58
- PMXI_Plugin::$session['pmxi_import']['pointer'] = 0;
59
- pmxi_session_commit();
60
- }
61
-
62
  $xml = $this->get_xml();
63
 
64
  if (empty($xml) and in_array($action, array('process')) ){
@@ -67,7 +64,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
67
  }
68
 
69
  if (empty(PMXI_Plugin::$session->data['pmxi_import'])
70
- or ! @$dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml))// FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
71
  //or empty(PMXI_Plugin::$session['pmxi_import']['source'])
72
  or ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])->isEmpty()
73
  ) {
@@ -113,6 +110,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
113
 
114
  $this->data['reimported_import'] = $import = new PMXI_Import_Record();
115
  $this->data['id'] = $id = $this->input->get('id');
 
116
  if ($id and $import->getById($id)->isEmpty()) { // update requested but corresponding import is not found
117
  wp_redirect(remove_query_arg('id', $this->baseUrl)); die();
118
  }
@@ -126,11 +124,10 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
126
  'reimport' => '',
127
  'is_update_previous' => $id ? 1 : 0,
128
  'update_previous' => $id,
129
- 'xpath' => '/',
130
- 'large_file' => '',
131
  'filepath' => '',
132
  'root_element' => ''
133
- ));
134
 
135
  if ($this->input->post('is_submitted_continue')) {
136
  if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) {
@@ -159,8 +156,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
159
  $filePath = '';
160
 
161
  if (!empty($v_result_list)){
162
- foreach ($v_result_list as $unzipped_file) {
163
- if ($unzipped_file['status'] == 'ok') $filePath = $unzipped_file['filename'];
164
  }
165
  }
166
  if($uploads['error']){
@@ -188,8 +185,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
188
  }
189
  }
190
 
191
- // Detect if file is very large
192
- $post['large_file'] = (filesize($filePath) > PMXI_Plugin::LARGE_SIZE) ? 'on' : false;
193
  $source = array(
194
  'name' => basename($post['filepath']),
195
  'type' => 'upload',
@@ -201,23 +197,18 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
201
  if($uploads['error']){
202
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
203
  }
204
- if (empty($post['large_file'])) {
205
- $filePath = PMXI_Plugin::csv_to_xml($filePath);
206
- }
207
- else{
208
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
209
- $csv = new PMXI_CsvParser($filePath, true); // create chunks
210
- $filePath = $csv->xml_path;
211
- $post['root_element'] = 'node';
212
- }
213
  }
214
  }
215
 
216
  } elseif ( preg_match('%\W(csv|txt|dat|psv)$%i', trim($post['filepath']))) { // If CSV file uploaded
217
 
218
- // Detect if file is very large
219
- $post['large_file'] = (filesize($post['filepath']) > PMXI_Plugin::LARGE_SIZE) ? 'on' : false;
220
-
221
  if($uploads['error']){
222
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
223
  }
@@ -226,22 +217,17 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
226
  'name' => basename($post['filepath']),
227
  'type' => 'upload',
228
  'path' => $filePath,
229
- );
230
- if (empty($post['large_file'])) {
231
- $filePath = PMXI_Plugin::csv_to_xml($post['filepath']);
232
- } else{
233
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
234
- $csv = new PMXI_CsvParser($post['filepath'], true);
235
- $filePath = $csv->xml_path;
236
- $post['root_element'] = 'node';
237
- }
238
  } elseif(preg_match('%\W(gz)$%i', trim($post['filepath']))){ // If gz file uploaded
239
  $fileInfo = pmxi_gzfile_get_contents($post['filepath']);
240
  $filePath = $fileInfo['localPath'];
241
 
242
- // Detect if file is very large
243
- $post['large_file'] = (filesize($filePath) > PMXI_Plugin::LARGE_SIZE) ? 'on' : false;
244
-
245
  $source = array(
246
  'name' => basename($post['filepath']),
247
  'type' => 'upload',
@@ -250,21 +236,16 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
250
 
251
  // detect CSV or XML
252
  if ( $fileInfo['type'] == 'csv') { // it is CSV file
253
- if (empty($post['large_file'])) {
254
- $filePath = PMXI_Plugin::csv_to_xml($filePath); // convert CSV to XML
255
- }
256
- else{
257
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
258
- $csv = new PMXI_CsvParser($filePath, true); // create chunks
259
- $filePath = $csv->xml_path;
260
- $post['root_element'] = 'node';
261
- }
262
  }
263
  } else { // If XML file uploaded
264
 
265
  // Detect if file is very large
266
- $post['large_file'] = (filesize($post['filepath']) > PMXI_Plugin::LARGE_SIZE) ? 'on' : false;
267
-
268
  $filePath = $post['filepath'];
269
  $source = array(
270
  'name' => basename($post['filepath']),
@@ -276,142 +257,105 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
276
  elseif ($this->input->post('is_submitted')){
277
 
278
  $this->errors->add('form-validation', __('Upgrade to the paid edition of WP All Import to use this feature.', 'pmxi_plugin'));
279
- }
280
 
281
  if ($post['is_update_previous'] and empty($post['update_previous'])) {
282
  $this->errors->add('form-validation', __('Previous import for update must be selected to proceed with a new one', 'pmxi_plugin'));
283
  }
284
-
285
- if ($this->input->post('is_submitted') and ! $this->errors->get_error_codes()) {
286
-
287
- check_admin_referer('choose-file', '_wpnonce_choose-file');
288
- $elements_cloud = array();
289
- $is_validate = true;
290
 
291
- if (empty($xml)){
292
 
293
- $wp_uploads = wp_upload_dir();
 
 
 
 
 
 
 
294
 
295
- if (!empty($post['large_file'])){
296
-
297
- @set_time_limit(0);
298
- $chunks = 0;
299
- $chunk_path = '';
300
- $local_paths = !empty($local_paths) ? $local_paths : array($filePath);
301
-
302
- foreach ($local_paths as $key => $path) {
303
-
304
- if ( @file_exists($path) ){
305
-
306
- $file = new PMXI_Chunk($path, array('element' => $post['root_element'], 'path' => $wp_uploads['path']));
307
-
308
- while ($xml = $file->read()) {
309
- if (!empty($xml))
310
- {
311
- PMXI_Import_Record::preprocessXml($xml);
312
- if ( !empty($xml) ){
313
- $xml = $file->encoding . "\n" . $xml;
314
- $is_validate = $file->is_validate;
315
- $chunks++;
316
- break;
317
- }
318
- }
319
- }
320
-
321
- if ( ! $key ){
322
- if ( ! empty($file->options['element'])) {
323
- $post['root_element'] = $file->options['element'];
324
- $xpath = "/".$post['root_element'];
325
- $elements_cloud = $file->cloud;
326
- if (empty($chunks)) { $this->errors->add('form-validation', __('No matching elements found for Root element and XPath expression specified', 'pmxi_plugin')); }
327
- }
328
- else $this->errors->add('form-validation', __('Unable to find root element for this feed. Please open the feed in your browser or a text editor and ensure it is a valid feed.', 'pmxi_plugin'));
329
- }
330
- }
331
- else $this->errors->add('form-validation', __('Unable to download feed resource.', 'pmxi_plugin'));
332
- }
333
 
334
- } else {
335
 
336
- ob_start();
337
- $filePath && @readgzfile($filePath);
338
- $xml = ob_get_clean();
339
-
340
- if (empty($xml)){
341
- $xml = @file_get_contents($filePath);
342
- if (empty($xml)) get_file_curl($filePath, $wp_uploads['path'] .'/'. basename($filePath));
343
- if (empty($xml)) $xml = @file_get_contents($wp_uploads['path'] .'/'. basename($filePath));
344
  }
345
- }
346
- }
347
-
348
- if ((!$is_validate or PMXI_Import_Record::validateXml($xml, $this->errors)) and (empty($post['large_file']) or (!empty($post['large_file']) and !empty($chunks)))) {
349
- // xml is valid
350
- if (!empty($post['large_file'])){
351
- $source['large_import'] = 'Yes';
352
- $source['root_element'] = $post['root_element'];
353
- }
354
- else {
355
- $source['large_import'] = 'No';
356
- $source['root_element'] = '';
357
  }
 
 
358
 
359
- $source['first_import'] = date("Y-m-d H:i:s");
360
 
361
- pmxi_session_unset();
362
-
363
- $encoding = 'UTF-8';
364
- preg_match('~encoding=["|\']{1}([-a-z0-9_]+)["|\']{1}~i', $file->encoding, $encoding);
365
-
366
- if ( "" == $post['feed_type'] and "" != PMXI_Plugin::$is_csv) $post['feed_type'] = 'csv';
367
 
368
  PMXI_Plugin::$session['pmxi_import'] = array(
369
  'filePath' => $filePath,
 
370
  'xpath' => (!empty($xpath)) ? $xpath : '',
371
  'feed_type' => $post['feed_type'],
372
- 'source' => $source,
373
- 'large_file' => (!empty($post['large_file'])) ? true : false,
374
- 'encoding' => (is_array($encoding)) ? $encoding[1] : $encoding,
375
  'is_csv' => PMXI_Plugin::$is_csv,
376
  'csv_path' => PMXI_Plugin::$csv_path,
377
  'chunk_number' => 1,
378
- 'log' => '',
379
- 'current_post_ids' => '',
380
  'processing' => 0,
381
  'queue_chunk_number' => 0,
382
- 'count' => (isset($chunks)) ? $chunks : 0,
383
- 'created_records' => 0,
384
- 'updated_records' => 0,
385
- 'skipped_records' => 0,
386
  'warnings' => 0,
387
  'errors' => 0,
388
  'start_time' => 0,
389
  'local_paths' => (!empty($local_paths)) ? $local_paths : array(), // ftp import local copies of remote files
390
  'csv_paths' => (!empty($csv_paths)) ? $csv_paths : array(PMXI_Plugin::$csv_path), // ftp import local copies of remote CSV files
391
  'action' => 'import',
392
- 'elements_cloud' => (!empty($elements_cloud)) ? $elements_cloud : array()
 
393
  );
394
-
395
- unset($xml);
396
  $update_previous = new PMXI_Import_Record();
397
  if ($post['is_update_previous'] and ! $update_previous->getById($post['update_previous'])->isEmpty()) {
398
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = $update_previous->id;
399
  PMXI_Plugin::$session['pmxi_import']['xpath'] = $update_previous->xpath;
400
  PMXI_Plugin::$session['pmxi_import']['template'] = $update_previous->template;
401
- PMXI_Plugin::$session['pmxi_import']['options'] = $update_previous->options;
402
  } else {
403
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = '';
404
  }
405
 
406
  pmxi_session_commit();
407
-
408
- wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
 
 
 
 
 
 
 
 
409
 
410
  } else {
411
  $this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
412
  if ( "" != PMXI_Plugin::$is_csv) $this->errors->add('form-validation', __('Probably your CSV feed contains HTML code. In this case, you can enable the <strong>"My CSV feed contains HTML code"</strong> option on the settings screen.', 'pmxi_plugin'));
413
  }
414
- }
 
 
415
 
416
  $this->render();
417
  }
@@ -459,7 +403,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
459
 
460
  } else {
461
 
462
- if (isset(PMXI_Plugin::$session->data['pmxi_import']['xpath']) and PMXI_Plugin::$session->data['pmxi_import']['large_file']) {
463
  $post['xpath'] = PMXI_Plugin::$session->data['pmxi_import']['xpath'];
464
  $this->data['elements'] = $elements = $xpath->query($post['xpath']);
465
  if ( ! $elements->length and ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])) {
@@ -477,7 +421,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
477
 
478
  // workaround to prevent rendered XML representation to eat memory since it has to be stored in momory when output is bufferred
479
  $this->render();
480
- add_action('pmxi_action_after', array($this, 'element_after'));
481
  }
482
  public function element_after()
483
  {
@@ -493,123 +437,113 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
493
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
494
  }
495
 
 
 
 
 
 
 
 
496
  $xpath = new DOMXPath($this->data['dom']);
497
- $post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'delimiter' => '', 'pointer' => 0, 'chunk' => 0));
498
  $wp_uploads = wp_upload_dir();
499
 
500
  if ('' == $post['xpath']) {
501
  $this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
502
  } else {
503
- // counting selected elements
504
- if (PMXI_Plugin::$session->data['pmxi_import']['large_file']){ // in large mode
505
-
506
- if ('' != $post['delimiter'] and $post['delimiter'] != PMXI_Plugin::$session->data['pmxi_import']['is_csv']) {
507
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
508
-
509
- PMXI_Plugin::$session['pmxi_import']['is_csv'] = $post['delimiter'];
510
 
511
- if (PMXI_Plugin::$session->data['pmxi_import']['source']['type'] != 'ftp'){
512
- $csv = new PMXI_CsvParser(PMXI_Plugin::$session->data['pmxi_import']['csv_path'], true, '', $post['delimiter']); // create chunks
 
 
 
 
 
 
 
 
513
  $filePath = $csv->xml_path;
514
- PMXI_Plugin::$session['pmxi_import']['filePath'] = $filePath;
515
- PMXI_Plugin::$session['pmxi_import']['local_paths'] = array($filePath);
516
- }
517
- else{
518
- $local_paths = array();
519
- foreach (PMXI_Plugin::$session->data['pmxi_import']['csv_paths'] as $key => $path) {
520
- $csv = new PMXI_CsvParser($path, true, '', $post['delimiter']); // create chunks
521
- $filePath = $csv->xml_path;
522
- if (!$key) PMXI_Plugin::$session['pmxi_import']['filePath'] = $filePath;
523
- $local_paths[] = $filePath;
524
- }
525
- PMXI_Plugin::$session['pmxi_import']['local_paths'] = $local_paths;
526
  }
 
527
  }
 
528
 
529
- // counting selected elements
530
- PMXI_Plugin::$session['pmxi_import']['xpath'] = $post['xpath'];
531
 
532
- if ($post['show_element'] == 1 and ! $post['pointer']) {
533
- PMXI_Plugin::$session['pmxi_import']['count'] = $this->data['node_list_count'] = 0;
534
- }else{
535
- if($post['show_element'] > 1 and ! $post['chunk'] ) $post['pointer'] = 0;
536
- $this->data['node_list_count'] = PMXI_Plugin::$session->data['pmxi_import']['count'];
537
- }
538
-
539
- $xpath_elements = explode('[', $post['xpath']);
540
- $xpath_parts = explode('/', $xpath_elements[0]);
541
-
542
- PMXI_Plugin::$session['pmxi_import']['source']['root_element'] = $xpath_parts[count($xpath_parts) - 1];
543
 
544
- pmxi_session_commit();
545
-
546
- $loop = $post['chunk'] * 100 + 1;
 
 
 
 
 
 
 
 
547
 
548
- foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
549
- $file = new PMXI_Chunk($path, array('element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'path' => $wp_uploads['path']), $post['pointer']);
550
- // loop through the file until all lines are read
551
- while ($xml = $file->read()) {
552
- if (!empty($xml))
553
- {
554
- $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
555
- PMXI_Import_Record::preprocessXml($xml);
556
-
557
- $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
558
- $old = libxml_use_internal_errors(true);
559
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
560
- libxml_use_internal_errors($old);
561
- $xpath = new DOMXPath($dom);
562
-
563
- if (($this->data['elements'] = $elements = @$xpath->query($post['xpath'])) and $elements->length){
564
- if ( $post['show_element'] == 1 ){
565
- $this->data['node_list_count'] += $elements->length;
566
- PMXI_Plugin::$session['pmxi_import']['count'] = $this->data['node_list_count'];
567
- }
568
-
569
- if ( $loop == $post['show_element'] ){
570
- $this->data['dom'] = $dom;
571
- if ($post['show_element'] > 1)
572
- break;
573
- }
574
- unset($dom, $xpath, $elements);
 
575
  }
 
 
576
 
577
- if ($loop % 100 == 0){
578
- exit( json_encode( array('result' => false, 'pointer' => $file->pointer, 'chunk' => ++$post['chunk'] ) ));
 
579
  }
580
 
581
- if ($this->data['elements']->length) $loop++;
582
- }
583
- }
584
- unset($file);
585
  }
586
- if ( ! $this->data['node_list_count']) {
587
- $this->errors->add('form-validation', __('No matching elements found for XPath expression specified', 'pmxi_plugin'));
588
- }
589
  }
590
- else{ // in default mode
591
- $this->data['elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
592
- $this->data['node_list_count'] = $elements->length;
593
- if (FALSE === $elements) {
594
- $this->errors->add('form-validation', __('Invalid XPath expression', 'pmxi_plugin'));
595
- } elseif ( ! $elements->length) {
596
- $this->errors->add('form-validation', __('No matching elements found for XPath expression specified', 'pmxi_plugin'));
597
- } else {
598
- foreach ($elements as $el) {
599
- if ( ! $el instanceof DOMElement) {
600
- $this->errors->add('form-validation', __('XPath must match only elements', 'pmxi_plugin'));
601
- break;
602
- };
603
- }
604
- }
605
- }
606
  }
607
 
608
  pmxi_session_commit();
609
 
610
- ob_start();
611
- if ( ! $this->errors->get_error_codes()) {
612
- //$this->shrink_xml_element($this->data['dom']->documentElement);
613
  $xpath = new DOMXPath($this->data['dom']);
614
  $this->data['elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
615
  $paths = array(); $this->data['paths'] =& $paths;
@@ -623,7 +557,16 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
623
  } else {
624
  $this->error();
625
  }
626
- exit( json_encode( array('result' => true, 'html' => ob_get_clean() ) ));
 
 
 
 
 
 
 
 
 
627
  }
628
 
629
  /**
@@ -635,17 +578,20 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
635
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
636
  }
637
 
638
- $xpath = new DOMXPath($this->data['dom']);
639
- $post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'tagno' => 0));
640
  $wp_uploads = wp_upload_dir();
641
 
 
 
 
 
642
  $this->data['tagno'] = max(intval($this->input->getpost('tagno', 1)), 0);
643
 
644
  if ('' == $post['xpath']) {
645
  $this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
646
  } else {
647
- $post['xpath'] = '/' . PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'] . '/'. ltrim(trim(str_replace("[*]","",$post['xpath']),'{}'), '/');
648
-
649
  // in default mode
650
  $this->data['variation_elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
651
  $this->data['variation_list_count'] = $elements->length;
@@ -663,9 +609,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
663
  }
664
  }
665
  if ( ! $this->errors->get_error_codes()) {
666
-
667
- //$xpath = new DOMXPath($this->data['dom']);
668
- //$this->data['variation_elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
669
  $paths = array(); $this->data['paths'] =& $paths;
670
  if (PMXI_Plugin::getInstance()->getOption('highlight_limit') and $elements->length <= PMXI_Plugin::getInstance()->getOption('highlight_limit')) {
671
  foreach ($elements as $el) {
@@ -699,15 +643,15 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
699
 
700
  if ($this->isWizard) {
701
  $this->data['post'] = $post = $this->input->post(
702
- (isset(PMXI_Plugin::$session->data['pmxi_import']['template']) ? PMXI_Plugin::$session->data['pmxi_import']['template'] : array())
703
- + $default
704
- );
705
  } else {
706
  $this->data['post'] = $post = $this->input->post(
707
- $this->data['import']->template
708
- + $default
709
  );
710
- }
711
 
712
  if (($load_template = $this->input->post('load_template'))) { // init form with template selected
713
  if ( ! $template->getById($load_template)->isEmpty()) {
@@ -731,9 +675,9 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
731
  $this->_validate_template($post['title'], 'Post title');
732
  }
733
 
734
- if ( ! empty($post['content'])) {
735
- /*$this->errors->add('form-validation', __('Post content is empty', 'pmxi_plugin'));
736
- } else {*/
737
  $this->_validate_template($post['content'], 'Post content');
738
  }
739
 
@@ -743,8 +687,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
743
  PMXI_Plugin::$session['pmxi_import']['saved_template'] = $template->id;
744
  }
745
  if ($this->isWizard) {
746
- PMXI_Plugin::$session['pmxi_import']['template'] = $post;
747
- pmxi_session_commit();
748
  wp_redirect(add_query_arg('action', 'options', $this->baseUrl)); die();
749
  } else {
750
  $this->data['import']->set('template', $post)->save();
@@ -767,8 +711,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
767
  }
768
  wp_enqueue_script('word-count');
769
  add_thickbox();
770
- wp_enqueue_script('media-upload');
771
- add_action('admin_print_footer_scripts', 'wp_tiny_mce', 25);
772
  wp_enqueue_script('quicktags');
773
  $this->render();
774
  }
@@ -811,24 +754,13 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
811
  $history_file = new PMXI_File_Record();
812
  $history_file->getBy('id', $history[0]['id']);
813
 
814
- if ($update_previous->large_import == 'Yes' and empty(PMXI_Plugin::$session->data['pmxi_import'])){
815
  PMXI_Plugin::$session['pmxi_import']['filePath'] = $history_file->path;
816
- if (!@file_exists($history_file->path)) PMXI_Plugin::$session['pmxi_import']['filePath'] = $wp_uploads['basedir'] . '/wpallimport_history/' . $history_file->id;
817
- PMXI_Plugin::$session['pmxi_import']['source']['root_element'] = $update_previous->root_element;
818
- PMXI_Plugin::$session['pmxi_import']['large_file'] = true;
819
  PMXI_Plugin::$session['pmxi_import']['count'] = $update_previous->count;
820
  PMXI_Plugin::$session['pmxi_import']['encoding'] = (!empty($update_previous->options['encoding'])) ? $update_previous->options['encoding'] : 'UTF-8';
821
  pmxi_session_commit();
822
- }
823
- /*else{
824
- $xml = @file_get_contents($history_file->path);
825
- $this->data['dom'] = $dom = new DOMDocument('1.0', 'UTF-8');
826
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml));
827
- $xpath = new DOMXPath($dom);
828
-
829
- $this->data['elements'] = $elements = $xpath->query($update_previous->xpath);
830
- if ( !$elements->length ) $this->data['elements'] = $elements = $xpath->query('.');
831
- }*/
832
  }
833
 
834
  } else {
@@ -838,36 +770,36 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
838
 
839
  $this->data['tagno'] = max(intval($this->input->getpost('tagno', 1)), 1);
840
 
841
- if (PMXI_Plugin::$session->data['pmxi_import']['large_file'] and $this->data['tagno']){
842
 
843
  PMXI_Plugin::$session['pmxi_import']['local_paths'] = $local_paths = (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) ? PMXI_Plugin::$session->data['pmxi_import']['local_paths'] : array(PMXI_Plugin::$session->data['pmxi_import']['filePath']);
844
 
845
- $loop = 1;
846
 
847
- foreach ($local_paths as $key => $path) {
 
848
  if (@file_exists($path)){
849
 
850
- $file = new PMXI_Chunk($path, array('element' => (!empty($update_previous->root_element)) ? $update_previous->root_element : ((!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'])));
851
  // loop through the file until all lines are read
852
  while ($xml = $file->read()) {
853
 
854
  if (!empty($xml))
855
- {
856
- $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
857
- PMXI_Import_Record::preprocessXml($xml);
858
 
859
- $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
860
  $old = libxml_use_internal_errors(true);
861
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
862
  libxml_use_internal_errors($old);
863
  $xpath = new DOMXPath($dom);
864
- if (($this->data['elements'] = $elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length){
865
- if ($loop == $this->data['tagno']){
866
- PMXI_Plugin::$session['pmxi_import']['pointer'] = $file->pointer;
867
- pmxi_session_commit();
868
- break;
869
- } else unset($dom, $xpath, $elements);
870
- $loop++;
871
  }
872
  }
873
  }
@@ -890,53 +822,56 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
890
  'is_keep_linebreaks' => 0,
891
  'is_leave_html' => 0,
892
  'fix_characters' => 0,
893
- 'import_encoding' => 'UFT-8'
 
894
  ));
895
  $wp_uploads = wp_upload_dir();
896
 
897
  $legacy_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
898
- $tagno = min(max(intval($this->input->getpost('tagno', 1)), 1), ( ! PMXI_Plugin::$session->data['pmxi_import']['large_file']) ? $this->data['elements']->length : PMXI_Plugin::$session->data['pmxi_import']['count']);
899
 
900
  $xml = '';
 
 
901
 
902
- if (PMXI_Plugin::$session->data['pmxi_import']['large_file']){
903
- $loop = 1;
904
- foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
905
 
906
- if (PMXI_Plugin::$session->data['pmxi_import']['encoding'] != $post['import_encoding'] and ! empty(PMXI_Plugin::$session->data['pmxi_import']['csv_paths'][$key])){
907
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
908
- $csv = new PMXI_CsvParser(PMXI_Plugin::$session->data['pmxi_import']['csv_paths'][$key], true, '', PMXI_Plugin::$is_csv, $post['import_encoding'], $path); // conver CSV to XML with selected encoding
909
- }
910
 
911
- $file = new PMXI_Chunk($path, array('element' => (!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'path' => $wp_uploads['path']));
912
- // loop through the file until all lines are read
913
- while ($xml = $file->read()) {
914
- if (!empty($xml))
915
- {
916
- $xml = "<?xml version=\"1.0\" encoding=\"". $post['import_encoding'] ."\"?>" . "\n" . $xml;
917
- PMXI_Import_Record::preprocessXml($xml);
918
- $dom = new DOMDocument('1.0', $post['import_encoding']);
919
- $old = libxml_use_internal_errors(true);
920
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
921
- libxml_use_internal_errors($old);
922
- $xpath = new DOMXPath($dom);
923
- if (($this->data['elements'] = $elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length){
924
- if ( $loop == $tagno )
925
- break;
926
- unset($dom, $xpath, $elements);
927
- $loop++;
928
- }
929
- }
930
- }
931
- unset($file);
932
  }
933
- $tagno = 1;
934
  }
935
- $xpath = "(" . PMXI_Plugin::$session->data['pmxi_import']['xpath'] . ")[$tagno]";
936
- //if ( "" != $xml){
937
- PMXI_Plugin::$session['pmxi_import']['encoding'] = $post['import_encoding'];
938
- pmxi_session_commit();
939
- //}
 
 
940
  // validate
941
  try {
942
  if (empty($xml)){
@@ -976,8 +911,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
976
  * Step #4: Options
977
  */
978
  public function options()
979
- {
980
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
981
 
982
  $default = PMXI_Plugin::get_default_import_options();
983
 
@@ -1010,73 +944,98 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1010
  }
1011
  }
1012
  }
 
 
 
 
1013
 
1014
- if ( class_exists('PMWI_Plugin') )
1015
- $post = $this->input->post(
1016
- (isset(PMXI_Plugin::$session->data['pmxi_import']['options']) ? PMXI_Plugin::$session->data['pmxi_import']['options'] : array())
1017
- + $default
1018
- + PMWI_Plugin::get_default_import_options()
1019
- );
1020
- else
1021
- $post = $this->input->post(
1022
- (isset(PMXI_Plugin::$session->data['pmxi_import']['options']) ? PMXI_Plugin::$session->data['pmxi_import']['options'] : array())
1023
- + $default
1024
- );
1025
-
1026
- $scheduled = $this->input->post(array(
1027
- 'is_scheduled' => ! empty(PMXI_Plugin::$session->data['pmxi_import']['scheduled']),
1028
- 'scheduled_period' => ! empty(PMXI_Plugin::$session->data['pmxi_import']['scheduled']) ? PMXI_Plugin::$session->data['pmxi_import']['scheduled'] : '0 0 * * *', // daily by default
1029
- ));
1030
 
1031
  } else {
1032
- $this->data['source_type'] = $this->data['import']->type;
1033
- if ( class_exists('PMWI_Plugin') )
1034
- $post = $this->input->post(
1035
- $this->data['import']->options
1036
- + $default
1037
- + PMWI_Plugin::get_default_import_options()
1038
- );
1039
- else
1040
- $post = $this->input->post(
1041
- $this->data['import']->options
1042
- + $default
1043
- );
1044
- $scheduled = $this->input->post(array(
1045
- 'is_scheduled' => ! empty($this->data['import']->scheduled),
1046
- 'scheduled_period' => ! empty($this->data['import']->scheduled) ? $this->data['import']->scheduled : '0 0 * * *', // daily by default
1047
- ));
1048
  }
1049
 
1050
- $this->data['post'] =& $post;
1051
- $this->data['scheduled'] =& $scheduled;
1052
 
1053
  // Get All meta keys in the system
1054
  $this->data['meta_keys'] = $keys = new PMXI_Model_List();
1055
  $keys->setTable(PMXI_Plugin::getInstance()->getWPPrefix() . 'postmeta');
1056
- $keys->setColumns('meta_id', 'meta_key')->getBy(NULL, "meta_id", NULL, NULL, "meta_key");
1057
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1058
  $load_template = $this->input->post('load_template');
1059
  if ($load_template) { // init form with template selected
1060
  PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = $load_template;
1061
  $template = new PMXI_Template_Record();
1062
  if ( ! $template->getById($load_template)->isEmpty()) {
1063
- $post = (!empty($template->options) ? $template->options : array()) + $default;
1064
- $scheduled = array(
1065
- 'is_scheduled' => ! empty($template->scheduled),
1066
- 'scheduled_period' => ! empty($template->scheduled) ? $template->scheduled : '0 0 * * *', // daily by default
1067
- );
1068
  }
1069
  } elseif ($load_template == -1){
1070
  PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = 0;
1071
 
1072
- $post = $default;
1073
- $scheduled = $this->input->post(array(
1074
- 'is_scheduled' => ! empty($post['scheduled']),
1075
- 'scheduled_period' => ! empty($post['scheduled']) ? $post['scheduled_period'] : '0 0 * * *', // daily by default
1076
- ));
1077
 
1078
- } elseif ($this->input->post('is_submitted')) {
1079
- check_admin_referer('options', '_wpnonce_options');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1080
 
1081
  if ( $post['type'] == "post" and $post['custom_type'] == "product" and class_exists('PMWI_Plugin')){
1082
  // remove entires where both custom_name and custom_value are empty
@@ -1105,6 +1064,14 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1105
  if ('post' == $post['type']) {
1106
  /*'' == $post['categories'] or $this->_validate_template($post['categories'], __('Categories', 'pmxi_plugin'));*/
1107
  '' == $post['tags'] or $this->_validate_template($post['tags'], __('Tags', 'pmxi_plugin'));
 
 
 
 
 
 
 
 
1108
  }
1109
  if ('specific' == $post['date_type']) {
1110
  '' == $post['date'] or $this->_validate_template($post['date'], __('Date', 'pmxi_plugin'));
@@ -1124,7 +1091,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1124
  if ( ! preg_match('%^([1-9]\d*)( *- *([1-9]\d*))?$%', $chank, $mtch)) {
1125
  $this->errors->add('form-validation', __('Wrong format of `Import only specified records` value', 'pmxi_plugin'));
1126
  break;
1127
- } elseif ($this->isWizard and empty(PMXI_Plugin::$session->data['pmxi_import']['large_file']) and (intval($mtch[1]) > $this->data['elements']->length or isset($mtch[3]) and intval($mtch[3]) > $this->data['elements']->length)) {
1128
  $this->errors->add('form-validation', __('One of the numbers in `Import only specified records` value exceeds record quantity in XML file', 'pmxi_plugin'));
1129
  break;
1130
  }
@@ -1142,6 +1109,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1142
  if ('' == $post['custom_duplicate_value'])
1143
  $this->errors->add('form-validation', __('Custom field value must be specified.', 'pmxi_plugin'));
1144
  }
 
 
1145
 
1146
  if ( ! $this->errors->get_error_codes()) { // no validation errors found
1147
  // assign some defaults
@@ -1154,14 +1123,12 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1154
 
1155
  $template->getByName($this->input->post('name'))->set(array(
1156
  'name' => $this->input->post('name'),
1157
- 'options' => $post,
1158
- 'scheduled' => (($scheduled['is_scheduled']) ? $scheduled['scheduled_period'] : '')
1159
  ))->save();
1160
  }
1161
 
1162
  if ($this->isWizard) {
1163
  PMXI_Plugin::$session['pmxi_import']['options'] = $post;
1164
- PMXI_Plugin::$session['pmxi_import']['scheduled'] = $scheduled['is_scheduled'] ? $scheduled['scheduled_period'] : '';
1165
 
1166
  pmxi_session_commit();
1167
 
@@ -1176,7 +1143,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1176
  'xpath' => PMXI_Plugin::$session->data['pmxi_import']['xpath'],
1177
  'template' => PMXI_Plugin::$session->data['pmxi_import']['template'],
1178
  'options' => PMXI_Plugin::$session->data['pmxi_import']['options'],
1179
- 'scheduled' => PMXI_Plugin::$session->data['pmxi_import']['scheduled'],
1180
  'count' => PMXI_Plugin::$session->data['pmxi_import']['count'],
1181
  'friendly_name' => $this->data['post']['friendly_name'],
1182
  )
@@ -1187,19 +1154,17 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1187
  'name' => $import->name,
1188
  'import_id' => $import->id,
1189
  'path' => PMXI_Plugin::$session->data['pmxi_import']['filePath'],
1190
- 'contents' => $this->get_xml(), //PMXI_Plugin::$session->data['pmxi_import']['xml'],
1191
  'registered_on' => date('Y-m-d H:i:s'),
1192
  ))->save();
1193
 
1194
- pmxi_session_unset();
1195
-
1196
- //unset(PMXI_Plugin::$session->data['pmxi_import']); // clear session data
1197
 
1198
  wp_redirect(add_query_arg(array('page' => 'pmxi-admin-manage', 'pmlc_nt' => urlencode($is_update ? __('Import updated', 'pmxi_plugin') : __('Import created', 'pmxi_plugin'))), admin_url('admin.php'))); die();
1199
  }
1200
  } else {
1201
 
1202
- $this->data['import']->set('options', $post)->set( array( 'scheduled' => $scheduled['is_scheduled'] ? $scheduled['scheduled_period'] : '', 'friendly_name' => $this->data['post']['friendly_name'] ) )->save();
1203
 
1204
  wp_redirect(add_query_arg(array('page' => 'pmxi-admin-manage', 'pmlc_nt' => urlencode(__('Options updated', 'pmxi_plugin'))) + array_intersect_key($_GET, array_flip($this->baseUrlParamNames)), admin_url('admin.php'))); die();
1205
  }
@@ -1216,45 +1181,50 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1216
  pmxi_session_commit();
1217
 
1218
  $this->render();
1219
- }
1220
 
1221
  /**
1222
  * Import processing step (status console)
1223
  */
1224
  public function process($save_history = true)
1225
  {
1226
- $wp_uploads = wp_upload_dir();
1227
- @set_time_limit(0);
1228
  $import = $this->data['update_previous'];
1229
  $logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m))) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
1230
 
1231
- if ( ! PMXI_Plugin::is_ajax()) {
1232
- // Save import history
1233
-
1234
- PMXI_Plugin::$session['pmxi_import']['pointer'] = 0;
1235
- pmxi_session_commit();
1236
 
1237
  $import->set(
1238
  (empty(PMXI_Plugin::$session->data['pmxi_import']['source']) ? array() : PMXI_Plugin::$session->data['pmxi_import']['source'])
1239
  + array(
1240
  'xpath' => PMXI_Plugin::$session->data['pmxi_import']['xpath'],
1241
  'template' => PMXI_Plugin::$session->data['pmxi_import']['template'],
1242
- 'options' => PMXI_Plugin::$session->data['pmxi_import']['options'],
1243
- 'scheduled' => PMXI_Plugin::$session->data['pmxi_import']['scheduled'],
1244
  'count' => PMXI_Plugin::$session->data['pmxi_import']['count'],
1245
  'friendly_name' => PMXI_Plugin::$session->data['pmxi_import']['options']['friendly_name'],
1246
- 'feed_type' => PMXI_Plugin::$session->data['pmxi_import']['feed_type']
 
 
 
 
1247
  )
1248
- );
1249
-
1250
- // store import info in database
1251
- $import->set(array(
1252
- 'imported' => 0,
1253
- 'created' => 0,
1254
- 'updated' => 0,
1255
- 'skipped' => 0
1256
- ))->save();
1257
-
 
 
 
 
 
 
1258
  do_action( 'pmxi_before_xml_import', $import->id );
1259
 
1260
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = $import->id;
@@ -1278,79 +1248,206 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1278
  'import_id' => $import->id,
1279
  'path' => PMXI_Plugin::$session->data['pmxi_import']['filePath'],
1280
  'contents' => $this->get_xml(),
1281
- 'registered_on' => date('Y-m-d H:i:s'),
1282
  ))->save();
1283
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1284
 
1285
  $this->render();
1286
- wp_ob_end_flush_all(); flush();
 
1287
 
1288
- }
 
1289
  elseif (empty($import->id)){
1290
  $import = new PMXI_Import_Record();
1291
  $import->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
1292
- }
 
 
1293
 
1294
  PMXI_Plugin::$session['pmxi_import']['start_time'] = (empty(PMXI_Plugin::$session->data['pmxi_import']['start_time'])) ? time() : PMXI_Plugin::$session->data['pmxi_import']['start_time'];
1295
 
1296
- if (PMXI_Plugin::is_ajax()) {
1297
-
1298
- PMXI_Plugin::$session['pmxi_import']['current_post_ids'] = (empty(PMXI_Plugin::$session->data['pmxi_import']['current_post_ids'])) ? array() : PMXI_Plugin::$session->data['pmxi_import']['current_post_ids'];
1299
- PMXI_Plugin::$session['pmxi_import']['pointer'] = (empty(PMXI_Plugin::$session->data['pmxi_import']['pointer'])) ? 0 : PMXI_Plugin::$session->data['pmxi_import']['pointer'];
1300
- pmxi_session_commit();
1301
 
1302
- $loop = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
 
1304
  if (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])){
1305
 
1306
- foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
 
 
1307
 
1308
- $file = new PMXI_Chunk($path, array('element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'path' => $wp_uploads['path']), PMXI_Plugin::$session->data['pmxi_import']['pointer']);
1309
 
 
 
 
 
 
 
 
 
1310
  // loop through the file until all lines are read
1311
  while ($xml = $file->read()) {
1312
- if (!empty($xml))
 
1313
  {
1314
- $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
1315
  PMXI_Import_Record::preprocessXml($xml);
 
1316
 
1317
- $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
1318
- $old = libxml_use_internal_errors(true);
1319
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
1320
  libxml_use_internal_errors($old);
1321
  $xpath = new DOMXPath($dom);
1322
- if (($this->data['elements'] = $elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length){
1323
- PMXI_Plugin::$session['pmxi_import']['pointer'] = $file->pointer;
1324
- if ( ! $loop ) ob_start();
1325
- do_action('pmxi_before_post_import', $import->id);
1326
- $import->process($xml, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number']);
1327
- do_action('pmxi_after_post_import', $import->id);
1328
- if (($import->created + $import->updated + $import->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'] == $import->count) and !in_array($import->type, array('ftp'))){
1329
- PMXI_Plugin::$session['pmxi_import']['pointer'] = 0;
1330
- array_shift(PMXI_Plugin::$session->data['pmxi_import']['local_paths']);
1331
- PMXI_Plugin::$session['pmxi_import']['local_paths'] = PMXI_Plugin::$session->data['pmxi_import']['local_paths'];
1332
- unset($dom, $xpath);
1333
- pmxi_session_commit();
1334
- exit(ob_get_clean());
1335
- }
1336
- if ( $loop == PMXI_Plugin::$session->data['pmxi_import']['options']['records_per_request'] - 1 ) exit(ob_get_clean());
1337
- $loop++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1338
  }
1339
- }
1340
-
1341
- if (($import->created + $import->updated + $import->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'] == $import->count) and !in_array($import->type, array('ftp'))){
1342
- PMXI_Plugin::$session['pmxi_import']['pointer'] = 0;
1343
- array_shift(PMXI_Plugin::$session->data['pmxi_import']['local_paths']);
1344
- PMXI_Plugin::$session['pmxi_import']['local_paths'] = PMXI_Plugin::$session->data['pmxi_import']['local_paths'];
1345
- pmxi_session_commit();
1346
- exit(ob_get_clean());
1347
- }
1348
- }
 
 
 
 
1349
  }
1350
  }
1351
  }
1352
-
1353
- if ( ! PMXI_Plugin::$session->data['pmxi_import']['large_file'] or PMXI_Plugin::is_ajax()){
1354
 
1355
  // Save import process log
1356
  $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
@@ -1365,27 +1462,24 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1365
  _get_term_hierarchy( $tax );
1366
  }
1367
 
 
 
1368
  // clear import session
1369
  pmxi_session_unset(); // clear session data (prevent from reimporting the same data on page refresh)
1370
 
1371
  // [indicate in header process is complete]
1372
  $msg = addcslashes(__('Complete', 'pmxi_plugin'), "\n\r");
1373
 
1374
- ob_start();
1375
 
1376
- echo '<a id="download_pmxi_log" class="update" href="'.esc_url(add_query_arg(array('id' => $import->id, 'action' => 'log', 'page' => 'pmxi-admin-manage'), $this->baseUrl)).'">'.__('Download log','pmxi_plugin').'</a>';
1377
 
1378
  echo <<<COMPLETE
1379
  <script type="text/javascript">
1380
  //<![CDATA[
1381
- (function($){
1382
- var percents = $('.import_percent:last').html();
1383
- if (percents != null && percents != ''){
1384
- $('#center_progress').html($('.import_process_bar:last').html());
1385
- $('#right_progress').html(percents + '%');
1386
- $('#progressbar div').css({'width': ((parseInt(percents) > 100) ? 100 : percents) + '%'});
1387
- }
1388
- $('#status').attr('rel',1).html('$msg');
1389
  window.onbeforeunload = false;
1390
  })(jQuery);
1391
  //]]>
@@ -1393,10 +1487,21 @@ echo <<<COMPLETE
1393
  COMPLETE;
1394
  // [/indicate in header process is complete]
1395
 
1396
- exit(ob_get_clean());
 
 
 
 
 
 
 
 
 
 
1397
 
 
1398
  }
1399
- }
1400
 
1401
  protected $_sibling_limit = 20;
1402
  protected function get_xml_path(DOMElement $el, DOMXPath $xpath)
@@ -1492,6 +1597,23 @@ COMPLETE;
1492
  }
1493
  echo '</div>';
1494
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1495
  protected $_unique_key = array();
1496
  protected function find_unique_key(DOMElement $el){
1497
  if ($el->hasChildNodes()) {
@@ -1643,42 +1765,52 @@ COMPLETE;
1643
  $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
1644
  }
1645
 
1646
- protected function get_xml(){
1647
  $xml = '';
 
1648
  $wp_uploads = wp_upload_dir();
1649
  $update_previous = new PMXI_Import_Record();
1650
 
1651
- if ( !empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']))
1652
- $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
1653
 
1654
- if (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) {
 
 
1655
  foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
1656
 
1657
  if ( @file_exists($path) ){
1658
 
1659
  $root_element = ( ! $update_previous->isEmpty() ) ? $update_previous->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'];
1660
 
1661
- $file = new PMXI_Chunk($path, array('element' => $root_element, 'path' => $wp_uploads['path']), (!empty(PMXI_Plugin::$session->data['pmxi_import']['pointer'])) ? PMXI_Plugin::$session->data['pmxi_import']['pointer'] : 0);
1662
- while ($xml = $file->read()) {
1663
- if (!empty($xml))
1664
- {
1665
- $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
1666
- PMXI_Import_Record::preprocessXml($xml);
1667
 
1668
- if ( '' != PMXI_Plugin::$session->data['pmxi_import']['xpath']){
 
 
 
 
 
 
 
1669
  $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
1670
  $old = libxml_use_internal_errors(true);
1671
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
1672
  libxml_use_internal_errors($old);
1673
- $xpath = new DOMXPath($dom);
1674
- if (($elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length) break;
 
 
 
 
1675
  }
1676
  else break;
1677
  }
1678
  }
 
 
1679
  }
1680
- }
1681
- }
1682
  return $xml;
1683
  }
1684
- }
10
  protected $isTemplateEdit = false; // indicates whether controlled is deligated by manage imports controller
11
 
12
  protected function init() {
13
+ parent::init();
14
 
15
  if ('PMXI_Admin_Manage' == PMXI_Plugin::getInstance()->getAdminCurrentScreen()->base) { // prereqisites are not checked when flow control is deligated
16
  $id = $this->input->get('id');
30
 
31
  // preserve id parameter as part of baseUrl
32
  $id = $this->input->get('id') and $this->baseUrl = add_query_arg('id', $id, $this->baseUrl);
33
+
34
+ $this->baseUrl = apply_filters('pmxi_base_url', $this->baseUrl);
35
  }
36
 
37
  public function set($var, $val)
55
  $this->data['dom'] = $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
56
  $this->data['update_previous'] = $update_previous = new PMXI_Import_Record();
57
  $old = libxml_use_internal_errors(true);
58
+
 
 
 
 
 
59
  $xml = $this->get_xml();
60
 
61
  if (empty($xml) and in_array($action, array('process')) ){
64
  }
65
 
66
  if (empty(PMXI_Plugin::$session->data['pmxi_import'])
67
+ or ! @$dom->loadXML($xml)// FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
68
  //or empty(PMXI_Plugin::$session['pmxi_import']['source'])
69
  or ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous']) and $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])->isEmpty()
70
  ) {
110
 
111
  $this->data['reimported_import'] = $import = new PMXI_Import_Record();
112
  $this->data['id'] = $id = $this->input->get('id');
113
+ $this->data['parent_import'] = $parent_import = $this->input->get('parent_import');
114
  if ($id and $import->getById($id)->isEmpty()) { // update requested but corresponding import is not found
115
  wp_redirect(remove_query_arg('id', $this->baseUrl)); die();
116
  }
124
  'reimport' => '',
125
  'is_update_previous' => $id ? 1 : 0,
126
  'update_previous' => $id,
127
+ 'xpath' => '/',
 
128
  'filepath' => '',
129
  'root_element' => ''
130
+ ));
131
 
132
  if ($this->input->post('is_submitted_continue')) {
133
  if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) {
156
  $filePath = '';
157
 
158
  if (!empty($v_result_list)){
159
+ foreach ($v_result_list as $unzipped_file) {
160
+ if ($unzipped_file['status'] == 'ok' and preg_match('%\W(xml|csv|txt|dat|psv)$%i', trim($unzipped_file['stored_filename']))) { $filePath = $unzipped_file['filename']; break; }
161
  }
162
  }
163
  if($uploads['error']){
185
  }
186
  }
187
 
188
+ // Detect if file is very large
 
189
  $source = array(
190
  'name' => basename($post['filepath']),
191
  'type' => 'upload',
197
  if($uploads['error']){
198
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
199
  }
200
+
201
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
202
+ $csv = new PMXI_CsvParser($filePath, true); // create chunks
203
+ $filePath = $csv->xml_path;
204
+ $post['root_element'] = 'node';
205
+
 
 
 
206
  }
207
  }
208
 
209
  } elseif ( preg_match('%\W(csv|txt|dat|psv)$%i', trim($post['filepath']))) { // If CSV file uploaded
210
 
211
+ // Detect if file is very large
 
 
212
  if($uploads['error']){
213
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
214
  }
217
  'name' => basename($post['filepath']),
218
  'type' => 'upload',
219
  'path' => $filePath,
220
+ );
221
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
222
+ $csv = new PMXI_CsvParser($post['filepath'], true);
223
+ $filePath = $csv->xml_path;
224
+ $post['root_element'] = 'node';
225
+
 
 
 
226
  } elseif(preg_match('%\W(gz)$%i', trim($post['filepath']))){ // If gz file uploaded
227
  $fileInfo = pmxi_gzfile_get_contents($post['filepath']);
228
  $filePath = $fileInfo['localPath'];
229
 
230
+ // Detect if file is very large
 
 
231
  $source = array(
232
  'name' => basename($post['filepath']),
233
  'type' => 'upload',
236
 
237
  // detect CSV or XML
238
  if ( $fileInfo['type'] == 'csv') { // it is CSV file
239
+
240
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
241
+ $csv = new PMXI_CsvParser($filePath, true); // create chunks
242
+ $filePath = $csv->xml_path;
243
+ $post['root_element'] = 'node';
244
+
 
 
 
245
  }
246
  } else { // If XML file uploaded
247
 
248
  // Detect if file is very large
 
 
249
  $filePath = $post['filepath'];
250
  $source = array(
251
  'name' => basename($post['filepath']),
257
  elseif ($this->input->post('is_submitted')){
258
 
259
  $this->errors->add('form-validation', __('Upgrade to the paid edition of WP All Import to use this feature.', 'pmxi_plugin'));
260
+ }
261
 
262
  if ($post['is_update_previous'] and empty($post['update_previous'])) {
263
  $this->errors->add('form-validation', __('Previous import for update must be selected to proceed with a new one', 'pmxi_plugin'));
264
  }
 
 
 
 
 
 
265
 
266
+ $this->data['detection_feed_extension'] = false;
267
 
268
+ if ( ! class_exists('DOMDocument') ) {
269
+ $this->errors->add('form-validation', __('Class \'DOMDocument\' not found.', 'pmxi_plugin'));
270
+ }
271
+ if ( ! class_exists('XMLReader') ) {
272
+ $this->errors->add('form-validation', __('Class \'XMLReader\' not found.', 'pmxi_plugin'));
273
+ }
274
+
275
+ if ($this->input->post('is_submitted') and ! $this->errors->get_error_codes()) {
276
 
277
+ check_admin_referer('choose-file', '_wpnonce_choose-file');
278
+ $elements_cloud = array();
279
+ @set_time_limit(0);
280
+ $local_paths = !empty($local_paths) ? $local_paths : array($filePath);
281
+
282
+ foreach ($local_paths as $key => $path) {
283
+
284
+ if ( @file_exists($path) ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
+ $file = new PMXI_Chunk($path, array('element' => $post['root_element']));
287
 
288
+ if ( ! empty($file->options['element']) ) {
289
+ $xpath = "/".$file->options['element'];
290
+ $elements_cloud = $file->cloud;
291
+ break;
 
 
 
 
292
  }
293
+ else $this->errors->add('form-validation', __('Unable to find root element for this feed. Please open the feed in your browser or a text editor and ensure it is a valid feed.', 'pmxi_plugin'));
294
+
 
 
 
 
 
 
 
 
 
 
295
  }
296
+ else $this->errors->add('form-validation', __('Unable to download feed resource.', 'pmxi_plugin'));
297
+ }
298
 
299
+ if ( ! $this->errors->get_error_codes() ) {
300
 
301
+ // xml is valid
302
+ $source['root_element'] = $file->options['element'];
303
+ $source['first_import'] = date("Y-m-d H:i:s");
304
+ pmxi_session_unset();
 
 
305
 
306
  PMXI_Plugin::$session['pmxi_import'] = array(
307
  'filePath' => $filePath,
308
+ 'parent_import_id' => $parent_import,
309
  'xpath' => (!empty($xpath)) ? $xpath : '',
310
  'feed_type' => $post['feed_type'],
311
+ 'source' => $source,
312
+ 'encoding' => 'UTF-8',//$file->options['encoding'],
 
313
  'is_csv' => PMXI_Plugin::$is_csv,
314
  'csv_path' => PMXI_Plugin::$csv_path,
315
  'chunk_number' => 1,
316
+ 'log' => '',
 
317
  'processing' => 0,
318
  'queue_chunk_number' => 0,
319
+ 'count' => (isset($chunks)) ? $chunks : 0,
 
 
 
320
  'warnings' => 0,
321
  'errors' => 0,
322
  'start_time' => 0,
323
  'local_paths' => (!empty($local_paths)) ? $local_paths : array(), // ftp import local copies of remote files
324
  'csv_paths' => (!empty($csv_paths)) ? $csv_paths : array(PMXI_Plugin::$csv_path), // ftp import local copies of remote CSV files
325
  'action' => 'import',
326
+ 'elements_cloud' => (!empty($elements_cloud)) ? $elements_cloud : array(),
327
+ 'pointer' => 1
328
  );
329
+
 
330
  $update_previous = new PMXI_Import_Record();
331
  if ($post['is_update_previous'] and ! $update_previous->getById($post['update_previous'])->isEmpty()) {
332
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = $update_previous->id;
333
  PMXI_Plugin::$session['pmxi_import']['xpath'] = $update_previous->xpath;
334
  PMXI_Plugin::$session['pmxi_import']['template'] = $update_previous->template;
335
+ PMXI_Plugin::$session['pmxi_import']['options'] = $update_previous->options;
336
  } else {
337
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = '';
338
  }
339
 
340
  pmxi_session_commit();
341
+
342
+ $xml = $this->get_xml();
343
+ if (empty($xml))
344
+ {
345
+ $this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
346
+ if ( "" != PMXI_Plugin::$is_csv) $this->errors->add('form-validation', __('Probably your CSV feed contains HTML code. In this case, you can enable the <strong>"My CSV feed contains HTML code"</strong> option on the settings screen.', 'pmxi_plugin'));
347
+ }
348
+ else{
349
+ wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
350
+ }
351
 
352
  } else {
353
  $this->errors->add('form-validation', __('Please confirm you are importing a valid feed.<br/> Often, feed providers distribute feeds with invalid data, improperly wrapped HTML, line breaks where they should not be, faulty character encodings, syntax errors in the XML, and other issues.<br/><br/>WP All Import has checks in place to automatically fix some of the most common problems, but we can’t catch every single one.<br/><br/>It is also possible that there is a bug in WP All Import, and the problem is not with the feed.<br/><br/>If you need assistance, please contact support – <a href="mailto:support@soflyy.com">support@soflyy.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
354
  if ( "" != PMXI_Plugin::$is_csv) $this->errors->add('form-validation', __('Probably your CSV feed contains HTML code. In this case, you can enable the <strong>"My CSV feed contains HTML code"</strong> option on the settings screen.', 'pmxi_plugin'));
355
  }
356
+
357
+ do_action("pmxi_get_file", $filePath);
358
+ }
359
 
360
  $this->render();
361
  }
403
 
404
  } else {
405
 
406
+ if (isset(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) {
407
  $post['xpath'] = PMXI_Plugin::$session->data['pmxi_import']['xpath'];
408
  $this->data['elements'] = $elements = $xpath->query($post['xpath']);
409
  if ( ! $elements->length and ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])) {
421
 
422
  // workaround to prevent rendered XML representation to eat memory since it has to be stored in momory when output is bufferred
423
  $this->render();
424
+ //add_action('pmxi_action_after', array($this, 'element_after'));
425
  }
426
  public function element_after()
427
  {
437
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
438
  }
439
 
440
+ // HTTP headers for no cache etc
441
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
442
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
443
+ header("Cache-Control: no-store, no-cache, must-revalidate");
444
+ header("Cache-Control: post-check=0, pre-check=0", false);
445
+ header("Pragma: no-cache");
446
+
447
  $xpath = new DOMXPath($this->data['dom']);
448
+ $post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'delimiter' => ''));
449
  $wp_uploads = wp_upload_dir();
450
 
451
  if ('' == $post['xpath']) {
452
  $this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
453
  } else {
454
+ // counting selected elements
455
+ if ('' != $post['delimiter'] and $post['delimiter'] != PMXI_Plugin::$session->data['pmxi_import']['is_csv']) {
456
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
457
+
458
+ PMXI_Plugin::$session['pmxi_import']['is_csv'] = $post['delimiter'];
 
 
459
 
460
+ if (PMXI_Plugin::$session->data['pmxi_import']['source']['type'] != 'ftp'){
461
+ $csv = new PMXI_CsvParser(PMXI_Plugin::$session->data['pmxi_import']['csv_path'], true, '', $post['delimiter']); // create chunks
462
+ $filePath = $csv->xml_path;
463
+ PMXI_Plugin::$session['pmxi_import']['filePath'] = $filePath;
464
+ PMXI_Plugin::$session['pmxi_import']['local_paths'] = array($filePath);
465
+ }
466
+ else{
467
+ $local_paths = array();
468
+ foreach (PMXI_Plugin::$session->data['pmxi_import']['csv_paths'] as $key => $path) {
469
+ $csv = new PMXI_CsvParser($path, true, '', $post['delimiter']); // create chunks
470
  $filePath = $csv->xml_path;
471
+ if (!$key) PMXI_Plugin::$session['pmxi_import']['filePath'] = $filePath;
472
+ $local_paths[] = $filePath;
 
 
 
 
 
 
 
 
 
 
473
  }
474
+ PMXI_Plugin::$session['pmxi_import']['local_paths'] = $local_paths;
475
  }
476
+ }
477
 
478
+ // counting selected elements
479
+ PMXI_Plugin::$session['pmxi_import']['xpath'] = $post['xpath'];
480
 
481
+ $current_xpath = '';
 
 
 
 
 
 
 
 
 
 
482
 
483
+ if ($post['show_element'] == 1) {
484
+ PMXI_Plugin::$session['pmxi_import']['count'] = $this->data['node_list_count'] = 0;
485
+ }else{
486
+ $this->data['node_list_count'] = PMXI_Plugin::$session->data['pmxi_import']['count'];
487
+ //$post['xpath'] .= '[' . $post['show_element'] . ']';
488
+ }
489
+
490
+ $xpath_elements = explode('[', $post['xpath']);
491
+ $xpath_parts = explode('/', $xpath_elements[0]);
492
+
493
+ PMXI_Plugin::$session['pmxi_import']['source']['root_element'] = $xpath_parts[1];
494
 
495
+ pmxi_session_commit();
496
+
497
+ $loop = 0;
498
+
499
+ foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
500
+
501
+ $file = new PMXI_Chunk($path, array('element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'encoding' => PMXI_Plugin::$session->data['pmxi_import']['encoding']));
502
+
503
+ // loop through the file until all lines are read
504
+ while ($xml = $file->read()) {
505
+
506
+ if (!empty($xml))
507
+ {
508
+ PMXI_Import_Record::preprocessXml($xml);
509
+ $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
510
+
511
+ $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
512
+ $old = libxml_use_internal_errors(true);
513
+ $dom->loadXML($xml);
514
+ libxml_use_internal_errors($old);
515
+ $xpath = new DOMXPath($dom);
516
+
517
+ if (($elements = @$xpath->query($post['xpath'])) and $elements->length){
518
+
519
+ if ( $post['show_element'] == 1 ){
520
+ $this->data['node_list_count'] += $elements->length;
521
+ PMXI_Plugin::$session['pmxi_import']['count'] = $this->data['node_list_count'];
522
+ if (!$loop) $this->data['dom'] = $dom;
523
  }
524
+
525
+ $loop += $elements->length;
526
 
527
+ if ( $post['show_element'] > 1 and $loop == $post['show_element']) {
528
+ $this->data['dom'] = $dom;
529
+ break(2);
530
  }
531
 
532
+ unset($dom, $xpath, $elements);
533
+ }
534
+ }
 
535
  }
536
+ unset($file);
 
 
537
  }
538
+ if ( ! $this->data['node_list_count']) {
539
+ $this->errors->add('form-validation', __('No matching elements found for XPath expression specified', 'pmxi_plugin'));
540
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
541
  }
542
 
543
  pmxi_session_commit();
544
 
545
+ ob_start();
546
+ if ( ! $this->errors->get_error_codes()) {
 
547
  $xpath = new DOMXPath($this->data['dom']);
548
  $this->data['elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
549
  $paths = array(); $this->data['paths'] =& $paths;
557
  } else {
558
  $this->error();
559
  }
560
+
561
+ $html = ob_get_clean();
562
+
563
+ ob_start();
564
+
565
+ if ( ! empty($elements->length) ) $this->render_xml_elements_for_filtring($elements->item(0));
566
+
567
+ $render_element = ob_get_clean();
568
+
569
+ exit( json_encode( array('result' => true, 'html' => $html, 'root_element' => PMXI_Plugin::$session['pmxi_import']['source']['root_element'], 'render_element' => $render_element )));
570
  }
571
 
572
  /**
578
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
579
  }
580
 
581
+ $post = $this->input->post(array('xpath' => '', 'show_element' => 1, 'root_element' => PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'tagno' => 0, 'parent_tagno' => 1));
 
582
  $wp_uploads = wp_upload_dir();
583
 
584
+ $this->get_xml( $post['parent_tagno'] );
585
+
586
+ $xpath = new DOMXPath($this->data['dom']);
587
+
588
  $this->data['tagno'] = max(intval($this->input->getpost('tagno', 1)), 0);
589
 
590
  if ('' == $post['xpath']) {
591
  $this->errors->add('form-validation', __('No elements selected', 'pmxi_plugin'));
592
  } else {
593
+ $post['xpath'] = '/' . ((!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']) .'/'. ltrim(trim(str_replace("[*]","",$post['xpath']),'{}'), '/');
594
+
595
  // in default mode
596
  $this->data['variation_elements'] = $elements = @ $xpath->query($post['xpath']); // prevent parsing warning to be displayed
597
  $this->data['variation_list_count'] = $elements->length;
609
  }
610
  }
611
  if ( ! $this->errors->get_error_codes()) {
612
+
 
 
613
  $paths = array(); $this->data['paths'] =& $paths;
614
  if (PMXI_Plugin::getInstance()->getOption('highlight_limit') and $elements->length <= PMXI_Plugin::getInstance()->getOption('highlight_limit')) {
615
  foreach ($elements as $el) {
643
 
644
  if ($this->isWizard) {
645
  $this->data['post'] = $post = $this->input->post(
646
+ apply_filters('pmxi_template_options', (isset(PMXI_Plugin::$session->data['pmxi_import']['template']) ? PMXI_Plugin::$session->data['pmxi_import']['template'] : array())
647
+ + $default, $this->isWizard)
648
+ );
649
  } else {
650
  $this->data['post'] = $post = $this->input->post(
651
+ apply_filters('pmxi_template_options', $this->data['import']->template
652
+ + $default, $this->isWizard)
653
  );
654
+ }
655
 
656
  if (($load_template = $this->input->post('load_template'))) { // init form with template selected
657
  if ( ! $template->getById($load_template)->isEmpty()) {
675
  $this->_validate_template($post['title'], 'Post title');
676
  }
677
 
678
+ if (empty($post['content'])) {
679
+ $this->errors->add('form-validation', __('Post content is empty', 'pmxi_plugin'));
680
+ } else {
681
  $this->_validate_template($post['content'], 'Post content');
682
  }
683
 
687
  PMXI_Plugin::$session['pmxi_import']['saved_template'] = $template->id;
688
  }
689
  if ($this->isWizard) {
690
+ PMXI_Plugin::$session['pmxi_import']['template'] = $post;
691
+ pmxi_session_commit();
692
  wp_redirect(add_query_arg('action', 'options', $this->baseUrl)); die();
693
  } else {
694
  $this->data['import']->set('template', $post)->save();
711
  }
712
  wp_enqueue_script('word-count');
713
  add_thickbox();
714
+ wp_enqueue_script('media-upload');
 
715
  wp_enqueue_script('quicktags');
716
  $this->render();
717
  }
754
  $history_file = new PMXI_File_Record();
755
  $history_file->getBy('id', $history[0]['id']);
756
 
757
+ if (empty(PMXI_Plugin::$session->data['pmxi_import'])){
758
  PMXI_Plugin::$session['pmxi_import']['filePath'] = $history_file->path;
759
+ if (!@file_exists($history_file->path)) PMXI_Plugin::$session['pmxi_import']['filePath'] = $wp_uploads['basedir'] . '/wpallimport_history/' . $history_file->id;
 
 
760
  PMXI_Plugin::$session['pmxi_import']['count'] = $update_previous->count;
761
  PMXI_Plugin::$session['pmxi_import']['encoding'] = (!empty($update_previous->options['encoding'])) ? $update_previous->options['encoding'] : 'UTF-8';
762
  pmxi_session_commit();
763
+ }
 
 
 
 
 
 
 
 
 
764
  }
765
 
766
  } else {
770
 
771
  $this->data['tagno'] = max(intval($this->input->getpost('tagno', 1)), 1);
772
 
773
+ if ($this->data['tagno']){
774
 
775
  PMXI_Plugin::$session['pmxi_import']['local_paths'] = $local_paths = (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) ? PMXI_Plugin::$session->data['pmxi_import']['local_paths'] : array(PMXI_Plugin::$session->data['pmxi_import']['filePath']);
776
 
777
+ $loop = 0;
778
 
779
+ foreach ($local_paths as $key => $path) {
780
+
781
  if (@file_exists($path)){
782
 
783
+ $file = new PMXI_Chunk($path, array('element' => (!empty($update_previous->root_element)) ? $update_previous->root_element : ((!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']), 'encoding' => PMXI_Plugin::$session->data['pmxi_import']['encoding']));
784
  // loop through the file until all lines are read
785
  while ($xml = $file->read()) {
786
 
787
  if (!empty($xml))
788
+ {
789
+ PMXI_Import_Record::preprocessXml($xml);
790
+ $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
791
 
792
+ $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
793
  $old = libxml_use_internal_errors(true);
794
+ $dom->loadXML($xml);
795
  libxml_use_internal_errors($old);
796
  $xpath = new DOMXPath($dom);
797
+ if (($elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length){
798
+ $this->data['elements'] = $elements;
799
+ $loop += $elements->length;
800
+ unset($dom, $xpath, $elements);
801
+ if ($loop == $this->data['tagno'] or $loop == PMXI_Plugin::$session->data['pmxi_import']['count'])
802
+ break(2);
 
803
  }
804
  }
805
  }
822
  'is_keep_linebreaks' => 0,
823
  'is_leave_html' => 0,
824
  'fix_characters' => 0,
825
+ 'import_encoding' => 'UTF-8',
826
+ 'tagno' => 0
827
  ));
828
  $wp_uploads = wp_upload_dir();
829
 
830
  $legacy_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
831
+ $this->data['tagno'] = $tagno = min(max(intval($this->input->getpost('tagno', 1)), 1), PMXI_Plugin::$session->data['pmxi_import']['count']);
832
 
833
  $xml = '';
834
+
835
+ $local_paths = (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) ? PMXI_Plugin::$session->data['pmxi_import']['local_paths'] : array(PMXI_Plugin::$session->data['pmxi_import']['filePath']);
836
 
837
+ $loop = 1;
838
+ foreach ($local_paths as $key => $path) {
 
839
 
840
+ if (PMXI_Plugin::$session->data['pmxi_import']['encoding'] != $post['import_encoding'] and ! empty(PMXI_Plugin::$session->data['pmxi_import']['csv_paths'][$key])){
841
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
842
+ $csv = new PMXI_CsvParser(PMXI_Plugin::$session->data['pmxi_import']['csv_paths'][$key], true, '', PMXI_Plugin::$is_csv, $post['import_encoding'], $path); // conver CSV to XML with selected encoding
843
+ }
844
 
845
+ $file = new PMXI_Chunk($path, array('element' => (!empty($this->data['update_previous']->root_element)) ? $this->data['update_previous']->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'], 'encoding' => $post['import_encoding']));
846
+ // loop through the file until all lines are read
847
+ while ($xml = $file->read()) {
848
+ if (!empty($xml))
849
+ {
850
+ PMXI_Import_Record::preprocessXml($xml);
851
+ $xml = "<?xml version=\"1.0\" encoding=\"". $post['import_encoding'] ."\"?>" . "\n" . $xml;
852
+
853
+ $dom = new DOMDocument('1.0', $post['import_encoding']);
854
+ $old = libxml_use_internal_errors(true);
855
+ $dom->loadXML($xml); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
856
+ libxml_use_internal_errors($old);
857
+ $xpath = new DOMXPath($dom);
858
+ if (($this->data['elements'] = $elements = @$xpath->query(PMXI_Plugin::$session->data['pmxi_import']['xpath'])) and $elements->length){
859
+ unset($dom, $xpath, $elements);
860
+ if ( $loop == $tagno )
861
+ break(2);
862
+ $loop++;
863
+ }
864
+ }
 
865
  }
866
+ unset($file);
867
  }
868
+ //$this->data['tagno'] = $tagno = 1;
869
+
870
+ $xpath = "(" . PMXI_Plugin::$session->data['pmxi_import']['xpath'] . ")[1]";
871
+
872
+ PMXI_Plugin::$session['pmxi_import']['encoding'] = $post['import_encoding'];
873
+ pmxi_session_commit();
874
+
875
  // validate
876
  try {
877
  if (empty($xml)){
911
  * Step #4: Options
912
  */
913
  public function options()
914
+ {
 
915
 
916
  $default = PMXI_Plugin::get_default_import_options();
917
 
944
  }
945
  }
946
  }
947
+
948
+ $DefaultOptions = (isset(PMXI_Plugin::$session->data['pmxi_import']['options']) ? PMXI_Plugin::$session->data['pmxi_import']['options'] : array()) + $default;
949
+ foreach (PMXI_Admin_Addons::get_active_addons() as $class)
950
+ $DefaultOptions += call_user_func(array($class, "get_default_import_options"));
951
 
952
+ $post = $this->input->post( apply_filters('pmxi_options_options', $DefaultOptions, $this->isWizard) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
953
 
954
  } else {
955
+ $this->data['source_type'] = $this->data['import']->type;
956
+ $DefaultOptions = $this->data['import']->options + $default;
957
+ foreach (PMXI_Admin_Addons::get_active_addons() as $class)
958
+ $DefaultOptions += call_user_func(array($class, "get_default_import_options"));
959
+
960
+ $post = $this->input->post( apply_filters( 'pmxi_options_options', $DefaultOptions, $this->isWizard) );
 
 
 
 
 
 
 
 
 
 
961
  }
962
 
963
+ $this->data['post'] =& $post;
 
964
 
965
  // Get All meta keys in the system
966
  $this->data['meta_keys'] = $keys = new PMXI_Model_List();
967
  $keys->setTable(PMXI_Plugin::getInstance()->getWPPrefix() . 'postmeta');
968
+ $keys->setColumns('meta_id', 'meta_key')->getBy(NULL, "meta_id", NULL, NULL, "meta_key");
969
+
970
+ global $wpdb;
971
+
972
+ $existing_attributes = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_product_attributes'" );
973
+
974
+ $this->data['existing_attributes'] = array();
975
+
976
+ if ( ! empty($existing_attributes)){
977
+ foreach ($existing_attributes as $key => $existing_attribute) {
978
+ $existing_attribute = maybe_unserialize($existing_attribute->meta_value);
979
+ if (!empty($existing_attribute) and is_array($existing_attribute)):
980
+ foreach ($existing_attribute as $key => $value) {
981
+ if (strpos($key, "pa_") === false and ! in_array($key, $this->data['existing_attributes'])) $this->data['existing_attributes'][] = $key;
982
+ }
983
+ endif;
984
+ }
985
+ }
986
+
987
  $load_template = $this->input->post('load_template');
988
  if ($load_template) { // init form with template selected
989
  PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = $load_template;
990
  $template = new PMXI_Template_Record();
991
  if ( ! $template->getById($load_template)->isEmpty()) {
992
+ $post = (!empty($template->options) ? $template->options : array()) + $default;
 
 
 
 
993
  }
994
  } elseif ($load_template == -1){
995
  PMXI_Plugin::$session['pmxi_import']['is_loaded_template'] = 0;
996
 
997
+ $post = $default;
 
 
 
 
998
 
999
+ } elseif ($this->input->post('is_submitted')) {
1000
+
1001
+ check_admin_referer('options', '_wpnonce_options');
1002
+
1003
+ // Categories/taxonomies logic
1004
+ if ($post['update_categories_logic'] == 'only'){
1005
+ $post['taxonomies_list'] = explode(",", $post['taxonomies_only_list']);
1006
+ }
1007
+ elseif ($post['update_categories_logic'] == 'all_except'){
1008
+ $post['taxonomies_list'] = explode(",", $post['taxonomies_except_list']);
1009
+ }
1010
+
1011
+ // Custom fields logic
1012
+ if ($post['update_custom_fields_logic'] == 'only'){
1013
+ $post['custom_fields_list'] = explode(",", $post['custom_fields_only_list']);
1014
+ }
1015
+ elseif ($post['update_custom_fields_logic'] == 'all_except'){
1016
+ $post['custom_fields_list'] = explode(",", $post['custom_fields_except_list']);
1017
+ }
1018
+
1019
+ // Attributes fields logic
1020
+ $post = apply_filters('pmxi_save_options', $post);
1021
+
1022
+ // remove entires where both custom_name and custom_value are empty
1023
+ $not_empty = array_flip(array_values(array_merge(array_keys(array_filter($post['custom_name'], 'strlen')), array_keys(array_filter($post['custom_value'], 'strlen')))));
1024
+
1025
+ $post['custom_name'] = array_intersect_key($post['custom_name'], $not_empty);
1026
+ $post['custom_value'] = array_intersect_key($post['custom_value'], $not_empty);
1027
+
1028
+ // validate
1029
+ if (array_keys(array_filter($post['custom_name'], 'strlen')) != array_keys(array_filter($post['custom_value'], 'strlen'))) {
1030
+ $this->errors->add('form-validation', __('Both name and value must be set for all custom parameters', 'pmxi_plugin'));
1031
+ } else {
1032
+ foreach ($post['custom_name'] as $custom_name) {
1033
+ $this->_validate_template($custom_name, __('Custom Field Name', 'pmxi_plugin'));
1034
+ }
1035
+ foreach ($post['custom_value'] as $custom_value) {
1036
+ $this->_validate_template($custom_value, __('Custom Field Value', 'pmxi_plugin'));
1037
+ }
1038
+ }
1039
 
1040
  if ( $post['type'] == "post" and $post['custom_type'] == "product" and class_exists('PMWI_Plugin')){
1041
  // remove entires where both custom_name and custom_value are empty
1064
  if ('post' == $post['type']) {
1065
  /*'' == $post['categories'] or $this->_validate_template($post['categories'], __('Categories', 'pmxi_plugin'));*/
1066
  '' == $post['tags'] or $this->_validate_template($post['tags'], __('Tags', 'pmxi_plugin'));
1067
+ if ( "" != $post['custom_type']) {
1068
+ if ($post['custom_type'] != 'product'){
1069
+ $this->_validate_template($post['custom_type'], __('Custom post type is not supported', 'pmxi_plugin'));
1070
+ }
1071
+ elseif ( ! class_exists('PMWI_Plugin') ){
1072
+ $this->_validate_template($post['custom_type'], __('Custom post type is not supported', 'pmxi_plugin'));
1073
+ }
1074
+ }
1075
  }
1076
  if ('specific' == $post['date_type']) {
1077
  '' == $post['date'] or $this->_validate_template($post['date'], __('Date', 'pmxi_plugin'));
1091
  if ( ! preg_match('%^([1-9]\d*)( *- *([1-9]\d*))?$%', $chank, $mtch)) {
1092
  $this->errors->add('form-validation', __('Wrong format of `Import only specified records` value', 'pmxi_plugin'));
1093
  break;
1094
+ } elseif (isset($mtch[3]) and intval($mtch[3]) > PMXI_Plugin::$session->data['pmxi_import']['count']) {
1095
  $this->errors->add('form-validation', __('One of the numbers in `Import only specified records` value exceeds record quantity in XML file', 'pmxi_plugin'));
1096
  break;
1097
  }
1109
  if ('' == $post['custom_duplicate_value'])
1110
  $this->errors->add('form-validation', __('Custom field value must be specified.', 'pmxi_plugin'));
1111
  }
1112
+
1113
+ apply_filters('pmxi_options_validation', $this->errors, $post, $this->data['import']);
1114
 
1115
  if ( ! $this->errors->get_error_codes()) { // no validation errors found
1116
  // assign some defaults
1123
 
1124
  $template->getByName($this->input->post('name'))->set(array(
1125
  'name' => $this->input->post('name'),
1126
+ 'options' => $post,
 
1127
  ))->save();
1128
  }
1129
 
1130
  if ($this->isWizard) {
1131
  PMXI_Plugin::$session['pmxi_import']['options'] = $post;
 
1132
 
1133
  pmxi_session_commit();
1134
 
1143
  'xpath' => PMXI_Plugin::$session->data['pmxi_import']['xpath'],
1144
  'template' => PMXI_Plugin::$session->data['pmxi_import']['template'],
1145
  'options' => PMXI_Plugin::$session->data['pmxi_import']['options'],
1146
+ //'scheduled' => PMXI_Plugin::$session->data['pmxi_import']['scheduled'],
1147
  'count' => PMXI_Plugin::$session->data['pmxi_import']['count'],
1148
  'friendly_name' => $this->data['post']['friendly_name'],
1149
  )
1154
  'name' => $import->name,
1155
  'import_id' => $import->id,
1156
  'path' => PMXI_Plugin::$session->data['pmxi_import']['filePath'],
1157
+ 'contents' => $this->get_xml(),
1158
  'registered_on' => date('Y-m-d H:i:s'),
1159
  ))->save();
1160
 
1161
+ pmxi_session_unset();
 
 
1162
 
1163
  wp_redirect(add_query_arg(array('page' => 'pmxi-admin-manage', 'pmlc_nt' => urlencode($is_update ? __('Import updated', 'pmxi_plugin') : __('Import created', 'pmxi_plugin'))), admin_url('admin.php'))); die();
1164
  }
1165
  } else {
1166
 
1167
+ $this->data['import']->set('options', $post)->set( array( 'scheduled' => '', 'friendly_name' => $this->data['post']['friendly_name'] ) )->save();
1168
 
1169
  wp_redirect(add_query_arg(array('page' => 'pmxi-admin-manage', 'pmlc_nt' => urlencode(__('Options updated', 'pmxi_plugin'))) + array_intersect_key($_GET, array_flip($this->baseUrlParamNames)), admin_url('admin.php'))); die();
1170
  }
1181
  pmxi_session_commit();
1182
 
1183
  $this->render();
1184
+ }
1185
 
1186
  /**
1187
  * Import processing step (status console)
1188
  */
1189
  public function process($save_history = true)
1190
  {
1191
+ $wp_uploads = wp_upload_dir();
1192
+
1193
  $import = $this->data['update_previous'];
1194
  $logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m))) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
1195
 
1196
+ if ( ! PMXI_Plugin::is_ajax() ) {
 
 
 
 
1197
 
1198
  $import->set(
1199
  (empty(PMXI_Plugin::$session->data['pmxi_import']['source']) ? array() : PMXI_Plugin::$session->data['pmxi_import']['source'])
1200
  + array(
1201
  'xpath' => PMXI_Plugin::$session->data['pmxi_import']['xpath'],
1202
  'template' => PMXI_Plugin::$session->data['pmxi_import']['template'],
1203
+ 'options' => PMXI_Plugin::$session->data['pmxi_import']['options'],
 
1204
  'count' => PMXI_Plugin::$session->data['pmxi_import']['count'],
1205
  'friendly_name' => PMXI_Plugin::$session->data['pmxi_import']['options']['friendly_name'],
1206
+ 'feed_type' => PMXI_Plugin::$session->data['pmxi_import']['feed_type'],
1207
+ 'parent_import_id' => ($this->data['update_previous']->isEmpty()) ? PMXI_Plugin::$session->data['pmxi_import']['parent_import_id'] : $this->data['update_previous']->parent_import_id,
1208
+ 'queue_chunk_number' => 0,
1209
+ 'triggered' => 0,
1210
+ 'processing' => 0,
1211
  )
1212
+ )->save();
1213
+
1214
+ if ( PMXI_Plugin::$session->data['pmxi_import']['action'] != 'continue' ){
1215
+ // store import info in database
1216
+ $import->set(array(
1217
+ 'imported' => 0,
1218
+ 'created' => 0,
1219
+ 'updated' => 0,
1220
+ 'skipped' => 0,
1221
+ 'current_post_ids' => ''
1222
+ ))->update();
1223
+ }
1224
+
1225
+ foreach ( get_taxonomies() as $tax )
1226
+ delete_transient("pmxi_{$tax}_terms");
1227
+
1228
  do_action( 'pmxi_before_xml_import', $import->id );
1229
 
1230
  PMXI_Plugin::$session['pmxi_import']['update_previous'] = $import->id;
1248
  'import_id' => $import->id,
1249
  'path' => PMXI_Plugin::$session->data['pmxi_import']['filePath'],
1250
  'contents' => $this->get_xml(),
1251
+ 'registered_on' => date('Y-m-d H:i:s')
1252
  ))->save();
1253
+ }
1254
+
1255
+ /*
1256
+ Split file up into 1000 record chunks.
1257
+ This option will decrease the amount of slowdown experienced at the end of large imports.
1258
+ The slowdown is partially caused by the need for WP All Import to read deeper and deeper into the file on each successive iteration.
1259
+ Splitting the file into pieces means that, for example, instead of having to read 19000 records into a 20000 record file when importing the last 1000 records,
1260
+ WP All Import will just split it into 20 chunks, and then read the last chunk from the beginning.
1261
+ */
1262
+ if ( "ajax" == $import->options['import_processing'] and $import->count > PMXI_Plugin::getInstance()->getOption('large_feed_limit') and $import->options['chuncking'] ){
1263
+
1264
+ $chunk_files = array();
1265
+
1266
+ if (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])){
1267
+
1268
+ $records_count = 0;
1269
+ $chunk_records_count = 0;
1270
+
1271
+ $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
1272
+
1273
+ foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
1274
+
1275
+ $file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding']));
1276
+
1277
+ // loop through the file until all lines are read
1278
+ while ($xml = $file->read()) {
1279
+
1280
+ if ( ! empty($xml) )
1281
+ {
1282
+ PMXI_Import_Record::preprocessXml($xml);
1283
+ $chunk = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . $xml;
1284
+
1285
+ $dom = new DOMDocument('1.0', $import->options['encoding']);
1286
+ $old = libxml_use_internal_errors(true);
1287
+ $dom->loadXML($chunk); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
1288
+ libxml_use_internal_errors($old);
1289
+ $xpath = new DOMXPath($dom);
1290
+
1291
+ if ($elements = @$xpath->query($import->xpath) and $elements->length){
1292
+ $records_count += $elements->length;
1293
+ $chunk_records_count += $elements->length;
1294
+ $feed .= $xml;
1295
+ }
1296
+ }
1297
+
1298
+ if ( $chunk_records_count == PMXI_Plugin::getInstance()->getOption('large_feed_limit') or $records_count == $import->count ){
1299
+ $feed .= "</pmxi_records>";
1300
+ $chunk_file_path = $wp_uploads['path'] . "/pmxi_chunk_" . count($chunk_files) . "_" . basename($path);
1301
+ file_put_contents($chunk_file_path, $feed);
1302
+ $chunk_files[] = $chunk_file_path;
1303
+ $chunk_records_count = 0;
1304
+ $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
1305
+ }
1306
+ }
1307
+ }
1308
+ PMXI_Plugin::$session['pmxi_import']['local_paths'] = $chunk_files;
1309
+ }
1310
+ }
1311
+
1312
+ pmxi_session_commit();
1313
 
1314
  $this->render();
1315
+ wp_ob_end_flush_all(); flush();
1316
+ @set_time_limit(0);
1317
 
1318
+ if ( "ajax" == $import->options['import_processing'] ) die();
1319
+ }
1320
  elseif (empty($import->id)){
1321
  $import = new PMXI_Import_Record();
1322
  $import->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
1323
+ }
1324
+
1325
+ $ajax_processing = ("ajax" == $import->options['import_processing']) ? true : false;
1326
 
1327
  PMXI_Plugin::$session['pmxi_import']['start_time'] = (empty(PMXI_Plugin::$session->data['pmxi_import']['start_time'])) ? time() : PMXI_Plugin::$session->data['pmxi_import']['start_time'];
1328
 
1329
+ wp_cache_flush();
 
 
 
 
1330
 
1331
+ if ( PMXI_Plugin::is_ajax() or ! $ajax_processing ) {
1332
+
1333
+ if ( "ajax" == $import->options['import_processing'] ) {
1334
+ // HTTP headers for no cache etc
1335
+ header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
1336
+ header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
1337
+ header("Cache-Control: no-store, no-cache, must-revalidate");
1338
+ header("Cache-Control: post-check=0, pre-check=0", false);
1339
+ header("Pragma: no-cache");
1340
+ }
1341
+
1342
+ $loop = 0;
1343
+ $pointer = 0;
1344
+ $records = array();
1345
+
1346
+ if ($import->options['is_import_specified']) {
1347
+ foreach (preg_split('% *, *%', $import->options['import_specified'], -1, PREG_SPLIT_NO_EMPTY) as $chank) {
1348
+ if (preg_match('%^(\d+)-(\d+)$%', $chank, $mtch)) {
1349
+ $records = array_merge($records, range(intval($mtch[1]), intval($mtch[2])));
1350
+ } else {
1351
+ $records = array_merge($records, array(intval($chank)));
1352
+ }
1353
+ }
1354
+ }
1355
+
1356
+ $records_to_import = (empty($records)) ? $import->count : $records[count($records) -1];
1357
+
1358
+ $records_per_request = ( ! $ajax_processing and $import->options['records_per_request'] < 50 ) ? 50 : $import->options['records_per_request'];
1359
 
1360
  if (!empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])){
1361
 
1362
+ $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
1363
+
1364
+ foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
1365
 
1366
+ $import_done = ($import->imported + $import->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'] == $records_to_import ) ? true : false;
1367
 
1368
+ if ( $import_done ) {
1369
+ if (strpos($path, "pmxi_chunk_") !== false and @file_exists($path)) @unlink($path);
1370
+ PMXI_Plugin::$session['pmxi_import']['local_paths'] = array();
1371
+ pmxi_session_commit();
1372
+ break;
1373
+ }
1374
+
1375
+ $file = new PMXI_Chunk($path, array('element' => $import->root_element, 'encoding' => $import->options['encoding'], 'pointer' => PMXI_Plugin::$session->data['pmxi_import']['pointer']));
1376
  // loop through the file until all lines are read
1377
  while ($xml = $file->read()) {
1378
+
1379
+ if ( ! empty($xml) )
1380
  {
 
1381
  PMXI_Import_Record::preprocessXml($xml);
1382
+ $chunk = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . $xml;
1383
 
1384
+ $dom = new DOMDocument('1.0', $import->options['encoding']);
1385
+ $old = libxml_use_internal_errors(true);
1386
+ $dom->loadXML($chunk); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
1387
  libxml_use_internal_errors($old);
1388
  $xpath = new DOMXPath($dom);
1389
+
1390
+ $pointer++;
1391
+
1392
+ if (($this->data['elements'] = $elements = @$xpath->query($import->xpath)) and $elements->length){
1393
+
1394
+ // continue action
1395
+ if ( $import->imported + $import->skipped >= PMXI_Plugin::$session->data['pmxi_import']['chunk_number'] + $elements->length - 1 ){
1396
+ PMXI_Plugin::$session['pmxi_import']['chunk_number'] = PMXI_Plugin::$session->data['pmxi_import']['chunk_number'] + $elements->length;
1397
+ pmxi_session_commit();
1398
+ continue;
1399
+ }
1400
+
1401
+ if ( ! $loop and $ajax_processing ) ob_start();
1402
+
1403
+ $feed .= $xml; $loop += $elements->length;
1404
+
1405
+ $processed_records = $import->imported + $import->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
1406
+
1407
+ if ( $loop == $records_per_request or $processed_records + $loop == $records_to_import or $processed_records == $records_to_import) {
1408
+
1409
+ $feed .= "</pmxi_records>";
1410
+ $import->process($feed, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number'], false, '/pmxi_records');
1411
+ unset($dom, $xpath);
1412
+
1413
+ if ( ! $ajax_processing ){
1414
+ $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
1415
+ $loop = 0;
1416
+ } else {
1417
+ unset($file);
1418
+ PMXI_Plugin::$session['pmxi_import']['pointer'] = PMXI_Plugin::$session->data['pmxi_import']['pointer'] + $pointer;
1419
+ pmxi_session_commit();
1420
+ wp_send_json(array(
1421
+ 'created' => $import->created,
1422
+ 'updated' => $import->updated,
1423
+ 'percentage' => ceil(($processed_records/$import->count) * 100),
1424
+ 'warnings' => PMXI_Plugin::$session->data['pmxi_import']['warnings'],
1425
+ 'errors' => PMXI_Plugin::$session->data['pmxi_import']['errors'],
1426
+ 'log' => ob_get_clean(),
1427
+ 'done' => false
1428
+ ));
1429
+ }
1430
+ }
1431
  }
1432
+ }
1433
+ }
1434
+
1435
+ // Move to the next file, set pointer to first element
1436
+ if ( $ajax_processing ) {
1437
+
1438
+ if (strpos($path, "pmxi_chunk_") !== false and @file_exists($path)) @unlink($path);
1439
+
1440
+ PMXI_Plugin::$session['pmxi_import']['pointer'] = 1;
1441
+ $pointer = 0;
1442
+ array_shift(PMXI_Plugin::$session->data['pmxi_import']['local_paths']);
1443
+ PMXI_Plugin::$session['pmxi_import']['local_paths'] = PMXI_Plugin::$session->data['pmxi_import']['local_paths'];
1444
+ pmxi_session_commit();
1445
+ }
1446
  }
1447
  }
1448
  }
1449
+
1450
+ if ( ( PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths']) ) or ! $ajax_processing ){
1451
 
1452
  // Save import process log
1453
  $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
1462
  _get_term_hierarchy( $tax );
1463
  }
1464
 
1465
+ $import->set('registered_on', date('Y-m-d H:i:s'))->update();
1466
+
1467
  // clear import session
1468
  pmxi_session_unset(); // clear session data (prevent from reimporting the same data on page refresh)
1469
 
1470
  // [indicate in header process is complete]
1471
  $msg = addcslashes(__('Complete', 'pmxi_plugin'), "\n\r");
1472
 
1473
+ if ( $ajax_processing ) ob_start();
1474
 
1475
+ $import->options['is_import_specified'] and $logger and call_user_func($logger, 'Done');
1476
 
1477
  echo <<<COMPLETE
1478
  <script type="text/javascript">
1479
  //<![CDATA[
1480
+ (function($){
1481
+ $('#status').html('$msg');
1482
+ $('#import_finished').show();
 
 
 
 
 
1483
  window.onbeforeunload = false;
1484
  })(jQuery);
1485
  //]]>
1487
  COMPLETE;
1488
  // [/indicate in header process is complete]
1489
 
1490
+ if ( $ajax_processing ) {
1491
+
1492
+ wp_send_json(array(
1493
+ 'created' => $import->created,
1494
+ 'updated' => $import->updated,
1495
+ 'percentage' => 100,
1496
+ 'warnings' => PMXI_Plugin::$session->data['pmxi_import']['warnings'],
1497
+ 'errors' => PMXI_Plugin::$session->data['pmxi_import']['errors'],
1498
+ 'log' => ob_get_clean(),
1499
+ 'done' => true
1500
+ ));
1501
 
1502
+ }
1503
  }
1504
+ }
1505
 
1506
  protected $_sibling_limit = 20;
1507
  protected function get_xml_path(DOMElement $el, DOMXPath $xpath)
1597
  }
1598
  echo '</div>';
1599
  }
1600
+ protected function render_xml_elements_for_filtring(DOMElement $el, $path ='', $lvl = 0){
1601
+ if ("" != $path){
1602
+ if ($lvl > 1) $path .= "->" . $el->nodeName; else $path = $el->nodeName;
1603
+ echo '<option value="'.$path.'">' .$path . '</option>';
1604
+ }
1605
+ else $path = $el->nodeName;
1606
+
1607
+ foreach ($el->attributes as $attr) {
1608
+ echo '<option value="'.$path . '@' . $attr->nodeName.'">'. $path . '@' . $attr->nodeName . '</option>';
1609
+ }
1610
+ if ($el->hasChildNodes()) {
1611
+ foreach ($el->childNodes as $child) {
1612
+ if ($child instanceof DOMElement)
1613
+ $this->render_xml_elements_for_filtring($child, $path, $lvl + 1);
1614
+ }
1615
+ }
1616
+ }
1617
  protected $_unique_key = array();
1618
  protected function find_unique_key(DOMElement $el){
1619
  if ($el->hasChildNodes()) {
1765
  $toDom->appendChild($toDom->ownerDocument->importNode($fromDom, true));
1766
  }
1767
 
1768
+ protected function get_xml($tagno = 0){
1769
  $xml = '';
1770
+ $customXpath = PMXI_Plugin::$session->data['pmxi_import']['xpath'];
1771
  $wp_uploads = wp_upload_dir();
1772
  $update_previous = new PMXI_Import_Record();
1773
 
1774
+ if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['update_previous'])) $update_previous->getById(PMXI_Plugin::$session->data['pmxi_import']['update_previous']);
 
1775
 
1776
+ if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])) {
1777
+
1778
+ $loop = 0;
1779
  foreach (PMXI_Plugin::$session->data['pmxi_import']['local_paths'] as $key => $path) {
1780
 
1781
  if ( @file_exists($path) ){
1782
 
1783
  $root_element = ( ! $update_previous->isEmpty() ) ? $update_previous->root_element : PMXI_Plugin::$session->data['pmxi_import']['source']['root_element'];
1784
 
1785
+ $file = new PMXI_Chunk($path, array('element' => $root_element, 'encoding' => PMXI_Plugin::$session->data['pmxi_import']['encoding']));
 
 
 
 
 
1786
 
1787
+ while ($xml = $file->read()) {
1788
+
1789
+ if (!empty($xml))
1790
+ {
1791
+ PMXI_Import_Record::preprocessXml($xml);
1792
+ $xml = "<?xml version=\"1.0\" encoding=\"". PMXI_Plugin::$session->data['pmxi_import']['encoding'] ."\"?>" . "\n" . $xml;
1793
+
1794
+ if ( '' != $customXpath){
1795
  $dom = new DOMDocument('1.0', PMXI_Plugin::$session->data['pmxi_import']['encoding']);
1796
  $old = libxml_use_internal_errors(true);
1797
+ $dom->loadXML($xml);
1798
  libxml_use_internal_errors($old);
1799
+ $xpath = new DOMXPath($dom);
1800
+ if (($elements = $xpath->query($customXpath)) and $elements->length){
1801
+ $this->data['dom'] = $dom;
1802
+ $loop++;
1803
+ if ( ! $tagno or $loop == $tagno ) break;
1804
+ }
1805
  }
1806
  else break;
1807
  }
1808
  }
1809
+ unset($file);
1810
+
1811
  }
1812
+ }
1813
+ }
1814
  return $xml;
1815
  }
1816
+ }
controllers/admin/manage.php CHANGED
@@ -32,7 +32,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
32
 
33
  $list = new PMXI_Import_List();
34
  $post = new PMXI_Post_Record();
35
- $by = NULL;
36
  if ('' != $s) {
37
  $like = '%' . preg_replace('%\s+%', '%', preg_replace('/[%?]/', '\\\\$0', $s)) . '%';
38
  $by[] = array(array('name LIKE' => $like, 'type LIKE' => $like, 'path LIKE' => $like), 'OR');
@@ -54,9 +54,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
54
  'current' => $pagenum,
55
  ));
56
 
57
- //unset(PMXI_Plugin::$session['pmxi_import']);
58
-
59
- pmxi_session_unset();
60
 
61
  $this->render();
62
  }
@@ -65,6 +63,9 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
65
  * Edit Template
66
  */
67
  public function edit() {
 
 
 
68
  // deligate operation to other controller
69
  $controller = new PMXI_Admin_Import();
70
  $controller->set('isTemplateEdit', true);
@@ -75,11 +76,28 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
75
  * Edit Options
76
  */
77
  public function options() {
 
 
 
78
  // deligate operation to other controller
79
  $controller = new PMXI_Admin_Import();
80
  $controller->set('isTemplateEdit', true);
81
  $controller->options();
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
 
84
  /**
85
  * Reimport
@@ -87,22 +105,23 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
87
  public function update() {
88
  $id = $this->input->get('id');
89
  $action_type = $this->input->get('type');
90
- $pointer = 0;
91
 
92
  $this->data['item'] = $item = new PMXI_Import_Record();
93
  if ( ! $id or $item->getById($id)->isEmpty()) {
94
  wp_redirect($this->baseUrl); die();
95
  }
96
-
97
  pmxi_session_unset();
98
 
99
  if ($this->input->post('is_confirmed')) {
100
 
101
  check_admin_referer('update-import', '_wpnonce_update-import');
102
 
103
- $uploads = wp_upload_dir();
 
 
104
 
105
- if ($item->large_import == 'No' or ($item->large_import == 'Yes' and empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number']))) {
106
 
107
  if ( in_array($item->type, array('upload')) ) { // if import type NOT URL
108
 
@@ -119,8 +138,8 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
119
  $filePath = '';
120
 
121
  if (!empty($v_result_list)){
122
- foreach ($v_result_list as $unzipped_file) {
123
- if ($unzipped_file['status'] == 'ok') $filePath = $unzipped_file['filename'];
124
  }
125
  }
126
  if($uploads['error']){
@@ -148,47 +167,34 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
148
  }
149
  }
150
 
151
- if (preg_match('%\W(csv)$%i', trim($filePath))){ // If CSV file found in archieve
152
 
153
  if($uploads['error']){
154
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
155
- }
156
- if (empty($item->large_import) or $item->large_import == 'No') {
157
- $filePath = PMXI_Plugin::csv_to_xml($filePath);
158
- }
159
- else{
160
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
161
- $csv = new PMXI_CsvParser($filePath, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : ''); // create chunks
162
- $filePath = $csv->xml_path;
163
- }
164
  }
165
  }
166
 
167
- } elseif ( preg_match('%\W(csv)$%i', trim($item->path))) { // If CSV file uploaded
168
  if($uploads['error']){
169
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
170
  }
171
- $filePath = $post['filepath'];
172
- if (empty($item->large_import) or $item->large_import == 'No') {
173
- $filePath = PMXI_Plugin::csv_to_xml($item->path);
174
- } else{
175
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
176
- $csv = new PMXI_CsvParser($item->path, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : '');
177
- $filePath = $csv->xml_path;
178
- }
179
  } elseif(preg_match('%\W(gz)$%i', trim($item->path))){ // If gz file uploaded
180
  $fileInfo = pmxi_gzfile_get_contents($item->path);
181
  $filePath = $fileInfo['localPath'];
182
  // detect CSV or XML
183
- if ( $fileInfo['type'] == 'csv') { // it is CSV file
184
- if (empty($item->large_import) or $item->large_import == 'No') {
185
- $filePath = PMXI_Plugin::csv_to_xml($filePath); // convert CSV to XML
186
- }
187
- else{
188
- include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
189
- $csv = new PMXI_CsvParser($filePath, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : ''); // create chunks
190
- $filePath = $csv->xml_path;
191
- }
192
  }
193
  } else { // If XML file uploaded
194
 
@@ -196,109 +202,54 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
196
 
197
  }
198
 
199
- }
200
 
201
- if (empty($xml)){
202
-
203
- if ($item->large_import == 'Yes'){
204
-
205
- @set_time_limit(0);
206
 
207
- $chunks = 0;
208
-
209
- $chunk_path = '';
210
-
211
- $local_paths = !empty($local_paths) ? $local_paths : array($filePath);
212
-
213
- $chunk_founded = false;
214
-
215
- foreach ($local_paths as $key => $path) {
216
-
217
- $file = new PMXI_Chunk($path, array('element' => $item->root_element, 'path' => $uploads['path']));
218
-
219
- while ($xml = $file->read()) {
220
-
221
- if (!empty($xml))
222
- {
223
- if (!empty($action_type) and $action_type == 'continue'){
224
- if ( !$chunk_founded) {
225
- $xml = $file->encoding . "\n" . $xml;
226
- PMXI_Import_Record::preprocessXml($xml);
227
-
228
- $dom = new DOMDocument('1.0', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : 'UTF-8');
229
- $old = libxml_use_internal_errors(true);
230
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
231
- libxml_use_internal_errors($old);
232
- $xpath = new DOMXPath($dom);
233
- if (($elements = @$xpath->query($item->xpath)) and !empty($elements) and !empty($elements->length)) $chunk_founded = true;
234
- unset($dom, $xpath, $elements);
235
- }
236
- $chunks++;
237
- if ($chunks == $item->imported){
238
- $pointer = $file->pointer;
239
- $chunks = $item->count;
240
- break;
241
- }
242
- }
243
- else{
244
- $xml = $file->encoding . "\n" . $xml;
245
- PMXI_Import_Record::preprocessXml($xml);
246
-
247
- $dom = new DOMDocument('1.0', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : 'UTF-8');
248
- $old = libxml_use_internal_errors(true);
249
- $dom->loadXML(preg_replace('%xmlns\s*=\s*([\'"]).*\1%sU', '', $xml)); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
250
- libxml_use_internal_errors($old);
251
- $xpath = new DOMXPath($dom);
252
- if (($elements = @$xpath->query($item->xpath)) and !empty($elements) and !empty($elements->length)) $chunks++;
253
- unset($dom, $xpath, $elements);
254
- }
255
- }
256
- }
257
- unset($file);
258
-
259
- !$key and $filePath = $path;
260
- }
261
 
262
- if (empty($chunks))
263
- $this->errors->add('form-validation', __('No matching elements found for Root element and XPath expression specified', 'pmxi_plugin'));
264
-
265
- } else {
266
 
267
- ob_start();
268
- $filePath && @readgzfile($filePath);
269
- $xml = ob_get_clean();
270
-
271
- if (empty($xml)){
272
- $xml = @file_get_contents($filePath);
273
- if (empty($xml)) get_file_curl($filePath, $uploads['path'] .'/'. basename($filePath));
274
- if (empty($xml)) $xml = @file_get_contents($uploads['path'] .'/'. basename($filePath));
275
- }
276
- }
277
- }
278
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
- if ($item->large_import == 'Yes' or PMXI_Import_Record::validateXml($xml, $this->errors)) { // xml is valid
281
-
282
- if ( ! PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number'])){
283
 
284
- $item->set(array(
285
- 'processing' => 0,
286
- 'queue_chunk_number' => 0,
287
- 'current_post_ids' => ''
288
- ))->save();
289
-
290
- if (empty($action_type)){
291
- $item->set(array(
292
- 'imported' => 0,
293
- 'created' => 0,
294
- 'updated' => 0,
295
- 'skipped' => 0
296
- ))->save();
297
- }
298
 
299
  // compose data to look like result of wizard steps
300
- PMXI_Plugin::$session['pmxi_import'] = array(
301
- //'xml' => (isset($xml)) ? $xml : '',
302
  'filePath' => $filePath,
303
  'source' => array(
304
  'name' => $item->name,
@@ -308,6 +259,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
308
  ),
309
  'feed_type' => $item->feed_type,
310
  'update_previous' => $item->id,
 
311
  'xpath' => $item->xpath,
312
  'template' => $item->template,
313
  'options' => $item->options,
@@ -315,17 +267,13 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
315
  'is_csv' => (!empty($item->options['delimiter'])) ? $item->options['delimiter'] : PMXI_Plugin::$is_csv,
316
  'csv_path' => PMXI_Plugin::$csv_path,
317
  'scheduled' => $item->scheduled,
318
- 'current_post_ids' => '',
319
- 'large_file' => ($item->large_import == 'Yes') ? true : false,
320
- 'chunk_number' => (!empty($action_type) and $action_type == 'continue') ? $item->imported : 1,
321
- 'pointer' => $pointer,
322
- 'log' => '',
323
- 'created_records' => (!empty($action_type) and $action_type == 'continue') ? $item->created : 0,
324
- 'updated_records' => (!empty($action_type) and $action_type == 'continue') ? $item->updated : 0,
325
- 'skipped_records' => (!empty($action_type) and $action_type == 'continue') ? $item->skipped : 0,
326
  'warnings' => 0,
327
  'errors' => 0,
328
  'start_time' => 0,
 
329
  'count' => (isset($chunks)) ? $chunks : 0,
330
  'local_paths' => (!empty($local_paths)) ? $local_paths : array(), // ftp import local copies of remote files
331
  'action' => (!empty($action_type) and $action_type == 'continue') ? 'continue' : 'update',
@@ -357,6 +305,8 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
357
 
358
  if ($this->input->post('is_confirmed')) {
359
  check_admin_referer('delete-import', '_wpnonce_delete-import');
 
 
360
 
361
  $item->delete( ! $this->input->post('is_delete_posts'));
362
  wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'pmxi_plugin')), $this->baseUrl)); die();
@@ -374,7 +324,7 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
374
  $this->data['action'] = $action = $this->input->post('bulk-action2');
375
  } else {
376
  $this->data['action'] = $action = $this->input->post('bulk-action');
377
- }
378
  $this->data['ids'] = $ids = $this->input->post('items');
379
  $this->data['items'] = $items = new PMXI_Import_List();
380
  if (empty($action) or ! in_array($action, array('delete')) or empty($ids) or $items->getBy('id', $ids)->isEmpty()) {
32
 
33
  $list = new PMXI_Import_List();
34
  $post = new PMXI_Post_Record();
35
+ $by = array('parent_import_id' => 0);
36
  if ('' != $s) {
37
  $like = '%' . preg_replace('%\s+%', '%', preg_replace('/[%?]/', '\\\\$0', $s)) . '%';
38
  $by[] = array(array('name LIKE' => $like, 'type LIKE' => $like, 'path LIKE' => $like), 'OR');
54
  'current' => $pagenum,
55
  ));
56
 
57
+ pmxi_session_unset();
 
 
58
 
59
  $this->render();
60
  }
63
  * Edit Template
64
  */
65
  public function edit() {
66
+
67
+ pmxi_session_unset();
68
+
69
  // deligate operation to other controller
70
  $controller = new PMXI_Admin_Import();
71
  $controller->set('isTemplateEdit', true);
76
  * Edit Options
77
  */
78
  public function options() {
79
+
80
+ pmxi_session_unset();
81
+
82
  // deligate operation to other controller
83
  $controller = new PMXI_Admin_Import();
84
  $controller->set('isTemplateEdit', true);
85
  $controller->options();
86
  }
87
+
88
+ /**
89
+ * Cron Scheduling
90
+ */
91
+ public function scheduling() {
92
+ $this->data['id'] = $id = $this->input->get('id');
93
+ $this->data['cron_job_key'] = PMXI_Plugin::getInstance()->getOption('cron_job_key');
94
+ $this->data['item'] = $item = new PMXI_Import_Record();
95
+ if ( ! $id or $item->getById($id)->isEmpty()) {
96
+ wp_redirect($this->baseUrl); die();
97
+ }
98
+
99
+ $this->render();
100
+ }
101
 
102
  /**
103
  * Reimport
105
  public function update() {
106
  $id = $this->input->get('id');
107
  $action_type = $this->input->get('type');
 
108
 
109
  $this->data['item'] = $item = new PMXI_Import_Record();
110
  if ( ! $id or $item->getById($id)->isEmpty()) {
111
  wp_redirect($this->baseUrl); die();
112
  }
113
+
114
  pmxi_session_unset();
115
 
116
  if ($this->input->post('is_confirmed')) {
117
 
118
  check_admin_referer('update-import', '_wpnonce_update-import');
119
 
120
+ $uploads = wp_upload_dir();
121
+
122
+ $chunks = 0;
123
 
124
+ if ( empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number']) ) {
125
 
126
  if ( in_array($item->type, array('upload')) ) { // if import type NOT URL
127
 
138
  $filePath = '';
139
 
140
  if (!empty($v_result_list)){
141
+ foreach ($v_result_list as $unzipped_file) {
142
+ if ($unzipped_file['status'] == 'ok' and preg_match('%\W(xml|csv|txt|dat|psv)$%i', trim($unzipped_file['stored_filename']))) { $filePath = $unzipped_file['filename']; break; }
143
  }
144
  }
145
  if($uploads['error']){
167
  }
168
  }
169
 
170
+ if (preg_match('%\W(csv|txt|dat|psv)$%i', trim($filePath))){ // If CSV file found in archieve
171
 
172
  if($uploads['error']){
173
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
174
+ }
175
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
176
+ $csv = new PMXI_CsvParser($filePath, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : ''); // create chunks
177
+ $filePath = $csv->xml_path;
 
 
 
 
 
178
  }
179
  }
180
 
181
+ } elseif ( preg_match('%\W(csv|txt|dat|psv)$%i', trim($item->path))) { // If CSV file uploaded
182
  if($uploads['error']){
183
  $this->errors->add('form-validation', __('Can not create upload folder. Permision denied', 'pmxi_plugin'));
184
  }
185
+ $filePath = $post['filepath'];
186
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
187
+ $csv = new PMXI_CsvParser($item->path, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : '');
188
+ $filePath = $csv->xml_path;
189
+
 
 
 
190
  } elseif(preg_match('%\W(gz)$%i', trim($item->path))){ // If gz file uploaded
191
  $fileInfo = pmxi_gzfile_get_contents($item->path);
192
  $filePath = $fileInfo['localPath'];
193
  // detect CSV or XML
194
+ if ( $fileInfo['type'] == 'csv') { // it is CSV file
195
+ include_once(PMXI_Plugin::ROOT_DIR.'/libraries/XmlImportCsvParse.php');
196
+ $csv = new PMXI_CsvParser($filePath, true, '', ( ! empty($item->options['delimiter']) ) ? $item->options['delimiter'] : '', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : ''); // create chunks
197
+ $filePath = $csv->xml_path;
 
 
 
 
 
198
  }
199
  } else { // If XML file uploaded
200
 
202
 
203
  }
204
 
205
+ }
206
 
207
+ @set_time_limit(0);
208
+
209
+ $local_paths = !empty($local_paths) ? $local_paths : array($filePath);
 
 
210
 
211
+ foreach ($local_paths as $key => $path) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
 
213
+ if (!empty($action_type) and $action_type == 'continue'){
214
+ $chunks = $item->count;
215
+ }
216
+ else{
217
 
218
+ $file = new PMXI_Chunk($path, array('element' => $item->root_element, 'encoding' => $item->options['encoding']));
219
+
220
+ while ($xml = $file->read()) {
221
+
222
+ if (!empty($xml))
223
+ {
224
+ PMXI_Import_Record::preprocessXml($xml);
225
+ $xml = "<?xml version=\"1.0\" encoding=\"". $item->options['encoding'] ."\"?>" . "\n" . $xml;
226
+
227
+ $dom = new DOMDocument('1.0', ( ! empty($item->options['encoding']) ) ? $item->options['encoding'] : 'UTF-8');
228
+ $old = libxml_use_internal_errors(true);
229
+ $dom->loadXML($xml); // FIX: libxml xpath doesn't handle default namespace properly, so remove it upon XML load
230
+ libxml_use_internal_errors($old);
231
+ $xpath = new DOMXPath($dom);
232
+ if (($elements = @$xpath->query($item->xpath)) and !empty($elements) and !empty($elements->length)) $chunks += $elements->length;
233
+ unset($dom, $xpath, $elements);
234
+ }
235
+ }
236
+ unset($file);
237
+ }
238
+
239
+ !$key and $filePath = $path;
240
+ }
241
+
242
+ if (empty($chunks))
243
+ $this->errors->add('form-validation', __('No matching elements found for Root element and XPath expression specified', 'pmxi_plugin'));
244
+
245
+ }
246
 
247
+ if ( $chunks ) { // xml is valid
 
 
248
 
249
+ if ( ! PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->data['pmxi_import']['chunk_number'])){
 
 
 
 
 
 
 
 
 
 
 
 
 
250
 
251
  // compose data to look like result of wizard steps
252
+ PMXI_Plugin::$session['pmxi_import'] = array(
 
253
  'filePath' => $filePath,
254
  'source' => array(
255
  'name' => $item->name,
259
  ),
260
  'feed_type' => $item->feed_type,
261
  'update_previous' => $item->id,
262
+ 'parent_import_id' => $item->parent_import_id,
263
  'xpath' => $item->xpath,
264
  'template' => $item->template,
265
  'options' => $item->options,
267
  'is_csv' => (!empty($item->options['delimiter'])) ? $item->options['delimiter'] : PMXI_Plugin::$is_csv,
268
  'csv_path' => PMXI_Plugin::$csv_path,
269
  'scheduled' => $item->scheduled,
270
+ 'current_post_ids' => '',
271
+ 'chunk_number' => 1,
272
+ 'log' => '',
 
 
 
 
 
273
  'warnings' => 0,
274
  'errors' => 0,
275
  'start_time' => 0,
276
+ 'pointer' => 1,
277
  'count' => (isset($chunks)) ? $chunks : 0,
278
  'local_paths' => (!empty($local_paths)) ? $local_paths : array(), // ftp import local copies of remote files
279
  'action' => (!empty($action_type) and $action_type == 'continue') ? 'continue' : 'update',
305
 
306
  if ($this->input->post('is_confirmed')) {
307
  check_admin_referer('delete-import', '_wpnonce_delete-import');
308
+
309
+ do_action('pmxi_before_import_delete', $item, $this->input->post('is_delete_posts'));
310
 
311
  $item->delete( ! $this->input->post('is_delete_posts'));
312
  wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Import deleted', 'pmxi_plugin')), $this->baseUrl)); die();
324
  $this->data['action'] = $action = $this->input->post('bulk-action2');
325
  } else {
326
  $this->data['action'] = $action = $this->input->post('bulk-action');
327
+ }
328
  $this->data['ids'] = $ids = $this->input->post('items');
329
  $this->data['items'] = $items = new PMXI_Import_List();
330
  if (empty($action) or ! in_array($action, array('delete')) or empty($ids) or $items->getBy('id', $ids)->isEmpty()) {
controllers/admin/settings.php CHANGED
@@ -106,7 +106,7 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
106
 
107
  $this->render();
108
  }
109
-
110
  public function dismiss(){
111
 
112
  PMXI_Plugin::getInstance()->updateOption("dismiss", 1);
@@ -128,6 +128,31 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
128
  exit('OK');
129
  }
130
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
131
  /**
132
  * upload.php
133
  *
@@ -152,6 +177,9 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
152
 
153
  $targetDir = $uploads['path'];
154
 
 
 
 
155
  $cleanupTargetDir = true; // Remove old files
156
  $maxFileAge = 5 * 3600; // Temp file age in seconds
157
 
@@ -258,11 +286,12 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
258
  }
259
 
260
  // Return JSON-RPC response
261
- exit(json_encode(array("jsonrpc" => "2.0", "result" => null, "id" => "id", "name" => $filePath)));
262
 
263
  }
264
 
265
  public function download(){
266
  PMXI_download::csv(PMXI_Plugin::ROOT_DIR.'/logs/'.$_GET['file'].'.txt');
267
- }
 
268
  }
106
 
107
  $this->render();
108
  }
109
+
110
  public function dismiss(){
111
 
112
  PMXI_Plugin::getInstance()->updateOption("dismiss", 1);
128
  exit('OK');
129
  }
130
 
131
+ public function meta_values(){
132
+
133
+ global $wpdb;
134
+
135
+ $meta_key = $_POST['key'];
136
+
137
+ $r = $wpdb->get_results("
138
+ SELECT DISTINCT postmeta.meta_value
139
+ FROM ".$wpdb->postmeta." as postmeta
140
+ WHERE postmeta.meta_key='".$meta_key."'
141
+ ", ARRAY_A);
142
+
143
+ $html = '<p>'.__('No existing values were found for this field.','pmxi_plugin').'</p>';
144
+
145
+ if (!empty($r)){
146
+ $html = '<select class="existing_meta_values"><option value="">'.__('Existing Values...','pmxi_plugin').'</option>';
147
+ foreach ($r as $key => $value) { if (empty($value['meta_value'])) continue;
148
+ $html .= '<option value="'.$value['meta_value'].'">'.$value['meta_value'].'</option>';
149
+ }
150
+ $html .= '</select>';
151
+ }
152
+
153
+ echo $html;
154
+ }
155
+
156
  /**
157
  * upload.php
158
  *
177
 
178
  $targetDir = $uploads['path'];
179
 
180
+ if (! is_dir($targetDir) || ! is_writable($targetDir))
181
+ exit(json_encode(array("jsonrpc" => "2.0", "error" => array("code" => 100, "message" => "Uploads folder is not writable."), "id" => "id")));
182
+
183
  $cleanupTargetDir = true; // Remove old files
184
  $maxFileAge = 5 * 3600; // Temp file age in seconds
185
 
286
  }
287
 
288
  // Return JSON-RPC response
289
+ echo json_encode(array("jsonrpc" => "2.0", "result" => null, "id" => "id", "name" => $filePath)); die;
290
 
291
  }
292
 
293
  public function download(){
294
  PMXI_download::csv(PMXI_Plugin::ROOT_DIR.'/logs/'.$_GET['file'].'.txt');
295
+ }
296
+
297
  }
controllers/controller/admin.php CHANGED
@@ -43,19 +43,28 @@ abstract class PMXI_Controller_Admin extends PMXI_Controller {
43
  wp_enqueue_style('jquery-ui', PMXI_ROOT_URL . '/static/js/jquery/css/redmond/jquery-ui.css');
44
  wp_enqueue_style('jquery-tipsy', PMXI_ROOT_URL . '/static/js/jquery/css/smoothness/jquery.tipsy.css');
45
  wp_enqueue_style('pmxi-admin-style', PMXI_ROOT_URL . '/static/css/admin.css');
46
- wp_enqueue_style('pmxi-admin-style-ie', PMXI_ROOT_URL . '/static/css/admin-ie.css');
 
 
47
  $wp_styles->add_data('pmxi-admin-style-ie', 'conditional', 'lte IE 7');
 
48
 
 
 
 
 
49
  $scheme_color = get_user_option('admin_color') and is_file(PMXI_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css') or $scheme_color = 'fresh';
50
  if (is_file(PMXI_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css')) {
51
  wp_enqueue_style('pmxi-admin-style-color', PMXI_ROOT_URL . '/static/css/admin-colors-' . $scheme_color . '.css');
52
  }
53
-
54
  wp_enqueue_script('jquery-ui-datepicker', PMXI_ROOT_URL . '/static/js/jquery/ui.datepicker.js', 'jquery-ui-core');
55
  wp_enqueue_script('jquery-ui-autocomplete', PMXI_ROOT_URL . '/static/js/jquery/ui.autocomplete.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'));
56
  wp_enqueue_script('jquery-tipsy', PMXI_ROOT_URL . '/static/js/jquery/jquery.tipsy.js', 'jquery');
57
  wp_enqueue_script('jquery-nestable', PMXI_ROOT_URL . '/static/js/jquery/jquery.mjs.nestedSortable.js', array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-tabs', 'jquery-ui-progressbar'));
58
- wp_enqueue_script('jquery-moment', PMXI_ROOT_URL . '/static/js/jquery/moment.js', 'jquery');
 
 
59
 
60
  /* load plupload scripts */
61
  wp_deregister_script('swfupload-all');
43
  wp_enqueue_style('jquery-ui', PMXI_ROOT_URL . '/static/js/jquery/css/redmond/jquery-ui.css');
44
  wp_enqueue_style('jquery-tipsy', PMXI_ROOT_URL . '/static/js/jquery/css/smoothness/jquery.tipsy.css');
45
  wp_enqueue_style('pmxi-admin-style', PMXI_ROOT_URL . '/static/css/admin.css');
46
+ wp_enqueue_style('pmxi-admin-style-ie', PMXI_ROOT_URL . '/static/css/admin-ie.css');
47
+ wp_enqueue_style('jquery-select2', PMXI_ROOT_URL . '/static/js/jquery/css/select2/select2.css');
48
+ wp_enqueue_style('jquery-select2', PMXI_ROOT_URL . '/static/js/jquery/css/select2/select2-bootstrap.css');
49
  $wp_styles->add_data('pmxi-admin-style-ie', 'conditional', 'lte IE 7');
50
+ wp_enqueue_style('wp-pointer');
51
 
52
+ if ( version_compare(get_bloginfo('version'), '3.8-RC1') >= 0 ){
53
+ wp_enqueue_style('pmxi-admin-style-wp-3.8', PMXI_ROOT_URL . '/static/css/admin-wp-3.8.css');
54
+ }
55
+
56
  $scheme_color = get_user_option('admin_color') and is_file(PMXI_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css') or $scheme_color = 'fresh';
57
  if (is_file(PMXI_Plugin::ROOT_DIR . '/static/css/admin-colors-' . $scheme_color . '.css')) {
58
  wp_enqueue_style('pmxi-admin-style-color', PMXI_ROOT_URL . '/static/css/admin-colors-' . $scheme_color . '.css');
59
  }
60
+
61
  wp_enqueue_script('jquery-ui-datepicker', PMXI_ROOT_URL . '/static/js/jquery/ui.datepicker.js', 'jquery-ui-core');
62
  wp_enqueue_script('jquery-ui-autocomplete', PMXI_ROOT_URL . '/static/js/jquery/ui.autocomplete.js', array('jquery-ui-core', 'jquery-ui-widget', 'jquery-ui-position'));
63
  wp_enqueue_script('jquery-tipsy', PMXI_ROOT_URL . '/static/js/jquery/jquery.tipsy.js', 'jquery');
64
  wp_enqueue_script('jquery-nestable', PMXI_ROOT_URL . '/static/js/jquery/jquery.mjs.nestedSortable.js', array('jquery', 'jquery-ui-dialog', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable', 'jquery-ui-tabs', 'jquery-ui-progressbar'));
65
+ wp_enqueue_script('jquery-moment', PMXI_ROOT_URL . '/static/js/jquery/moment.js', 'jquery');
66
+ wp_enqueue_script('jquery-select2', PMXI_ROOT_URL . '/static/js/jquery/select2.min.js', 'jquery');
67
+ wp_enqueue_script('wp-pointer');
68
 
69
  /* load plupload scripts */
70
  wp_deregister_script('swfupload-all');
helpers/get_file_curl.php CHANGED
@@ -3,7 +3,7 @@
3
  if ( ! function_exists('get_file_curl') ):
4
 
5
  function get_file_curl($url, $fullpath, $to_variable = false) {
6
-
7
  $rawdata = wp_remote_retrieve_body( wp_remote_get($url) );
8
 
9
  if (empty($rawdata))
@@ -14,11 +14,7 @@ if ( ! function_exists('get_file_curl') ):
14
  $fp = fopen($fullpath,'w');
15
  fwrite($fp, $rawdata);
16
  fclose($fp);
17
- }
18
-
19
- if( ! ($image_info = @getimagesize($fullpath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG)))
20
-
21
- return pmxi_curl_download($url, $fullpath, $to_variable);
22
 
23
  return ($to_variable) ? $rawdata : true;
24
  }
@@ -36,7 +32,7 @@ if ( ! function_exists('pmxi_curl_download') ) {
36
  $rawdata = curl_exec_follow($ch);
37
 
38
  $result = curl_getinfo($ch, CURLINFO_HTTP_CODE);
39
-
40
  curl_close ($ch);
41
 
42
  if ( empty($rawdata) ) return false;
@@ -56,7 +52,7 @@ if ( ! function_exists('curl_exec_follow') ):
56
 
57
  function curl_exec_follow($ch, &$maxredirect = null) {
58
 
59
- $mr = $maxredirect === null ? 5 : intval($maxredirect);
60
 
61
  if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
62
 
@@ -87,6 +83,7 @@ if ( ! function_exists('curl_exec_follow') ):
87
  $code = 0;
88
  } else {
89
  $code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
 
90
  if ($code == 301 || $code == 302) {
91
  preg_match('/Location:(.*?)\n/', $header, $matches);
92
  $newurl = trim(array_pop($matches));
3
  if ( ! function_exists('get_file_curl') ):
4
 
5
  function get_file_curl($url, $fullpath, $to_variable = false) {
6
+
7
  $rawdata = wp_remote_retrieve_body( wp_remote_get($url) );
8
 
9
  if (empty($rawdata))
14
  $fp = fopen($fullpath,'w');
15
  fwrite($fp, $rawdata);
16
  fclose($fp);
17
+ }
 
 
 
 
18
 
19
  return ($to_variable) ? $rawdata : true;
20
  }
32
  $rawdata = curl_exec_follow($ch);
33
 
34
  $result = curl_getinfo($ch, CURLINFO_HTTP_CODE);
35
+
36
  curl_close ($ch);
37
 
38
  if ( empty($rawdata) ) return false;
52
 
53
  function curl_exec_follow($ch, &$maxredirect = null) {
54
 
55
+ $mr = $maxredirect === null ? 2 : intval($maxredirect);
56
 
57
  if (ini_get('open_basedir') == '' && ini_get('safe_mode' == 'Off')) {
58
 
83
  $code = 0;
84
  } else {
85
  $code = curl_getinfo($rch, CURLINFO_HTTP_CODE);
86
+
87
  if ($code == 301 || $code == 302) {
88
  preg_match('/Location:(.*?)\n/', $header, $matches);
89
  $newurl = trim(array_pop($matches));
helpers/is_exists_term.php CHANGED
@@ -1,26 +1,10 @@
1
  <?php
2
  if (!function_exists('is_exists_term')){
3
- function is_exists_term($tx_name, $name, $parent_id = ''){
 
4
 
5
- $term = false;
6
-
7
- delete_option("{$tx_name}_children");
8
-
9
- $siblings = get_terms($tx_name, array('fields' => 'all', 'get' => 'all', 'parent' => (int)$parent_id) );
10
-
11
- $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
12
- $args = wp_parse_args(array('name' => $name, 'taxonomy' => $tx_name), $defaults);
13
- $args = sanitize_term($args, $tx_name, 'db');
14
 
15
- if (!empty($siblings)) foreach ($siblings as $t) {
16
-
17
- if ($t->name == wp_unslash($args['name'])){
18
- $term = array('term_id' => $t->term_id);
19
- break;
20
- }
21
- }
22
-
23
- return $term;
24
  }
25
  }
26
  ?>
1
  <?php
2
  if (!function_exists('is_exists_term')){
3
+
4
+ function is_exists_term($tx_name, $name, $parent_id = ''){
5
 
6
+ return term_exists( $name, $tx_name, $parent_id );
 
 
 
 
 
 
 
 
7
 
 
 
 
 
 
 
 
 
 
8
  }
9
  }
10
  ?>
helpers/pmxi_findDuplicates.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Find duplicates according to settings
5
+ */
6
+ function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_duplicate_value = '', $duplicate_indicator = 'title')
7
+ {
8
+ global $wpdb;
9
+
10
+ if ('custom field' == $duplicate_indicator){
11
+ $duplicate_ids = array();
12
+ $args = array(
13
+ 'post_type' => $articleData['post_type'],
14
+ 'meta_query' => array(
15
+ array(
16
+ 'key' => $custom_duplicate_name,
17
+ 'value' => $custom_duplicate_value,
18
+ )
19
+ )
20
+ );
21
+ $query = new WP_Query( $args );
22
+
23
+ if ( $query->have_posts() ) $duplicate_ids[] = $query->post->ID;
24
+
25
+ wp_reset_postdata();
26
+
27
+ return $duplicate_ids;
28
+ }
29
+ elseif('parent' == $duplicate_indicator){
30
+
31
+ $field = 'post_title'; // post_title or post_content
32
+ return $wpdb->get_col($wpdb->prepare("
33
+ SELECT ID FROM " . $wpdb->posts . "
34
+ WHERE
35
+ post_type = %s
36
+ AND ID != %s
37
+ AND post_parent = %s
38
+ AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
39
+ ",
40
+ $articleData['post_type'],
41
+ isset($articleData['ID']) ? $articleData['ID'] : 0,
42
+ (!empty($articleData['post_parent'])) ? $articleData['post_parent'] : 0,
43
+ preg_replace('%[ \\t\\n]%', '', $articleData[$field])
44
+ ));
45
+ }
46
+ else{
47
+ $field = 'post_' . $duplicate_indicator; // post_title or post_content
48
+ return $wpdb->get_col($wpdb->prepare("
49
+ SELECT ID FROM " . $wpdb->posts . "
50
+ WHERE
51
+ post_type = %s
52
+ AND ID != %s
53
+ AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
54
+ ",
55
+ $articleData['post_type'],
56
+ isset($articleData['ID']) ? $articleData['ID'] : 0,
57
+ preg_replace('%[ \\t\\n]%', '', $articleData[$field])
58
+ ));
59
+ }
60
+ }
61
+
62
+ ?>
helpers/pmxi_functions.php CHANGED
@@ -202,6 +202,17 @@
202
  }
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * Reading large files from remote server
207
  * @ $filePath - file URL
@@ -218,7 +229,7 @@
218
 
219
  $uploads = wp_upload_dir();
220
  $tmpname = wp_unique_filename($uploads['path'], ($type and strlen(basename($filePath)) < 30) ? basename($filePath) : time());
221
- $localPath = $uploads['path'] .'/'. $tmpname;
222
 
223
  $file = @fopen($filePath, "rb");
224
 
@@ -233,7 +244,7 @@
233
  }
234
  @fclose($file);
235
  @fclose($fp);
236
- }
237
 
238
  if (!file_exists($localPath)) {
239
 
@@ -249,7 +260,11 @@
249
  @fclose($file);
250
  }
251
 
252
- }
 
 
 
 
253
 
254
  return ($detect) ? array('type' => $type, 'localPath' => $localPath) : $localPath;
255
  }
@@ -261,7 +276,9 @@
261
  $type = 'csv';
262
  $uploads = wp_upload_dir();
263
  $tmpname = wp_unique_filename($uploads['path'], (strlen(basename($filename)) < 30) ? basename($filename) : time());
264
- $fp = @fopen($uploads['path'] .'/'. $tmpname, 'w');
 
 
265
 
266
  $file = @gzopen($filename, 'rb', $use_include_path);
267
  if ($file) {
@@ -274,69 +291,10 @@
274
  gzclose($file);
275
  }
276
  @fclose($fp);
277
- $localPath = $uploads['path'] .'/'. $tmpname;
278
  return array('type' => $type, 'localPath' => $localPath);
279
  }
280
- }
281
-
282
- if ( ! function_exists('stream_notification_callback')){
283
-
284
- function stream_notification_callback($notification_code, $severity, $message, $message_code, $bytes_transferred, $bytes_max) {
285
- static $filesize = null;
286
-
287
- $logger = create_function('$m', 'echo "$m\\n"; flush();');
288
-
289
- $msg = '';
290
- switch($notification_code) {
291
- case STREAM_NOTIFY_RESOLVE:
292
- case STREAM_NOTIFY_AUTH_REQUIRED:
293
- case STREAM_NOTIFY_COMPLETED:
294
- case STREAM_NOTIFY_FAILURE:
295
- case STREAM_NOTIFY_AUTH_RESULT:
296
- /* Ignore */
297
- break;
298
-
299
- case STREAM_NOTIFY_REDIRECTED:
300
- //$msg = "Being redirected to: ". $message;
301
- break;
302
-
303
- case STREAM_NOTIFY_CONNECT:
304
- //$msg = "Connected...";
305
- break;
306
-
307
- case STREAM_NOTIFY_FILE_SIZE_IS:
308
- $filesize = $bytes_max;
309
- //$msg = "Filesize: ". $filesize;
310
- break;
311
-
312
- case STREAM_NOTIFY_MIME_TYPE_IS:
313
- //$msg = "Mime-type: ". $message;
314
- break;
315
-
316
- case STREAM_NOTIFY_PROGRESS:
317
- if ($bytes_transferred > 0) {
318
- /*$m = "<script type='text/javascript'>";
319
- if (!isset($filesize)) {
320
- $m .= "document.getElementById('url_progressbar').innerHTML('Unknown filesize.. ".($bytes_transferred/1024)."d kb done..');";
321
- } else {
322
- $length = (int)(($bytes_transferred/$filesize)*100);
323
- $m .= "document.getElementById('url_upload_value').style.width = ".$length."%";
324
- $m .= "document.getElementById('url_progressbar').innerHTML('".$length."% (".($bytes_transferred/1024)."/".($filesize/1024)." kb)');";
325
- }
326
- $m .= "</script>";*/
327
-
328
- //$logger and call_user_func($logger, sprintf(__('%s', 'pmxi_plugin'), ($bytes_transferred/1024)));
329
-
330
- /*echo(str_repeat(' ', 256));
331
- if (@ob_get_contents()) {
332
- @ob_end_flush();
333
- }
334
- flush();*/
335
- }
336
- break;
337
- }
338
- }
339
- }
340
 
341
  if ( ! function_exists('pmxi_strip_tags_content')){
342
 
@@ -374,7 +332,7 @@
374
 
375
  $change_array = explode(',', $change);
376
 
377
- if ( empty($change_array) or count($orig_array) != count($change_array)) return "";
378
 
379
  return str_replace(array_map('trim', $orig_array), array_map('trim', $change_array), $value);
380
 
@@ -386,23 +344,42 @@
386
  function pmxi_convert_encoding ( $source, $target_encoding = 'ASCII' )
387
  {
388
 
389
- // detect the character encoding of the incoming file
390
- $encoding = mb_detect_encoding( $source, "auto" );
391
-
392
- // escape all of the question marks so we can remove artifacts from
393
- // the unicode conversion process
394
- $target = str_replace( "?", "[question_mark]", $source );
395
-
396
- // convert the string to the target encoding
397
- $target = mb_convert_encoding( $target, $target_encoding, $encoding);
398
-
399
- // remove any question marks that have been introduced because of illegal characters
400
- $target = str_replace( "?", "", $target );
401
-
402
- // replace the token string "[question_mark]" with the symbol "?"
403
- $target = str_replace( "[question_mark]", "?", $target );
404
-
405
- return html_entity_decode($target, ENT_COMPAT, 'UTF-8');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
406
  }
407
  }
408
 
@@ -437,5 +414,7 @@
437
  * Alias of wp_session_write_close()
438
  */
439
  function pmxi_session_commit() {
440
- pmxi_shutdown();
 
 
441
  }
202
  }
203
  }
204
 
205
+ if ( ! function_exists('getExtensionFromStr')){
206
+ function pmxi_getExtensionFromStr($str)
207
+ {
208
+ $i = strrpos($str,".");
209
+ if (!$i) return "";
210
+ $l = strlen($str) - $i;
211
+ $ext = substr($str,$i+1,$l);
212
+ return (preg_match('%\W(jpg|jpeg|gif|png)$%i', basename($ext)) and strlen($ext) <= 4) ? $ext : "";
213
+ }
214
+ }
215
+
216
  /**
217
  * Reading large files from remote server
218
  * @ $filePath - file URL
229
 
230
  $uploads = wp_upload_dir();
231
  $tmpname = wp_unique_filename($uploads['path'], ($type and strlen(basename($filePath)) < 30) ? basename($filePath) : time());
232
+ $localPath = $uploads['path'] .'/'. url_title($tmpname) . ((!$type) ? '.tmp' : '');
233
 
234
  $file = @fopen($filePath, "rb");
235
 
244
  }
245
  @fclose($file);
246
  @fclose($fp);
247
+ }
248
 
249
  if (!file_exists($localPath)) {
250
 
260
  @fclose($file);
261
  }
262
 
263
+ }
264
+
265
+ $newpath = str_replace("." . $type, "", $localPath) . '.' . $type;
266
+
267
+ if (@rename($localPath, $newpath)) $localPath = $newpath;
268
 
269
  return ($detect) ? array('type' => $type, 'localPath' => $localPath) : $localPath;
270
  }
276
  $type = 'csv';
277
  $uploads = wp_upload_dir();
278
  $tmpname = wp_unique_filename($uploads['path'], (strlen(basename($filename)) < 30) ? basename($filename) : time());
279
+ $localPath = $uploads['path'] .'/'. url_title($tmpname);
280
+
281
+ $fp = @fopen($localPath, 'w');
282
 
283
  $file = @gzopen($filename, 'rb', $use_include_path);
284
  if ($file) {
291
  gzclose($file);
292
  }
293
  @fclose($fp);
294
+
295
  return array('type' => $type, 'localPath' => $localPath);
296
  }
297
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
 
299
  if ( ! function_exists('pmxi_strip_tags_content')){
300
 
332
 
333
  $change_array = explode(',', $change);
334
 
335
+ if ( empty($change_array) or count($orig_array) != count($change_array)) return "";
336
 
337
  return str_replace(array_map('trim', $orig_array), array_map('trim', $change_array), $value);
338
 
344
  function pmxi_convert_encoding ( $source, $target_encoding = 'ASCII' )
345
  {
346
 
347
+ if ( function_exists('mb_detect_encoding') ){
348
+
349
+ // detect the character encoding of the incoming file
350
+ $encoding = mb_detect_encoding( $source, "auto" );
351
+
352
+ // escape all of the question marks so we can remove artifacts from
353
+ // the unicode conversion process
354
+ $target = str_replace( "?", "[question_mark]", $source );
355
+
356
+ // convert the string to the target encoding
357
+ $target = mb_convert_encoding( $target, $target_encoding, $encoding);
358
+
359
+ // remove any question marks that have been introduced because of illegal characters
360
+ $target = str_replace( "?", "", $target );
361
+
362
+ // replace the token string "[question_mark]" with the symbol "?"
363
+ $target = str_replace( "[question_mark]", "?", $target );
364
+
365
+ return html_entity_decode($target, ENT_COMPAT, 'UTF-8');
366
+
367
+ }
368
+
369
+ return $source;
370
+ }
371
+ }
372
+
373
+ if ( ! function_exists('pmxi_imageurlencode')){
374
+
375
+ function pmxi_imageurlencode($url){
376
+
377
+ $urlArray = parse_url($url);
378
+
379
+ $url = ($urlArray['scheme'].'://'.$urlArray['host'].str_replace('%2F', '/', urlencode($urlArray['path'])));
380
+ $url .= isset($urlArray['query']) ? '?'.$urlArray['query'] : '';
381
+
382
+ return $url;
383
  }
384
  }
385
 
414
  * Alias of wp_session_write_close()
415
  */
416
  function pmxi_session_commit() {
417
+ PMXI_Plugin::$session = PMXI_Session::get_instance();
418
+ PMXI_Plugin::$session->write_data();
419
+ do_action( 'pmxi_session_commit' );
420
  }
helpers/pmxi_insert_attachment.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmxi_insert_attachment($object, $file = false, $parent = 0) {
3
+ global $wpdb;
4
+
5
+ $user_id = get_current_user_id();
6
+
7
+ $defaults = array('post_status' => 'inherit', 'post_type' => 'post', 'post_author' => $user_id,
8
+ 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 'post_title' => '',
9
+ 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 'post_content' => '',
10
+ 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0, 'context' => '');
11
+
12
+ $object = wp_parse_args($object, $defaults);
13
+ if ( !empty($parent) )
14
+ $object['post_parent'] = $parent;
15
+
16
+ unset( $object[ 'filter' ] );
17
+
18
+ $object = sanitize_post($object, 'db');
19
+
20
+ // export array as variables
21
+ extract($object, EXTR_SKIP);
22
+
23
+ if ( empty($post_author) )
24
+ $post_author = $user_id;
25
+
26
+ $post_type = 'attachment';
27
+
28
+ if ( ! in_array( $post_status, array( 'inherit', 'private' ) ) )
29
+ $post_status = 'inherit';
30
+
31
+ if ( !empty($post_category) )
32
+ $post_category = array_filter($post_category); // Filter out empty terms
33
+
34
+ // Make sure we set a valid category.
35
+ if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
36
+ $post_category = array();
37
+ }
38
+
39
+ // Are we updating or creating?
40
+ if ( !empty($ID) ) {
41
+ $update = true;
42
+ $post_ID = (int) $ID;
43
+ } else {
44
+ $update = false;
45
+ $post_ID = 0;
46
+ }
47
+
48
+ // Create a valid post name.
49
+ if ( empty($post_name) )
50
+ $post_name = sanitize_title($post_title);
51
+ else
52
+ $post_name = sanitize_title($post_name);
53
+
54
+ // expected_slashed ($post_name)
55
+ $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
56
+
57
+ if ( empty($post_date) )
58
+ $post_date = current_time('mysql');
59
+ if ( empty($post_date_gmt) )
60
+ $post_date_gmt = current_time('mysql', 1);
61
+
62
+ if ( empty($post_modified) )
63
+ $post_modified = $post_date;
64
+ if ( empty($post_modified_gmt) )
65
+ $post_modified_gmt = $post_date_gmt;
66
+
67
+ if ( empty($comment_status) ) {
68
+ if ( $update )
69
+ $comment_status = 'closed';
70
+ else
71
+ $comment_status = get_option('default_comment_status');
72
+ }
73
+ if ( empty($ping_status) )
74
+ $ping_status = get_option('default_ping_status');
75
+
76
+ if ( isset($to_ping) )
77
+ $to_ping = preg_replace('|\s+|', "\n", $to_ping);
78
+ else
79
+ $to_ping = '';
80
+
81
+ if ( isset($post_parent) )
82
+ $post_parent = (int) $post_parent;
83
+ else
84
+ $post_parent = 0;
85
+
86
+ if ( isset($menu_order) )
87
+ $menu_order = (int) $menu_order;
88
+ else
89
+ $menu_order = 0;
90
+
91
+ if ( !isset($post_password) )
92
+ $post_password = '';
93
+
94
+ if ( ! isset($pinged) )
95
+ $pinged = '';
96
+
97
+ // expected_slashed (everything!)
98
+ $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'post_mime_type', 'guid' ) );
99
+ $data = wp_unslash( $data );
100
+
101
+ if ( $update ) {
102
+ $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) );
103
+ } else {
104
+ // If there is a suggested ID, use it if not already present
105
+ if ( !empty($import_id) ) {
106
+ $import_id = (int) $import_id;
107
+ if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) {
108
+ $data['ID'] = $import_id;
109
+ }
110
+ }
111
+
112
+ $wpdb->insert( $wpdb->posts, $data );
113
+ $post_ID = (int) $wpdb->insert_id;
114
+ }
115
+
116
+ if ( empty($post_name) ) {
117
+ $post_name = sanitize_title($post_title, $post_ID);
118
+ $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
119
+ }
120
+
121
+ if ( $file )
122
+ update_attached_file( $post_ID, $file );
123
+
124
+ clean_post_cache( $post_ID );
125
+
126
+ if ( ! empty( $context ) )
127
+ add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
128
+
129
+ return $post_ID;
130
+ }
131
+ ?>
helpers/pmxi_insert_post.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function pmxi_insert_post($postarr, $wp_error = false){
4
+ global $wpdb;
5
+
6
+ $user_id = get_current_user_id();
7
+
8
+ $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_id,
9
+ 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0,
10
+ 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '',
11
+ 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0,
12
+ 'post_content' => '', 'post_title' => '');
13
+
14
+ $postarr = wp_parse_args($postarr, $defaults);
15
+
16
+ $postarr = sanitize_post($postarr, 'db');
17
+
18
+ // export array as variables
19
+ extract($postarr, EXTR_SKIP);
20
+
21
+ // Are we updating or creating?
22
+ $post_ID = 0;
23
+ $update = false;
24
+ if ( ! empty( $ID ) ) {
25
+ $update = true;
26
+
27
+ // Get the post ID and GUID
28
+ $post_ID = $ID;
29
+ $post_before = get_post( $post_ID );
30
+ if ( is_null( $post_before ) ) {
31
+ if ( $wp_error )
32
+ return new WP_Error( 'invalid_post', __( 'Invalid post ID.' ) );
33
+ return 0;
34
+ }
35
+
36
+ $guid = get_post_field( 'guid', $post_ID );
37
+ $previous_status = get_post_field('post_status', $ID);
38
+ } else {
39
+ $previous_status = 'new';
40
+ }
41
+
42
+ if ( empty($post_type) )
43
+ $post_type = 'post';
44
+
45
+ if ( empty($post_status) )
46
+ $post_status = 'draft';
47
+
48
+ // Make sure we set a valid category.
49
+ if ( empty($post_category) || 0 == count($post_category) || !is_array($post_category) ) {
50
+ // 'post' requires at least one category.
51
+ if ( 'post' == $post_type && 'auto-draft' != $post_status )
52
+ $post_category = array( get_option('default_category') );
53
+ else
54
+ $post_category = array();
55
+ }
56
+
57
+ if ( empty($post_author) )
58
+ $post_author = $user_id;
59
+
60
+ // Create a valid post name. Drafts and pending posts are allowed to have an empty
61
+ // post name.
62
+ if ( empty($post_name) ) {
63
+ if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
64
+ $post_name = sanitize_title($post_title);
65
+ else
66
+ $post_name = '';
67
+ } else {
68
+ // On updates, we need to check to see if it's using the old, fixed sanitization context.
69
+ $check_name = sanitize_title( $post_name, '', 'old-save' );
70
+ if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $ID ) == $check_name )
71
+ $post_name = $check_name;
72
+ else // new post, or slug has changed.
73
+ $post_name = sanitize_title($post_name);
74
+ }
75
+
76
+ // If the post date is empty (due to having been new or a draft) and status is not 'draft' or 'pending', set date to now
77
+ if ( empty($post_date) || '0000-00-00 00:00:00' == $post_date )
78
+ $post_date = current_time('mysql');
79
+
80
+ // validate the date
81
+ $mm = substr( $post_date, 5, 2 );
82
+ $jj = substr( $post_date, 8, 2 );
83
+ $aa = substr( $post_date, 0, 4 );
84
+ $valid_date = wp_checkdate( $mm, $jj, $aa, $post_date );
85
+ if ( !$valid_date ) {
86
+ if ( $wp_error )
87
+ return new WP_Error( 'invalid_date', __( 'Whoops, the provided date is invalid.' ) );
88
+ else
89
+ return 0;
90
+ }
91
+
92
+ if ( empty($post_date_gmt) || '0000-00-00 00:00:00' == $post_date_gmt ) {
93
+ if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
94
+ $post_date_gmt = get_gmt_from_date($post_date);
95
+ else
96
+ $post_date_gmt = '0000-00-00 00:00:00';
97
+ }
98
+
99
+ if ( $update || '0000-00-00 00:00:00' == $post_date ) {
100
+ $post_modified = current_time( 'mysql' );
101
+ $post_modified_gmt = current_time( 'mysql', 1 );
102
+ } else {
103
+ $post_modified = $post_date;
104
+ $post_modified_gmt = $post_date_gmt;
105
+ }
106
+
107
+ if ( 'publish' == $post_status ) {
108
+ $now = gmdate('Y-m-d H:i:59');
109
+ if ( mysql2date('U', $post_date_gmt, false) > mysql2date('U', $now, false) )
110
+ $post_status = 'future';
111
+ } elseif( 'future' == $post_status ) {
112
+ $now = gmdate('Y-m-d H:i:59');
113
+ if ( mysql2date('U', $post_date_gmt, false) <= mysql2date('U', $now, false) )
114
+ $post_status = 'publish';
115
+ }
116
+
117
+ if ( empty($comment_status) ) {
118
+ if ( $update )
119
+ $comment_status = 'closed';
120
+ else
121
+ $comment_status = get_option('default_comment_status');
122
+ }
123
+ if ( empty($ping_status) )
124
+ $ping_status = get_option('default_ping_status');
125
+
126
+ if ( isset($to_ping) )
127
+ $to_ping = sanitize_trackback_urls( $to_ping );
128
+ else
129
+ $to_ping = '';
130
+
131
+ if ( ! isset($pinged) )
132
+ $pinged = '';
133
+
134
+ if ( isset($post_parent) )
135
+ $post_parent = (int) $post_parent;
136
+ else
137
+ $post_parent = 0;
138
+
139
+ // Check the post_parent to see if it will cause a hierarchy loop
140
+ $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
141
+
142
+ if ( isset($menu_order) )
143
+ $menu_order = (int) $menu_order;
144
+ else
145
+ $menu_order = 0;
146
+
147
+ $post_name = wp_unique_post_slug($post_name, $post_ID, $post_status, $post_type, $post_parent);
148
+
149
+ // expected_slashed (everything!)
150
+ $data = compact( array( 'post_author', 'post_date', 'post_date_gmt', 'post_content', 'post_content_filtered', 'post_title', 'post_excerpt', 'post_status', 'post_type', 'comment_status', 'ping_status', 'post_password', 'post_name', 'to_ping', 'pinged', 'post_modified', 'post_modified_gmt', 'post_parent', 'menu_order', 'guid' ) );
151
+ $data = wp_unslash( $data );
152
+ $where = array( 'ID' => $post_ID );
153
+
154
+ if ( $update ) {
155
+ if ( false === $wpdb->update( $wpdb->posts, $data, $where ) ) {
156
+ if ( $wp_error )
157
+ return new WP_Error('db_update_error', __('Could not update post in the database'), $wpdb->last_error);
158
+ else
159
+ return 0;
160
+ }
161
+ } else {
162
+ if ( isset($post_mime_type) )
163
+ $data['post_mime_type'] = wp_unslash( $post_mime_type ); // This isn't in the update
164
+ if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
165
+ if ( $wp_error )
166
+ return new WP_Error('db_insert_error', __('Could not insert post into the database'), $wpdb->last_error);
167
+ else
168
+ return 0;
169
+ }
170
+ $post_ID = (int) $wpdb->insert_id;
171
+
172
+ // use the newly generated $post_ID
173
+ $where = array( 'ID' => $post_ID );
174
+ }
175
+
176
+ if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
177
+ wp_set_post_tags( $post_ID, $tags_input );
178
+
179
+ $current_guid = get_post_field( 'guid', $post_ID );
180
+
181
+ // Set GUID
182
+ if ( !$update && '' == $current_guid )
183
+ $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post_ID ) ), $where );
184
+
185
+ return $post_ID;
186
+ }
187
+
188
+ ?>
helpers/pmxi_recursion_taxes.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
3
+
4
+ if (is_array($parent)){
5
+ $parent['name'] = sanitize_text_field($parent['name']);
6
+ if (empty($parent['parent'])){
7
+
8
+ $term = is_exists_term($tx_name, $parent['name']);
9
+
10
+ if ( empty($term) and !is_wp_error($term) ){
11
+ $term = wp_insert_term(
12
+ $parent['name'], // the term
13
+ $tx_name // the taxonomy
14
+ );
15
+ }
16
+ return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
17
+ }
18
+ else{
19
+ $parent_id = pmxi_recursion_taxes($parent['parent'], $tx_name, $txes, $key);
20
+
21
+ $term = is_exists_term($tx_name, $parent['name'], (int)$parent_id);
22
+
23
+ if ( empty($term) and !is_wp_error($term) ){
24
+ $term = wp_insert_term(
25
+ $parent, // the term
26
+ $tx_name, // the taxonomy
27
+ array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
28
+ );
29
+ }
30
+ return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
31
+ }
32
+ }
33
+ else{
34
+
35
+ if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
36
+ $parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
37
+
38
+ $term = is_exists_term($tx_name, $parent, (int)$parent_id);
39
+
40
+ if ( empty($term) and !is_wp_error($term) ){
41
+ $term = wp_insert_term(
42
+ $parent, // the term
43
+ $tx_name, // the taxonomy
44
+ array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
45
+ );
46
+ }
47
+ return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
48
+ }
49
+ else{
50
+
51
+ $term = is_exists_term($tx_name, $parent);
52
+ if ( empty($term) and !is_wp_error($term) ){
53
+ $term = wp_insert_term(
54
+ $parent, // the term
55
+ $tx_name // the taxonomy
56
+ );
57
+ }
58
+ return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
59
+ }
60
+ }
61
+
62
+ }
63
+ ?>
helpers/reverse_taxonomies_html.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! function_exists('reverse_taxonomies_html') ) {
4
+
5
+ function reverse_taxonomies_html($post_taxonomies, $item_id, &$i){
6
+ $childs = array();
7
+ foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
8
+
9
+ if (!empty($childs)){
10
+ ?>
11
+ <ol>
12
+ <?php
13
+ foreach ($childs as $child_cat){
14
+ $i++;
15
+ ?>
16
+ <li id="item_<?php echo $i; ?>">
17
+ <div class="drag-element">
18
+ <input type="checkbox" class="assign_post" <?php if ($child_cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
19
+ <input class="widefat" type="text" value="<?php echo esc_attr($child_cat->xpath); ?>"/>
20
+ </div>
21
+ <a href="javascript:void(0);" class="icon-item remove-ico"></a>
22
+ <?php echo reverse_taxonomies_html($post_taxonomies, $child_cat->item_id, $i); ?>
23
+ </li>
24
+ <?php
25
+ }
26
+ ?>
27
+ </ol>
28
+ <?php
29
+ }
30
+ }
31
+ }
32
+
33
+ ?>
helpers/wp_delete_attachments.php CHANGED
@@ -3,24 +3,29 @@
3
  * Delete attachments linked to a specified post
4
  * @param int $parent_id Parent id of post to delete attachments for
5
  */
6
- function wp_delete_attachments($parent_id, $unlink = true) {
7
  foreach (get_posts(array('post_parent' => $parent_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null)) as $attach) {
8
- if ($unlink){
9
- wp_delete_attachment($attach->ID, true);
10
- }
11
- else{
12
- global $wpdb;
13
- $sql = "delete a,b,c
14
- FROM ".$wpdb->posts." a
15
- LEFT JOIN ".$wpdb->term_relationships." b ON ( a.ID = b.object_id )
16
- LEFT JOIN ".$wpdb->postmeta." c ON ( a.ID = c.post_id )
17
- LEFT JOIN ".$wpdb->posts." d ON ( a.ID = d.post_parent )
18
- WHERE a.ID = ".$attach->ID.";";
19
 
20
- $wpdb->query(
21
- $wpdb->prepare($sql, '')
22
- );
23
- }
24
-
 
 
 
 
 
 
 
 
 
 
 
 
25
  }
26
  }
3
  * Delete attachments linked to a specified post
4
  * @param int $parent_id Parent id of post to delete attachments for
5
  */
6
+ function wp_delete_attachments($parent_id, $unlink = true, $type = '') {
7
  foreach (get_posts(array('post_parent' => $parent_id, 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null)) as $attach) {
8
+ if ($type == 'files' and ! wp_attachment_is_image( $attach->ID ) ){
9
+ wp_delete_attachment($attach->ID, true);
10
+ }
11
+ elseif ( ($type == 'images' and wp_attachment_is_image( $attach->ID )) or "" == $type){
 
 
 
 
 
 
 
12
 
13
+ if ($unlink or ! wp_attachment_is_image( $attach->ID )){
14
+ wp_delete_attachment($attach->ID, true);
15
+ }
16
+ else{
17
+ global $wpdb;
18
+ $sql = "delete a,b,c
19
+ FROM ".$wpdb->posts." a
20
+ LEFT JOIN ".$wpdb->term_relationships." b ON ( a.ID = b.object_id )
21
+ LEFT JOIN ".$wpdb->postmeta." c ON ( a.ID = c.post_id )
22
+ LEFT JOIN ".$wpdb->posts." d ON ( a.ID = d.post_parent )
23
+ WHERE a.ID = ".$attach->ID.";";
24
+
25
+ $wpdb->query(
26
+ $wpdb->prepare($sql, '')
27
+ );
28
+ }
29
+ }
30
  }
31
  }
libraries/XmlImportCsvParse.php CHANGED
@@ -1,61 +1,5 @@
1
  <?php
2
 
3
- /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
-
5
- /**
6
- * contains a few csv file data access tools.
7
- *
8
- * PHP VERSION 5
9
- *
10
- * LICENSE: The MIT License
11
- *
12
- * Copyright (c) <2008> <Kazuyoshi Tlacaelel>
13
- *
14
- * Permission is hereby granted, free of charge, to any person obtaining a copy
15
- * of this software and associated documentation files (the "Software"), to deal
16
- * in the Software without restriction, including without limitation the rights
17
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
- * copies of the Software, and to permit persons to whom the Software is
19
- * furnished to do so, subject to the following conditions:
20
- *
21
- * The above copyright notice and this permission notice shall be included in
22
- * all copies or substantial portions of the Software.
23
- *
24
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30
- * THE SOFTWARE.
31
- *
32
- * @category File
33
- * @package File_CSV_DataSource
34
- * @author Kazuyoshi Tlacaelel <kazu.dev@gmail.com>
35
- * @copyright 2008 Kazuyoshi Tlacaelel
36
- * @license The MIT License
37
- * @version SVN: $Id: DataSource.php 285574 2009-03-09 15:22:24Z ktlacaelel $
38
- * @link http://code.google.com/p/php-csv-parser/
39
- */
40
-
41
- /**
42
- * csv data fetcher
43
- *
44
- * Sample snippets refer to this csv file for demonstration.
45
- * <code>
46
- * name,age,skill
47
- * john,13,knows magic
48
- * tanaka,8,makes sushi
49
- * jose,5,dances salsa
50
- * </code>
51
- *
52
- * @category File
53
- * @package Csv_parse
54
- * @author Kazuyoshi Tlacaelel <kazu.dev@gmail.com>
55
- * @copyright 2008 Kazuyoshi Tlacaelel
56
- * @license The MIT License
57
- * @link http://code.google.com/p/php-csv-parser/
58
- */
59
  class PMXI_CsvParser
60
  {
61
  public
@@ -876,7 +820,8 @@ class PMXI_CsvParser
876
  return utf8_encode($in_str);
877
  }
878
 
879
- return $in_str;
 
880
 
881
  } // fixEncoding
882
 
@@ -965,7 +910,7 @@ class PMXI_CsvParser
965
  $wp_uploads = wp_upload_dir();
966
  if ($this->large_import){
967
  $tmpname = wp_unique_filename($wp_uploads['path'], str_replace("csv", "xml", basename($this->_filename)));
968
- if ('' == $this->xml_path) $this->xml_path = $wp_uploads['path'] .'/'. $tmpname;
969
  $fp = fopen($this->xml_path, 'w');
970
  fwrite($fp, "<?xml version=\"1.0\" encoding=\"".$this->csv_encoding."\"?><data>");
971
  }
@@ -990,16 +935,13 @@ class PMXI_CsvParser
990
  }
991
 
992
  if ($c or $create_new_headers) {
993
- if (!$this->large_import and empty($_POST['large_file'])) {
994
- array_push($this->rows, $keys);
995
- }
996
- else if (!empty($keys)){
997
 
998
  $chunk = array();
999
 
1000
  foreach ($this->headers as $key => $header) {
1001
  if ($this->auto_encoding)
1002
- $chunk[$header] = $this->fixEncoding( ($legacy_special_character_handling) ? htmlspecialchars($keys[$key], ENT_COMPAT, $this->csv_encoding) : $keys[$key] );
1003
  else
1004
  $chunk[$header] = ($legacy_special_character_handling) ? htmlspecialchars($keys[$key], ENT_COMPAT, $this->csv_encoding) : $keys[$key];
1005
  }
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class PMXI_CsvParser
4
  {
5
  public
820
  return utf8_encode($in_str);
821
  }
822
 
823
+ return $in_str;
824
+
825
 
826
  } // fixEncoding
827
 
910
  $wp_uploads = wp_upload_dir();
911
  if ($this->large_import){
912
  $tmpname = wp_unique_filename($wp_uploads['path'], str_replace("csv", "xml", basename($this->_filename)));
913
+ if ('' == $this->xml_path) $this->xml_path = $wp_uploads['path'] .'/'. url_title($tmpname);
914
  $fp = fopen($this->xml_path, 'w');
915
  fwrite($fp, "<?xml version=\"1.0\" encoding=\"".$this->csv_encoding."\"?><data>");
916
  }
935
  }
936
 
937
  if ($c or $create_new_headers) {
938
+ if (!empty($keys)){
 
 
 
939
 
940
  $chunk = array();
941
 
942
  foreach ($this->headers as $key => $header) {
943
  if ($this->auto_encoding)
944
+ $chunk[$header] = $this->fixEncoding( ($legacy_special_character_handling) ? htmlspecialchars($keys[$key], ENT_COMPAT, $this->csv_encoding) : $keys[$key] );
945
  else
946
  $chunk[$header] = ($legacy_special_character_handling) ? htmlspecialchars($keys[$key], ENT_COMPAT, $this->csv_encoding) : $keys[$key];
947
  }
models/file/record.php CHANGED
@@ -77,7 +77,7 @@ class PMXI_File_Record extends PMXI_Model_Record {
77
  if ($this->id) { // delete history file first
78
  $uploads = wp_upload_dir();
79
  $file_name = $uploads['basedir'] . '/wpallimport_history/' . $this->id;
80
- is_file($file_name) and unlink($file_name);
81
  }
82
  return parent::delete();
83
  }
77
  if ($this->id) { // delete history file first
78
  $uploads = wp_upload_dir();
79
  $file_name = $uploads['basedir'] . '/wpallimport_history/' . $this->id;
80
+ @file_exists($file_name) and @is_file($file_name) and @unlink($file_name);
81
  }
82
  return parent::delete();
83
  }
models/import/record.php CHANGED
@@ -25,25 +25,30 @@ class PMXI_Import_Record extends PMXI_Model_Record {
25
 
26
  PMXI_Import_Record::preprocessXml($xml);
27
 
28
- libxml_use_internal_errors(true);
29
- libxml_clear_errors();
30
- $_x = @simplexml_load_string($xml);
31
- $xml_errors = libxml_get_errors();
32
- libxml_clear_errors();
33
- if ($xml_errors) {
34
- $error_msg = '<strong>' . __('Invalid XML', 'pmxi_plugin') . '</strong><ul>';
35
- foreach($xml_errors as $error) {
36
- $error_msg .= '<li>';
37
- $error_msg .= __('Line', 'pmxi_plugin') . ' ' . $error->line . ', ';
38
- $error_msg .= __('Column', 'pmxi_plugin') . ' ' . $error->column . ', ';
39
- $error_msg .= __('Code', 'pmxi_plugin') . ' ' . $error->code . ': ';
40
- $error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
41
- $error_msg .= '</li>';
 
 
 
 
 
 
42
  }
43
- $error_msg .= '</ul>';
44
- $errors and $errors->add('form-validation', $error_msg);
45
- } else {
46
- return true;
47
  }
48
  }
49
  return false;
@@ -56,7 +61,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
56
  public function __construct($data = array()) {
57
  parent::__construct($data);
58
  $this->setTable(PMXI_Plugin::getInstance()->getTablePrefix() . 'imports');
59
- }
60
 
61
  /**
62
  * Perform import operation
@@ -65,96 +70,55 @@ class PMXI_Import_Record extends PMXI_Model_Record {
65
  * @return PMXI_Import_Record
66
  * @chainable
67
  */
68
- public function process($xml, $logger = NULL, $chunk = false, $is_cron = false) {
69
  add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // do not perform special filtering for imported content
70
 
 
 
71
  $this->options += PMXI_Plugin::get_default_import_options(); // make sure all options are defined
72
 
73
  $avoid_pingbacks = PMXI_Plugin::getInstance()->getOption('pingbacks');
74
  $legacy_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
75
 
76
- if ( $avoid_pingbacks and ! defined( 'WP_IMPORTING' ) ) define( 'WP_IMPORTING', true );
77
-
78
- in_array($this->type, array('ftp')) and ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Reading files for import...', 'pmxi_plugin'));
79
- in_array($this->type, array('ftp')) and ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, sprintf(_n('%s file found', '%s files found', count(PMXI_Plugin::$session->data['pmxi_import']['local_paths']), 'pmxi_plugin'), count(PMXI_Plugin::$session->data['pmxi_import']['local_paths'])));
80
 
81
  $postRecord = new PMXI_Post_Record();
82
 
83
  $tmp_files = array();
84
  // compose records to import
85
  $records = array();
86
- $chunk_records = array();
87
-
88
- if ($this->options['is_import_specified']) {
89
-
90
- foreach (preg_split('% *, *%', $this->options['import_specified'], -1, PREG_SPLIT_NO_EMPTY) as $chank) {
91
- if (preg_match('%^(\d+)-(\d+)$%', $chank, $mtch)) {
92
- $records = array_merge($records, range(intval($mtch[1]), intval($mtch[2])));
93
- } else {
94
- $records = array_merge($records, array(intval($chank)));
95
- }
96
- }
97
-
98
- $chunk_records = $records;
99
-
100
- if ($this->large_import == 'Yes' and !empty($records)){
101
-
102
- $this->set(array('count' => count($records)))->save();
103
-
104
- $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
105
-
106
- if (!in_array($chunk, $records)){
107
- $this->set(array(
108
- 'skipped' => $this->skipped + 1
109
- ))->save();
110
- PMXI_Plugin::$session['pmxi_import']['skipped_records'] = $this->skipped;
111
- $logger and call_user_func($logger, __('<b>SKIPPED</b>: by specified records option', 'pmxi_plugin'));
112
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
113
- // Time Elapsed
114
- if ( ! $is_cron ){
115
- $progress_msg = '<p class="import_process_bar"> Created ' . $this->created . ' / Updated ' . $this->updated . ' of '. $this->count .' records.</p><span class="import_percent">' . ceil(($records_count/$this->count) * 100) . '</span><span class="warnings_count">' . PMXI_Plugin::$session['pmxi_import']['warnings'] . '</span><span class="errors_count">' . PMXI_Plugin::$session['pmxi_import']['errors'] . '</span>';
116
- $logger and call_user_func($logger, $progress_msg);
117
- }
118
- PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
119
- pmxi_session_commit();
120
- return;
121
- }
122
- else $records = array();
123
- }
124
- }
125
  try {
126
 
127
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing titles...', 'pmxi_plugin'));
128
- $titles = XmlImportParser::factory($xml, $this->xpath, $this->template['title'], $file)->parse($records); $tmp_files[] = $file;
129
- if ($this->large_import != 'Yes')
130
- $this->set(array('count' => count($titles)))->save();
131
 
132
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing excerpts...', 'pmxi_plugin'));
133
  $post_excerpt = array();
134
  if (!empty($this->options['post_excerpt'])){
135
- $post_excerpt = XmlImportParser::factory($xml, $this->xpath, $this->options['post_excerpt'], $file)->parse($records); $tmp_files[] = $file;
136
  }
137
  else{
138
  count($titles) and $post_excerpt = array_fill(0, count($titles), '');
139
  }
140
 
141
  if ( "xpath" == $this->options['status'] ){
142
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing statuses...', 'pmxi_plugin'));
143
  $post_status = array();
144
  if (!empty($this->options['status_xpath'])){
145
- $post_status = XmlImportParser::factory($xml, $this->xpath, $this->options['status_xpath'], $file)->parse($records); $tmp_files[] = $file;
146
  }
147
  else{
148
  count($titles) and $post_status = array_fill(0, count($titles), '');
149
  }
150
  }
151
 
152
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing authors...', 'pmxi_plugin'));
153
  $post_author = array();
154
  $current_user = wp_get_current_user();
155
 
156
  if (!empty($this->options['author'])){
157
- $post_author = XmlImportParser::factory($xml, $this->xpath, $this->options['author'], $file)->parse($records); $tmp_files[] = $file;
158
  foreach ($post_author as $key => $author) {
159
  $user = get_user_by('login', $author) or $user = get_user_by('slug', $author) or $user = get_user_by('email', $author) or ctype_digit($author) and $user = get_user_by('id', $author);
160
  $post_author[$key] = (!empty($user)) ? $user->ID : $current_user->ID;
@@ -164,51 +128,52 @@ class PMXI_Import_Record extends PMXI_Model_Record {
164
  count($titles) and $post_author = array_fill(0, count($titles), $current_user->ID);
165
  }
166
 
167
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing slugs...', 'pmxi_plugin'));
168
  $post_slug = array();
169
  if (!empty($this->options['post_slug'])){
170
- $post_slug = XmlImportParser::factory($xml, $this->xpath, $this->options['post_slug'], $file)->parse($records); $tmp_files[] = $file;
171
  }
172
  else{
173
  count($titles) and $post_slug = array_fill(0, count($titles), '');
174
  }
175
 
176
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
177
  $contents = XmlImportParser::factory(
178
  (intval($this->template['is_keep_linebreaks']) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
179
- $this->xpath,
180
  $this->template['content'],
181
  $file)->parse($records
182
  ); $tmp_files[] = $file;
183
 
184
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing dates...', 'pmxi_plugin'));
185
  if ('specific' == $this->options['date_type']) {
186
- $dates = XmlImportParser::factory($xml, $this->xpath, $this->options['date'], $file)->parse($records); $tmp_files[] = $file;
187
  $warned = array(); // used to prevent the same notice displaying several times
188
  foreach ($dates as $i => $d) {
 
189
  $time = strtotime($d);
190
  if (FALSE === $time) {
191
  in_array($d, $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $d));
192
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
193
  $time = time();
194
  }
195
  $dates[$i] = date('Y-m-d H:i:s', $time);
196
  }
197
  } else {
198
- $dates_start = XmlImportParser::factory($xml, $this->xpath, $this->options['date_start'], $file)->parse($records); $tmp_files[] = $file;
199
- $dates_end = XmlImportParser::factory($xml, $this->xpath, $this->options['date_end'], $file)->parse($records); $tmp_files[] = $file;
200
  $warned = array(); // used to prevent the same notice displaying several times
201
  foreach ($dates_start as $i => $d) {
202
  $time_start = strtotime($dates_start[$i]);
203
  if (FALSE === $time_start) {
204
  in_array($dates_start[$i], $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $dates_start[$i]));
205
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
206
  $time_start = time();
207
  }
208
  $time_end = strtotime($dates_end[$i]);
209
  if (FALSE === $time_end) {
210
  in_array($dates_end[$i], $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $dates_end[$i]));
211
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
212
  $time_end = time();
213
  }
214
  $dates[$i] = date('Y-m-d H:i:s', mt_rand($time_start, $time_end));
@@ -217,8 +182,8 @@ class PMXI_Import_Record extends PMXI_Model_Record {
217
 
218
  $tags = array();
219
  if ($this->options['tags']) {
220
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing tags...', 'pmxi_plugin'));
221
- $tags_raw = XmlImportParser::factory($xml, $this->xpath, $this->options['tags'], $file)->parse($records); $tmp_files[] = $file;
222
  foreach ($tags_raw as $i => $t_raw) {
223
  $tags[$i] = '';
224
  if ('' != $t_raw) $tags[$i] = implode(', ', str_getcsv($t_raw, $this->options['tags_delim']));
@@ -238,11 +203,11 @@ class PMXI_Import_Record extends PMXI_Model_Record {
238
 
239
  if ((!empty($categories_hierarchy) and is_array($categories_hierarchy))){
240
 
241
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing categories...', 'pmxi_plugin'));
242
  $categories = array();
243
 
244
  foreach ($categories_hierarchy as $k => $category): if ("" == $category->xpath) continue;
245
- $cats_raw = XmlImportParser::factory($xml, $this->xpath, str_replace('\'','"',$category->xpath), $file)->parse($records); $tmp_files[] = $file;
246
  $warned = array(); // used to prevent the same notice displaying several times
247
  foreach ($cats_raw as $i => $c_raw) {
248
  if (empty($categories_hierarchy[$k]->cat_ids[$i])) $categories_hierarchy[$k]->cat_ids[$i] = array();
@@ -318,12 +283,12 @@ class PMXI_Import_Record extends PMXI_Model_Record {
318
  $tx = get_taxonomy($tx_name);
319
  $taxonomies[$tx_name] = array();
320
  if (!empty($tx->object_type) and in_array($taxonomies_object_type, $tx->object_type)) {
321
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, sprintf(__('Composing terms for `%s` taxonomy...', 'pmxi_plugin'), $tx->labels->name));
322
  $txes = array();
323
 
324
  $taxonomies_hierarchy = json_decode($tx_template);
325
  foreach ($taxonomies_hierarchy as $k => $taxonomy){ if ("" == $taxonomy->xpath) continue;
326
- $txes_raw = XmlImportParser::factory($xml, $this->xpath, str_replace('\'','"',$taxonomy->xpath), $file)->parse($records); $tmp_files[] = $file;
327
  $warned = array();
328
  foreach ($txes_raw as $i => $tx_raw) {
329
  if (empty($taxonomies_hierarchy[$k]->txn_names[$i])) $taxonomies_hierarchy[$k]->txn_names[$i] = array();
@@ -380,7 +345,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
380
  }
381
  }
382
  }; endif;
383
- // [/custom taxonomies]
384
 
385
  // serialized featured images
386
  if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
@@ -388,7 +353,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
388
  $logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created', 'pmxi_plugin'));
389
  PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
390
  } else {
391
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing URLs for featured images...', 'pmxi_plugin'));
392
  $featured_images = array();
393
  if ($this->options['featured_image']) {
394
  // Detect if images is separated by comma
@@ -401,13 +366,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
401
  {
402
  foreach($imgs as $img)
403
  {
404
- $posts_images = XmlImportParser::factory($xml, $this->xpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
405
  foreach($posts_images as $i => $val) $featured_images[$i][] = $val;
406
  }
407
  }
408
  else
409
  {
410
- $featured_images = XmlImportParser::factory($xml, $this->xpath, $this->options['featured_image'], $file)->parse($records); $tmp_files[] = $file;
411
  }
412
  }
413
 
@@ -421,7 +386,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
421
  $uploads = wp_upload_dir();
422
 
423
  // serialized images meta titles
424
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing image meta data (titles)...', 'pmxi_plugin'));
425
  $image_meta_titles = array();
426
 
427
  if ($this->options['image_meta_title']) {
@@ -436,13 +401,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
436
  {
437
  foreach($imgs as $img)
438
  {
439
- $posts_images = XmlImportParser::factory($xml, $this->xpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
440
  foreach($posts_images as $i => $val) $image_meta_titles[$i][] = $val;
441
  }
442
  }
443
  else
444
  {
445
- $image_meta_titles = XmlImportParser::factory($xml, $this->xpath, $this->options['image_meta_title'], $file)->parse($records); $tmp_files[] = $file;
446
  }
447
  }
448
 
@@ -451,7 +416,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
451
  }
452
 
453
  // serialized images meta captions
454
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing image meta data (captions)...', 'pmxi_plugin'));
455
  $image_meta_captions = array();
456
  if ($this->options['image_meta_caption']) {
457
  // Detect if images is separated by comma
@@ -464,13 +429,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
464
  {
465
  foreach($imgs as $img)
466
  {
467
- $posts_images = XmlImportParser::factory($xml, $this->xpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
468
  foreach($posts_images as $i => $val) $image_meta_captions[$i][] = $val;
469
  }
470
  }
471
  else
472
  {
473
- $image_meta_captions = XmlImportParser::factory($xml, $this->xpath, $this->options['image_meta_caption'], $file)->parse($records); $tmp_files[] = $file;
474
  }
475
  }
476
 
@@ -478,7 +443,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
478
  count($titles) and $image_meta_captions = array_fill(0, count($titles), '');
479
  }
480
  // serialized images meta alt text
481
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing image meta data (alt text)...', 'pmxi_plugin'));
482
  $image_meta_alts = array();
483
  if ($this->options['image_meta_alt']) {
484
  // Detect if images is separated by comma
@@ -491,13 +456,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
491
  {
492
  foreach($imgs as $img)
493
  {
494
- $posts_images = XmlImportParser::factory($xml, $this->xpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
495
  foreach($posts_images as $i => $val) $image_meta_alts[$i][] = $val;
496
  }
497
  }
498
  else
499
  {
500
- $image_meta_alts = XmlImportParser::factory($xml, $this->xpath, $this->options['image_meta_alt'], $file)->parse($records); $tmp_files[] = $file;
501
  }
502
  }
503
 
@@ -505,7 +470,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
505
  count($titles) and $image_meta_alts = array_fill(0, count($titles), '');
506
  }
507
  // serialized images meta description
508
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing image meta data (description)...', 'pmxi_plugin'));
509
  $image_meta_descriptions = array();
510
  if ($this->options['image_meta_description']) {
511
  // Detect if images is separated by comma
@@ -518,13 +483,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
518
  {
519
  foreach($imgs as $img)
520
  {
521
- $posts_images = XmlImportParser::factory($xml, $this->xpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
522
  foreach($posts_images as $i => $val) $image_meta_descriptions[$i][] = $val;
523
  }
524
  }
525
  else
526
  {
527
- $image_meta_descriptions = XmlImportParser::factory($xml, $this->xpath, $this->options['image_meta_description'], $file)->parse($records); $tmp_files[] = $file;
528
  }
529
  }
530
 
@@ -534,10 +499,10 @@ class PMXI_Import_Record extends PMXI_Model_Record {
534
  }
535
 
536
  // Composing images suffix
537
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $this->options['auto_rename_images'] and $logger and call_user_func($logger, __('Composing images suffix...', 'pmxi_plugin'));
538
  $auto_rename_images = array();
539
  if ( $this->options['auto_rename_images'] and ! empty($this->options['auto_rename_images_suffix'])){
540
- $auto_rename_images = XmlImportParser::factory($xml, $this->xpath, $this->options['auto_rename_images_suffix'], $file)->parse($records); $tmp_files[] = $file;
541
  }
542
  else{
543
  count($titles) and $auto_rename_images = array_fill(0, count($titles), '');
@@ -547,9 +512,9 @@ class PMXI_Import_Record extends PMXI_Model_Record {
547
  if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
548
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $uploads['error']);
549
  $logger and call_user_func($logger, __('<b>WARNING</b>: No attachments will be created', 'pmxi_plugin'));
550
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session['pmxi_import']['warnings'];
551
  } else {
552
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing URLs for attachments files...', 'pmxi_plugin'));
553
  $attachments = array();
554
 
555
  if ($this->options['attachments']) {
@@ -563,13 +528,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
563
  {
564
  foreach($atchs as $atch)
565
  {
566
- $posts_attachments = XmlImportParser::factory($xml, $this->xpath, trim($atch), $file)->parse($records); $tmp_files[] = $file;
567
  foreach($posts_attachments as $i => $val) $attachments[$i][] = $val;
568
  }
569
  }
570
  else
571
  {
572
- $attachments = XmlImportParser::factory($xml, $this->xpath, $this->options['attachments'], $file)->parse($records); $tmp_files[] = $file;
573
  }
574
  }
575
 
@@ -578,51 +543,76 @@ class PMXI_Import_Record extends PMXI_Model_Record {
578
  }
579
  }
580
 
581
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Composing unique keys...', 'pmxi_plugin'));
582
- $unique_keys = XmlImportParser::factory($xml, $this->xpath, $this->options['unique_key'], $file)->parse($records); $tmp_files[] = $file;
583
 
584
- ($chunk == 1 or (empty($this->large_import) or $this->large_import == 'No')) and $logger and call_user_func($logger, __('Processing posts...', 'pmxi_plugin'));
585
 
586
  if ('post' == $this->options['type'] and '' != $this->options['custom_type']) {
587
- $post_type = $this->options['custom_type'];
588
  } else {
589
  $post_type = $this->options['type'];
590
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
591
 
592
- // Import WooCommerce products
593
- if ( $post_type == "product" and class_exists('PMWI_Plugin')) {
 
 
 
 
 
594
 
595
- $product = new PMWI_Import_Record();
 
 
 
 
 
 
 
 
596
 
597
- extract( $product->process($this, count($titles), $xml, $logger, $chunk) );
598
-
599
  }
600
 
601
- $current_post_ids = array();
602
- foreach ($titles as $i => $void) {
 
 
 
603
 
604
  if (empty($titles[$i])) {
605
- if (class_exists('PMWI_Plugin') and !empty($single_product_parent_ID[$i])){
606
- $titles[$i] = $single_product_parent_ID[$i] . ' Product Variation';
607
  }
608
  else{
 
609
  $logger and call_user_func($logger, __('<b>SKIPPED</b>: by empty title', 'pmxi_plugin'));
610
  PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
611
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
612
- $this->set(array(
613
- 'skipped' => $this->skipped + 1
614
- ))->save();
615
- PMXI_Plugin::$session['pmxi_import']['skipped_records'] = $this->skipped;
616
- if ( ! $is_cron ){
617
- $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
618
- $progress_msg = '<p class="import_process_bar"> ' . __('Created', 'pmxi_plugin') . ' ' . $this->created . ' / ' . __('Updated','pmxi_plugin') . ' ' . $this->updated . ' ' . __('of', 'pmxi_plugin') . ' '. $this->count .' ' . __('records', 'pmxi_plugin') . '.</p><span class="import_percent">' . ceil(($records_count/$this->count) * 100) . '</span><span class="warnings_count">' . PMXI_Plugin::$session->data['pmxi_import']['warnings'] . '</span><span class="errors_count">' . PMXI_Plugin::$session->data['pmxi_import']['errors'] . '</span>';
619
- $logger and call_user_func($logger, $progress_msg);
620
- }
621
  pmxi_session_commit();
622
  continue;
623
  }
624
  }
625
-
626
  $articleData = array(
627
  'post_type' => $post_type,
628
  'post_status' => ("xpath" == $this->options['status']) ? $post_status[$i] : $this->options['status'],
@@ -634,7 +624,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
634
  'post_content' => ($this->template['is_leave_html']) ? html_entity_decode($contents[$i]) : $contents[$i],
635
  'post_date' => $dates[$i],
636
  'post_date_gmt' => get_gmt_from_date($dates[$i]),
637
- 'post_author' => $post_author[$i] ,
638
  'tags_input' => $tags[$i]
639
  );
640
 
@@ -650,15 +640,17 @@ class PMXI_Import_Record extends PMXI_Model_Record {
650
 
651
  // if Auto Matching re-import option selected
652
  if ("manual" != $this->options['duplicate_matching']){
653
- $postRecord->clear();
654
  // find corresponding article among previously imported
 
 
655
  $postRecord->getBy(array(
656
  'unique_key' => $unique_keys[$i],
657
  'import_id' => $this->id,
658
  ));
659
  if ( ! $postRecord->isEmpty() )
660
  $post_to_update = get_post($post_to_update_id = $postRecord->post_id);
661
-
662
  // if Manual Matching re-import option seleted
663
  } else {
664
 
@@ -670,171 +662,156 @@ class PMXI_Import_Record extends PMXI_Model_Record {
670
  ));
671
 
672
  if ('custom field' == $this->options['duplicate_indicator']) {
673
- $custom_duplicate_value = XmlImportParser::factory($xml, $this->xpath, $this->options['custom_duplicate_value'], $file)->parse($records); $tmp_files[] = $file;
674
- $custom_duplicate_name = XmlImportParser::factory($xml, $this->xpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
675
  }
676
  else{
677
  count($titles) and $custom_duplicate_name = $custom_duplicate_value = array_fill(0, count($titles), '');
678
  }
679
 
680
  // handle duplicates according to import settings
681
- if ($duplicates = $this->findDuplicates($articleData, $custom_duplicate_name[$i], $custom_duplicate_value[$i], $this->options['duplicate_indicator'])) {
682
  $duplicate_id = array_shift($duplicates);
683
  if ($duplicate_id) {
684
  $post_to_update = get_post($post_to_update_id = $duplicate_id);
685
  }
686
  }
687
  }
 
 
 
 
 
 
 
 
 
 
 
 
688
 
689
  // Duplicate record is founded
690
  if ($post_to_update){
691
  // Do not update already existing records option selected
692
- if ("yes" == $this->options['is_keep_former_posts']) {
693
-
694
- $tmp_array = (!empty($this->current_post_ids)) ? json_decode($this->current_post_ids, true) : array();
695
- if ( ! in_array($post_to_update_id, $tmp_array) ){
696
- $tmp_array[] = $post_to_update_id;
697
- $this->set(array(
698
- 'current_post_ids' => json_encode($tmp_array)
699
- ))->save();
700
- }
701
 
702
  // Do not update product variations
703
- if ($post_type == "product" and class_exists('PMWI_Plugin')){
704
-
705
- $children = get_posts( array(
706
- 'post_parent' => $post_to_update_id,
707
- 'posts_per_page'=> -1,
708
- 'post_type' => 'product_variation',
709
- 'fields' => 'ids',
710
- 'post_status' => 'publish'
711
- ) );
712
-
713
- if ( $children ) {
714
- foreach ( $children as $child ) {
715
-
716
- $tmp_array = (!empty($this->current_post_ids)) ? json_decode($this->current_post_ids, true) : array();
717
- if ( ! in_array($child, $tmp_array)){
718
- $tmp_array[] = $child;
719
- $this->set(array(
720
- 'current_post_ids' => json_encode($tmp_array)
721
- ))->save();
722
- }
723
- }
724
- }
725
- }
726
- $this->set(array(
727
- 'skipped' => $this->skipped + 1
728
- ))->save();
729
- PMXI_Plugin::$session['pmxi_import']['skipped_records'] = $this->skipped;
730
  $logger and call_user_func($logger, sprintf(__('<b>SKIPPED</b>: Previously imported record found for `%s`', 'pmxi_plugin'), $articleData['post_title']));
731
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
732
- if ( ! $is_cron ){
733
- $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
734
- $progress_msg = '<p class="import_process_bar"> ' . __('Created', 'pmxi_plugin') . ' ' . $this->created . ' / ' . __('Updated','pmxi_plugin') . ' ' . $this->updated . ' ' . __('of', 'pmxi_plugin') . ' '. $this->count .' ' . __('records', 'pmxi_plugin') . '.</p><span class="import_percent">' . ceil(($records_count/$this->count) * 100) . '</span><span class="warnings_count">' . PMXI_Plugin::$session->data['pmxi_import']['warnings'] . '</span><span class="errors_count">' . PMXI_Plugin::$session->data['pmxi_import']['errors'] . '</span>';
735
- $logger and call_user_func($logger, $progress_msg);
736
- }
737
- PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
738
  pmxi_session_commit();
739
  continue;
740
  }
741
 
742
  $articleData['ID'] = $post_to_update_id;
743
- // preserve date of already existing article when duplicate is found
744
- if ($this->options['is_keep_categories']) { // preserve categories and tags of already existing article if corresponding setting is specified
745
- $cats_list = get_the_category($articleData['ID']);
746
- $existing_cats = array();
747
- if (is_wp_error($cats_list)) {
748
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current categories for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
749
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
750
- } else {
751
- $cats_new = array();
752
- foreach ($cats_list as $c) {
753
- $cats_new[] = $c->slug;
754
- }
755
- $existing_cats[$i] = $cats_new;
756
- }
757
-
758
- $tags_list = get_the_tags($articleData['ID']);
759
- if (is_wp_error($tags_list)) {
760
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current tags for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
761
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
762
- } else {
763
- $tags_new = array();
764
- if ($tags_list) foreach ($tags_list as $t) {
765
- $tags_new[] = $t->name;
766
- }
767
- $articleData['tags_input'] = implode(', ', $tags_new);
768
- }
769
- $existing_taxonomies = array();
770
- foreach (array_keys($taxonomies) as $tx_name) {
771
- $txes_list = get_the_terms($articleData['ID'], $tx_name);
772
- if (is_wp_error($txes_list)) {
773
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current taxonomies for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
774
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
775
  } else {
776
- $txes_new = array();
777
- if (!empty($txes_list)):
778
- foreach ($txes_list as $t) {
779
- $txes_new[] = $t->slug;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
780
  }
781
- endif;
782
- $existing_taxonomies[$tx_name][$i] = $txes_new;
783
  }
784
- }
785
- }
786
- else{
787
- foreach (array_keys($taxonomies) as $tx_name) wp_set_object_terms($articleData['ID'], NULL, $tx_name);
788
- }
789
- if ($this->options['is_keep_dates']) { // preserve date of already existing article when duplicate is found
790
- $articleData['post_date'] = $post_to_update->post_date;
791
- $articleData['post_date_gmt'] = $post_to_update->post_date_gmt;
792
- }
793
- if ($this->options['is_keep_status']) { // preserve status and trashed flag
794
- $articleData['post_status'] = $post_to_update->post_status;
795
- }
796
- if ($this->options['is_keep_content']){
797
- $articleData['post_content'] = $post_to_update->post_content;
798
- }
799
- if ($this->options['is_keep_title']){
800
- $articleData['post_title'] = $post_to_update->post_title;
801
- }
802
- if ($this->options['is_keep_excerpt']){
803
- $articleData['post_excerpt'] = $post_to_update->post_excerpt;
804
- }
805
- if ($this->options['is_keep_menu_order']){
806
- $articleData['menu_order'] = $post_to_update->menu_order;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
807
  }
808
- if ($this->options['is_keep_parent']){
809
- $articleData['post_parent'] = $post_to_update->post_parent;
810
  }
811
  // handle obsolete attachments (i.e. delete or keep) according to import settings
812
- if ( ! $this->options['is_keep_images'] and ! $this->options['is_keep_attachments_on_update'] and ! $this->options['no_create_featured_image']){
813
- wp_delete_attachments($articleData['ID'], $this->options['download_images']);
814
  }
815
-
816
  }
817
  elseif ( ! $postRecord->isEmpty() ){
818
 
819
  // existing post not found though it's track was found... clear the leftover, plugin will continue to treat record as new
820
  $postRecord->delete();
821
 
822
- }
823
 
824
  // no new records are created. it will only update posts it finds matching duplicates for
825
- if ($this->options['not_create_records'] and empty($articleData['ID'])){
826
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
827
- $this->set(array(
828
- 'skipped' => $this->skipped + 1
829
- ))->save();
830
- PMXI_Plugin::$session['pmxi_import']['skipped_records'] = $this->skipped;
831
- $logger and call_user_func($logger, sprintf(__('<b>SKIPPED</b>: by "Not add new records" option for `%s`', 'pmxi_plugin'), $articleData['post_title']));
832
- if ( ! $is_cron ){
833
- $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
834
- $progress_msg = '<p class="import_process_bar"> '. __('Created','pmxi_plugin') . ' ' . $this->created . ' / ' . __('Updated','pmxi_plugin') . ' ' . $this->updated . ' ' . __('of', 'pmxi_plugin') . ' '. $this->count .' ' . __('records', 'pmxi_plugin') . '.</p><span class="import_percent">' . ceil(($records_count/$this->count) * 100) . '</span><span class="warnings_count">' . PMXI_Plugin::$session->data['pmxi_import']['warnings'] . '</span><span class="errors_count">' . PMXI_Plugin::$session->data['pmxi_import']['errors'] . '</span>';
835
- $logger and call_user_func($logger, $progress_msg);
836
- }
837
- PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
838
  pmxi_session_commit();
839
  continue;
840
  }
@@ -904,7 +881,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
904
  $dest->insert();
905
  } else {
906
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to create cloaked link for %s', 'pmxi_plugin'), $url));
907
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
908
  $link = NULL;
909
  }
910
  }
@@ -916,21 +893,15 @@ class PMXI_Import_Record extends PMXI_Model_Record {
916
  }
917
  }
918
 
919
- // insert article being imported
920
- $pid = wp_insert_post($articleData, true);
921
 
922
  if (is_wp_error($pid)) {
923
  $logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
924
- PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
925
  } else {
926
-
927
- $tmp_array = (!empty($this->current_post_ids)) ? json_decode($this->current_post_ids, true) : array();
928
- if ( ! in_array($pid, $tmp_array)){
929
- $tmp_array[] = $pid;
930
- $this->set(array(
931
- 'current_post_ids' => json_encode($tmp_array)
932
- ))->save();
933
- }
934
 
935
  if ("manual" != $this->options['duplicate_matching'] or empty($articleData['ID'])){
936
  // associate post with import
@@ -938,7 +909,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
938
  'post_id' => $pid,
939
  'import_id' => $this->id,
940
  'unique_key' => $unique_keys[$i],
941
- 'product_key' => (class_exists('PMWI_Plugin')) ? $single_product_ID[$i] : null
942
  ))->insert();
943
  }
944
 
@@ -946,19 +917,71 @@ class PMXI_Import_Record extends PMXI_Model_Record {
946
  if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ){
947
  set_post_format($pid, $this->options['post_format'] );
948
  }
949
- // [/post format]
 
 
 
 
 
 
950
 
951
- // Woocommerce add-on
952
- if ( $post_type == "product" and class_exists('PMWI_Plugin')){
953
 
954
- $product->import($pid, $i, $this, $articleData, $xml, $is_cron);
 
 
 
 
 
 
955
 
956
- }
 
957
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
958
  if ('post' != $articleData['post_type'] and !empty($this->options['page_template'])) update_post_meta($pid, '_wp_page_template', $this->options['page_template']);
959
 
960
  // [featured image]
961
- if ( ! empty($uploads) and false === $uploads['error'] and !empty($featured_images[$i]) and (empty($articleData['ID']) or empty($this->options['is_keep_images']) or ! has_post_thumbnail($pid))) {
962
 
963
  require_once(ABSPATH . 'wp-admin/includes/image.php');
964
 
@@ -966,7 +989,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
966
  if ( ! is_array($image_meta_titles[$i]) ) $image_meta_titles[$i] = array($image_meta_titles[$i]);
967
  if ( ! is_array($image_meta_captions[$i]) ) $image_meta_captions[$i] = array($image_meta_captions[$i]);
968
  if ( ! is_array($image_meta_descriptions[$i]) ) $image_meta_descriptions[$i] = array($image_meta_descriptions[$i]);
969
- $post_thumbnail = false;
970
  $success_images = false;
971
  $gallery_attachment_ids = array();
972
 
@@ -986,8 +1009,10 @@ class PMXI_Import_Record extends PMXI_Model_Record {
986
  foreach ($imgs as $img_key => $img_url) { if (empty($img_url)) continue;
987
 
988
  $url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
989
- $img_ext = pmxi_get_remote_image_ext($url);
990
- $image_name = (($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? url_title($auto_rename_images[$i] . '_' . (($this->options['images_name'] != 'auto') ? array_shift(explode('?', basename($url))) : uniqid())) : (($this->options['images_name'] != 'auto') ? array_shift(explode('?', basename($url))) : uniqid())) . (("" != $img_ext and $this->options['images_name'] == 'auto') ? '.'.$img_ext : '');
 
 
991
 
992
  // if wizard store image data to custom field
993
  $create_image = false;
@@ -1002,7 +1027,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1002
  imagejpeg($img, $image_filepath);
1003
  if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1004
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
1005
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1006
  } else {
1007
  $create_image = true;
1008
  }
@@ -1014,7 +1039,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1014
  $image_filepath = $uploads['path'] . '/' . url_title($image_filename);
1015
 
1016
  // keep existing and add newest images
1017
- if ( $this->options['no_create_featured_image'] ){
1018
  $attachment_imgs = get_posts( array(
1019
  'post_type' => 'attachment',
1020
  'posts_per_page' => -1,
@@ -1024,11 +1049,16 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1024
  if ( $attachment_imgs ) {
1025
  foreach ( $attachment_imgs as $attachment_img ) {
1026
  if ($attachment_img->guid == $uploads['url'] . '/' . $image_name){
1027
- $download_image = false;
 
 
 
 
 
 
1028
  $logger and call_user_func($logger, sprintf(__('<b>Image SKIPPED</b>: The image %s is always exists for the %s', 'pmxi_plugin'), basename($attachment_img->guid), $articleData['post_title']));
1029
  }
1030
- }
1031
-
1032
  }
1033
  }
1034
 
@@ -1037,13 +1067,15 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1037
  // do not download images
1038
  if ( ! $this->options['download_images'] ){
1039
 
1040
- $image_filepath = $uploads['path'] . '/' . url_title( $image_filename = $image_name );
 
1041
 
1042
  if ( @file_exists($image_filepath) ){
1043
  $download_image = false;
1044
  if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1045
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
1046
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
 
1047
  } else {
1048
  $create_image = true;
1049
  }
@@ -1053,7 +1085,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1053
  if ($download_image){
1054
 
1055
  if ( ! get_file_curl($url, $image_filepath) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1056
- unlink($image_filepath); // delete file since failed upload may result in empty file created
1057
  } elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1058
  $create_image = true;
1059
  }
@@ -1064,19 +1096,19 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1064
 
1065
  if ( ! get_file_curl($url, $image_filepath) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1066
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
1067
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1068
- unlink($image_filepath); // delete file since failed upload may result in empty file created
1069
  } elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1070
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $url));
1071
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
 
1072
  } else {
1073
  $create_image = true;
1074
  }
1075
-
1076
  }
1077
  }
1078
- }
1079
- }
1080
 
1081
  if ($create_image){
1082
 
@@ -1093,11 +1125,11 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1093
  $attachment['post_content'] = $image_meta['caption'];
1094
  }
1095
 
1096
- $attid = wp_insert_attachment($attachment, $image_filepath, $pid);
1097
 
1098
  if (is_wp_error($attid)) {
1099
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $attid->get_error_message());
1100
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1101
  } else {
1102
  // you must first include the image.php file
1103
  // for the function wp_generate_attachment_metadata() to work
@@ -1111,39 +1143,32 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1111
  if ( ! empty($img_descriptions[$img_key]) ) $update_attachment_meta['post_content'] = $img_descriptions[$img_key];
1112
  if ( ! empty($img_alts[$img_key]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$img_key]);
1113
 
1114
- if ( ! empty($update_attachment_meta)){
1115
- $update_attachment_meta['ID'] = $attid;
1116
- wp_update_post($update_attachment_meta);
1117
- }
1118
  }
1119
 
1120
  do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
1121
 
1122
  $success_images = true;
1123
- if ( ! $post_thumbnail ) {
1124
- if ( ! $this->options['no_create_featured_image'] or ! has_post_thumbnail($pid)){
1125
- set_post_thumbnail($pid, $attid);
1126
- $post_thumbnail = true;
1127
- }
1128
- else $gallery_attachment_ids[] = $attid;
1129
- }
1130
- else $gallery_attachment_ids[] = $attid;
1131
  }
1132
  }
1133
  }
1134
  }
1135
- }
1136
- //if (!$is_cron) update_post_meta($pid, '_pmxi_images', $_pmxi_images);
1137
  // Set product gallery images
1138
  if ( $post_type == "product" and !empty($gallery_attachment_ids) )
1139
  update_post_meta($pid, '_product_image_gallery', implode(',', $gallery_attachment_ids));
1140
  // Create entry as Draft if no images are downloaded successfully
1141
- if ( ! $success_images and "yes" == $this->options['create_draft'] ) wp_update_post(array('ID' => $pid, 'post_status' => 'draft'));
1142
  }
1143
  // [/featured image]
1144
 
1145
  // [attachments]
1146
- if ( ! empty($uploads) and false === $uploads['error'] and !empty($attachments[$i])) {
1147
 
1148
  // you must first include the image.php file
1149
  // for the function wp_generate_attachment_metadata() to work
@@ -1163,11 +1188,11 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1163
 
1164
  if ( ! get_file_curl(trim($atch_url), $attachment_filepath) and ! @file_put_contents($attachment_filepath, @file_get_contents(trim($atch_url)))) {
1165
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Attachment file %s cannot be saved locally as %s', 'pmxi_plugin'), trim($atch_url), $attachment_filepath));
1166
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1167
  unlink($attachment_filepath); // delete file since failed upload may result in empty file created
1168
  } elseif( ! $wp_filetype = wp_check_filetype(basename($attachment_filename), null )) {
1169
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Can\'t detect attachment file type %s', 'pmxi_plugin'), trim($atch_url)));
1170
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1171
  } else {
1172
 
1173
  $attachment_data = array(
@@ -1177,14 +1202,14 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1177
  'post_content' => '',
1178
  'post_status' => 'inherit'
1179
  );
1180
- $attach_id = wp_insert_attachment( $attachment_data, $attachment_filepath, $pid );
1181
 
1182
  if (is_wp_error($attach_id)) {
1183
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
1184
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1185
- } else {
1186
- do_action( 'pmxi_attachment_uploaded', $pid, $attid, $image_filepath);
1187
  wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attachment_filepath));
 
1188
  }
1189
  }
1190
  }
@@ -1194,24 +1219,38 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1194
  // [/attachments]
1195
 
1196
  // [custom taxonomies]
1197
- if (!empty($taxonomies)){
1198
- foreach ($taxonomies as $tx_name => $txes) {
1199
-
1200
- if ( empty($articleData['ID']) or !$this->options['is_keep_categories'] or ( $this->options['is_keep_categories'] and $this->options['is_add_newest_categories'] ) ){
 
 
 
 
 
 
 
 
 
 
 
1201
 
1202
  $assign_taxes = array();
1203
 
1204
- if ($this->options['is_add_newest_categories'] and !empty($existing_taxonomies[$tx_name][$i])){
1205
  $assign_taxes = $existing_taxonomies[$tx_name][$i];
1206
  unset($existing_taxonomies[$tx_name][$i]);
1207
  }
 
 
 
1208
 
1209
  // create term if not exists
1210
  if (!empty($txes[$i])):
1211
  foreach ($txes[$i] as $key => $single_tax) {
1212
- if (is_array($single_tax)){
1213
 
1214
- $parent_id = (!empty($single_tax['parent'])) ? $this->recursion_taxes($single_tax['parent'], $tx_name, $txes[$i], $key) : '';
1215
 
1216
  $term = is_exists_term($tx_name, $single_tax['name'], (int)$parent_id);
1217
 
@@ -1226,7 +1265,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1226
 
1227
  if ( is_wp_error($term) ){
1228
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: `%s`', 'pmxi_plugin'), $term->get_error_message()));
1229
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1230
  }
1231
  elseif (!empty($term)) {
1232
  $cat_id = $term['term_id'];
@@ -1241,21 +1280,24 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1241
  endif;
1242
  if (!empty($assign_taxes)){
1243
  // associate taxes with post
1244
- $term_ids = wp_set_object_terms($pid, $assign_taxes, $tx_name);
1245
  if (is_wp_error($term_ids)) {
1246
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$term_ids->get_error_message());
1247
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1248
  }
1249
  }
1250
  }
1251
  }
1252
- if (!empty($existing_taxonomies) and $this->options['is_keep_categories'] and $this->options['is_add_newest_categories']) {
1253
  foreach ($existing_taxonomies as $tx_name => $txes) {
 
 
 
1254
  if (!empty($txes[$i])){
1255
  $term_ids = wp_set_object_terms($pid, $txes[$i], $tx_name);
1256
  if (is_wp_error($term_ids)) {
1257
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$term_ids->get_error_message());
1258
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1259
  }
1260
  }
1261
  }
@@ -1266,185 +1308,214 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1266
  // [categories]
1267
  if (!empty($cats[$i])) {
1268
 
1269
- if ( empty($articleData['ID']) or !$this->options['is_keep_categories'] or ( $this->options['is_keep_categories'] and $this->options['is_add_newest_categories'] ) ){
1270
 
1271
- wp_set_object_terms( $pid, NULL, 'category' );
1272
 
1273
- $assign_cats = array();
1274
 
1275
- if ($this->options['is_add_newest_categories'] and !empty($existing_cats[$i])){
1276
- $assign_cats = $existing_cats[$i];
1277
- unset($existing_cats[$i]);
 
 
1278
  }
1279
 
1280
- // create categories if it's doesn't exists
1281
- foreach ($cats[$i] as $key => $single_cat) {
1282
 
1283
- if (is_array($single_cat)){
 
 
 
 
 
 
1284
 
1285
- $parent_id = (!empty($single_cat['parent'])) ? $this->recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
 
1286
 
1287
- //$term = term_exists( trim($single_cat['name']), 'category', $parent_id );
1288
- $term = is_exists_term('category', $single_cat['name'], (int)$parent_id);
1289
-
1290
- if ( empty($term) and !is_wp_error($term) ){
1291
- $term_attr = array('parent'=> (!empty($parent_id)) ? $parent_id : 0);
1292
- $term = wp_insert_term(
1293
- $single_cat['name'], // the term
1294
- 'category', // the taxonomy
1295
- $term_attr
1296
- );
1297
- }
1298
-
1299
- if ( is_wp_error($term) ){
1300
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: `%s`', 'pmxi_plugin'), $term->get_error_message()));
1301
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1302
- }
1303
- elseif ( ! empty($term) ) {
1304
- $cat_id = $term['term_id'];
1305
- if ($cat_id and $single_cat['assign'])
1306
- {
1307
- $term = get_term_by('id', $cat_id, 'category');
1308
- if ( ! in_array($term->slug, $assign_cats)) $assign_cats[] = $term->slug;
 
 
 
 
1309
  }
1310
- }
1311
- }
1312
- }
1313
 
1314
- // associate categories with post
1315
- $cats_ids = wp_set_object_terms($pid, $assign_cats, 'category');
1316
- if (is_wp_error($cats_ids)) {
1317
- $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$cats_ids->get_error_message());
1318
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1319
- }
 
1320
  }
1321
  }
1322
 
1323
- if (!empty($existing_cats[$i]) and $this->options['is_keep_categories']) {
1324
- $cats_ids = wp_set_object_terms($pid, $existing_cats[$i], 'category');
1325
-
1326
  if (is_wp_error($cats_ids)) {
1327
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$cats_ids->get_error_message());
1328
- PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1329
  }
1330
  }
1331
  // [/categories]
1332
 
1333
- if (empty($articleData['ID'])) {
1334
- PMXI_Plugin::$session['pmxi_import']['created_records'] = $this->created + 1;
1335
  $logger and call_user_func($logger, sprintf(__('`%s` post created successfully', 'pmxi_plugin'), $articleData['post_title']));
1336
- } else {
1337
- PMXI_Plugin::$session['pmxi_import']['updated_records'] = $this->updated + 1;
1338
  $logger and call_user_func($logger, sprintf(__('`%s` post updated successfully', 'pmxi_plugin'), $articleData['post_title']));
1339
- }
1340
-
1341
  do_action( 'pmxi_saved_post', $pid); // hook that was triggered immediately after post saved
1342
 
1343
- if ($this->large_import == 'Yes' and $chunk){
1344
- $this->set(array(
1345
- 'imported' => $this->imported + 1,
1346
- 'created' => (empty($articleData['ID'])) ? $this->created + 1 : $this->created,
1347
- 'updated' => (empty($articleData['ID'])) ? $this->updated : $this->updated + 1
1348
- ))->save();
1349
- }
1350
-
1351
- $records_count = 0;
1352
 
1353
- // Time Elapsed
1354
- if ( ! $is_cron){
1355
-
1356
- $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
1357
-
1358
- $progress_msg = '<p class="import_process_bar"> '.__('Created','pmxi_plugin'). ' ' . $this->created . ' / '.__('Updated','pmxi_plugin') . ' ' . $this->updated . ' ' . __('of','pmxi_plugin') . ' '. $this->count .' ' . __('records', 'pmxi_plugin') . '.</p><span class="import_percent">' . ceil(($records_count/$this->count) * 100) . '</span><span class="warnings_count">' . PMXI_Plugin::$session->data['pmxi_import']['warnings'] . '</span><span class="errors_count">' . PMXI_Plugin::$session->data['pmxi_import']['errors'] . '</span>';
1359
- $logger and call_user_func($logger, $progress_msg);
1360
  }
1361
-
1362
- }
1363
 
1364
- wp_cache_flush();
 
 
1365
  }
1366
 
1367
- if ($this->large_import == 'Yes' and $chunk) PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
 
 
 
 
 
 
 
 
 
 
 
1368
 
1369
- pmxi_session_commit();
1370
 
1371
- $is_import_complete = ($records_count == $this->count);
1372
 
1373
- if ( ! $is_cron and $is_import_complete and ! empty($this->options['is_delete_missing'])) { // delete posts which are not in current import set
1374
 
1375
- $logger and call_user_func($logger, 'Removing previously imported posts which are no longer actual...');
1376
- $postList = new PMXI_Post_List();
1377
- $current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1378
 
1379
- $missing_ids = array();
1380
- foreach ($postList->getBy(array('import_id' => $this->id, 'post_id NOT IN' => $current_post_ids)) as $missingPost) {
1381
- empty($this->options['is_keep_attachments']) and wp_delete_attachments($missingPost['post_id']);
1382
- $missing_ids[] = $missingPost['post_id'];
1383
-
1384
- $sql = "delete a
1385
- FROM ".PMXI_Plugin::getInstance()->getTablePrefix()."posts a
1386
- WHERE a.id=%d";
1387
-
1388
- $this->wpdb->query(
1389
- $this->wpdb->prepare($sql, $missingPost['id'])
1390
- );
1391
- }
1392
 
1393
- if (!empty($missing_ids)){
 
 
1394
 
1395
- foreach ($missing_ids as $id) wp_delete_object_term_relationships($id, get_object_taxonomies('' != $this->options['custom_type'] ? $this->options['custom_type'] : 'post'));
 
 
 
1396
 
1397
- $sql = "delete a,b,c
1398
- FROM ".$this->wpdb->posts." a
1399
- LEFT JOIN ".$this->wpdb->term_relationships." b ON ( a.ID = b.object_id )
1400
- LEFT JOIN ".$this->wpdb->postmeta." c ON ( a.ID = c.post_id )
1401
- WHERE a.ID IN (".implode(',', $missing_ids).");";
1402
 
1403
- $this->wpdb->query(
1404
- $this->wpdb->prepare($sql, '')
1405
- );
1406
- }
1407
 
1408
- }
 
1409
 
1410
- // Set out of stock status for missing records [Woocommerce add-on option]
1411
- if ( ! $is_cron and $is_import_complete and empty($this->options['is_delete_missing']) and $post_type == "product" and class_exists('PMWI_Plugin') and !empty($this->options['missing_records_stock_status'])) {
 
 
1412
 
1413
- $logger and call_user_func($logger, 'Update stock status previously imported posts which are no longer actual...');
1414
- $postList = new PMXI_Post_List();
1415
- $current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1416
- foreach ($postList->getBy(array('import_id' => $this->id, 'post_id NOT IN' => $current_post_ids)) as $missingPost) {
1417
- update_post_meta( $missingPost['post_id'], '_stock_status', 'outofstock' );
1418
- update_post_meta( $missingPost['post_id'], '_stock', 0 );
1419
- }
1420
 
1421
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1422
 
1423
- if ( ! $is_cron and $is_import_complete and empty($this->options['is_delete_missing']) and $this->options['is_update_missing_cf'] ) {
1424
-
1425
- $logger and call_user_func($logger, 'Update custom fields previously imported posts which are no longer actual...');
1426
- $postList = new PMXI_Post_List();
1427
- $current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1428
- foreach ($postList->getBy(array('import_id' => $this->id, 'post_id NOT IN' => $current_post_ids)) as $missingPost) {
1429
- update_post_meta( $missingPost['post_id'], $this->options['update_missing_cf_name'], $this->options['update_missing_cf_value'] );
1430
  }
1431
 
1432
- }
 
 
 
 
 
 
 
 
 
 
 
 
1433
 
1434
  } catch (XmlImportException $e) {
1435
  $logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $e->getMessage());
1436
  PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
1437
- }
1438
-
1439
- $this->set('registered_on', date('Y-m-d H:i:s'))->save(); // specify execution is successful
1440
 
1441
- !$is_cron and $is_import_complete and $logger and call_user_func($logger, __('Cleaning temporary data...', 'pmxi_plugin'));
1442
  foreach ($tmp_files as $file) { // remove all temporary files created
1443
  unlink($file);
1444
  }
1445
 
1446
  if (($is_cron or $is_import_complete) and $this->options['is_delete_source']) {
1447
- $logger and call_user_func($logger, __('Deleting source XML file...', 'pmxi_plugin'));
 
 
 
 
 
 
1448
  if ($this->type != "ftp"){
1449
  if ( ! @unlink($this->path)) {
1450
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'pmxi_plugin'), $this->path));
@@ -1461,130 +1532,30 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1461
  }
1462
  }
1463
  }
 
1464
  if ( ! $is_cron and $is_import_complete ){
 
1465
  $this->set(array(
1466
- 'processing' => 0,
1467
  'triggered' => 0,
1468
  'queue_chunk_number' => 0,
1469
- 'current_post_ids' => ''
1470
- ))->save();
 
 
1471
  $logger and call_user_func($logger, 'Done');
1472
  }
1473
 
1474
  remove_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // return any filtering rules back if they has been disabled for import procedure
1475
 
1476
  return $this;
1477
- }
1478
-
1479
- public function recursion_taxes($parent, $tx_name, $txes, $key){
1480
-
1481
- if (is_array($parent)){
1482
- $parent['name'] = sanitize_text_field($parent['name']);
1483
- if (empty($parent['parent'])){
1484
- //$term = term_exists( htmlspecialchars($parent['name']), $tx_name);
1485
-
1486
- $term = is_exists_term($tx_name, $parent['name']);
1487
-
1488
- if ( empty($term) and !is_wp_error($term) ){
1489
- $term = wp_insert_term(
1490
- $parent['name'], // the term
1491
- $tx_name // the taxonomy
1492
- );
1493
- }
1494
- return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
1495
- }
1496
- else{
1497
- $parent_id = $this->recursion_taxes($parent['parent'], $tx_name, $txes, $key);
1498
- //$term = term_exists( htmlspecialchars($parent['name']), $tx_name, $parent_id);
1499
-
1500
- $term = is_exists_term($tx_name, $parent['name'], (int)$parent_id);
1501
-
1502
- if ( empty($term) and !is_wp_error($term) ){
1503
- $term = wp_insert_term(
1504
- $parent, // the term
1505
- $tx_name, // the taxonomy
1506
- array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
1507
- );
1508
- }
1509
- return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
1510
- }
1511
- }
1512
- else{
1513
-
1514
- if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
1515
- $parent_id = $this->recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
1516
-
1517
- //$term = term_exists( htmlspecialchars($parent), $tx_name, $parent_id);
1518
- $term = is_exists_term($tx_name, $parent, (int)$parent_id);
1519
-
1520
- if ( empty($term) and !is_wp_error($term) ){
1521
- $term = wp_insert_term(
1522
- $parent, // the term
1523
- $tx_name, // the taxonomy
1524
- array('parent'=> (!empty($parent_id)) ? $parent_id : 0)
1525
- );
1526
- }
1527
- return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
1528
- }
1529
- else{
1530
- //$term = term_exists( htmlspecialchars($parent), $tx_name);
1531
- $term = is_exists_term($tx_name, $parent);
1532
- if ( empty($term) and !is_wp_error($term) ){
1533
- $term = wp_insert_term(
1534
- $parent, // the term
1535
- $tx_name // the taxonomy
1536
- );
1537
- }
1538
- return ( ! is_wp_error($term)) ? $term['term_id'] : 0;
1539
- }
1540
- }
1541
  }
1542
-
1543
  public function _filter_has_cap_unfiltered_html($caps)
1544
  {
1545
  $caps['unfiltered_html'] = true;
1546
  return $caps;
1547
- }
1548
-
1549
- /**
1550
- * Find duplicates according to settings
1551
- */
1552
- public function findDuplicates($articleData, $custom_duplicate_name = '', $custom_duplicate_value = '', $duplicate_indicator = 'title')
1553
- {
1554
- if ('custom field' == $duplicate_indicator){
1555
- $duplicate_ids = array();
1556
- $args = array(
1557
- 'post_type' => $articleData['post_type'],
1558
- 'meta_query' => array(
1559
- array(
1560
- 'key' => $custom_duplicate_name,
1561
- 'value' => $custom_duplicate_value,
1562
- )
1563
- )
1564
- );
1565
- $query = new WP_Query( $args );
1566
-
1567
- if ( $query->have_posts() ) $duplicate_ids[] = $query->post->ID;
1568
-
1569
- wp_reset_postdata();
1570
-
1571
- return $duplicate_ids;
1572
- }
1573
- else{
1574
- $field = 'post_' . $duplicate_indicator; // post_title or post_content
1575
- return $this->wpdb->get_col($this->wpdb->prepare("
1576
- SELECT ID FROM " . $this->wpdb->posts . "
1577
- WHERE
1578
- post_type = %s
1579
- AND ID != %s
1580
- AND REPLACE(REPLACE(REPLACE($field, ' ', ''), '\\t', ''), '\\n', '') = %s
1581
- ",
1582
- $articleData['post_type'],
1583
- isset($articleData['ID']) ? $articleData['ID'] : 0,
1584
- preg_replace('%[ \\t\\n]%', '', $articleData[$field])
1585
- ));
1586
- }
1587
- }
1588
 
1589
  /**
1590
  * Clear associations with posts
@@ -1597,7 +1568,10 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1597
  if ( ! $keepPosts) {
1598
  $ids = array();
1599
  foreach ($post->getBy('import_id', $this->id)->convertRecords() as $p) {
1600
- empty($this->options['is_keep_attachments']) and wp_delete_attachments($p->post_id);
 
 
 
1601
  $ids[] = $p->post_id;
1602
  }
1603
  if (!empty($ids)){
25
 
26
  PMXI_Import_Record::preprocessXml($xml);
27
 
28
+ if ( function_exists('simplexml_load_string')){
29
+ libxml_use_internal_errors(true);
30
+ libxml_clear_errors();
31
+ $_x = @simplexml_load_string($xml);
32
+ $xml_errors = libxml_get_errors();
33
+ libxml_clear_errors();
34
+ if ($xml_errors) {
35
+ $error_msg = '<strong>' . __('Invalid XML', 'pmxi_plugin') . '</strong><ul>';
36
+ foreach($xml_errors as $error) {
37
+ $error_msg .= '<li>';
38
+ $error_msg .= __('Line', 'pmxi_plugin') . ' ' . $error->line . ', ';
39
+ $error_msg .= __('Column', 'pmxi_plugin') . ' ' . $error->column . ', ';
40
+ $error_msg .= __('Code', 'pmxi_plugin') . ' ' . $error->code . ': ';
41
+ $error_msg .= '<em>' . trim(esc_html($error->message)) . '</em>';
42
+ $error_msg .= '</li>';
43
+ }
44
+ $error_msg .= '</ul>';
45
+ $errors and $errors->add('form-validation', $error_msg);
46
+ } else {
47
+ return true;
48
  }
49
+ }
50
+ else{
51
+ $errors and $errors->add('form-validation', __('simplexml module is disabled on your server', 'pmxi_plugin'));
 
52
  }
53
  }
54
  return false;
61
  public function __construct($data = array()) {
62
  parent::__construct($data);
63
  $this->setTable(PMXI_Plugin::getInstance()->getTablePrefix() . 'imports');
64
+ }
65
 
66
  /**
67
  * Perform import operation
70
  * @return PMXI_Import_Record
71
  * @chainable
72
  */
73
+ public function process($xml, $logger = NULL, $chunk = false, $is_cron = false, $xpath_prefix = '') {
74
  add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // do not perform special filtering for imported content
75
 
76
+ $cxpath = $xpath_prefix . $this->xpath;
77
+
78
  $this->options += PMXI_Plugin::get_default_import_options(); // make sure all options are defined
79
 
80
  $avoid_pingbacks = PMXI_Plugin::getInstance()->getOption('pingbacks');
81
  $legacy_handling = PMXI_Plugin::getInstance()->getOption('legacy_special_character_handling');
82
 
83
+ if ( $avoid_pingbacks and ! defined( 'WP_IMPORTING' ) ) define( 'WP_IMPORTING', true );
 
 
 
84
 
85
  $postRecord = new PMXI_Post_Record();
86
 
87
  $tmp_files = array();
88
  // compose records to import
89
  $records = array();
90
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  try {
92
 
93
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing titles...', 'pmxi_plugin'));
94
+ $titles = XmlImportParser::factory($xml, $cxpath, $this->template['title'], $file)->parse($records); $tmp_files[] = $file;
 
 
95
 
96
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing excerpts...', 'pmxi_plugin'));
97
  $post_excerpt = array();
98
  if (!empty($this->options['post_excerpt'])){
99
+ $post_excerpt = XmlImportParser::factory($xml, $cxpath, $this->options['post_excerpt'], $file)->parse($records); $tmp_files[] = $file;
100
  }
101
  else{
102
  count($titles) and $post_excerpt = array_fill(0, count($titles), '');
103
  }
104
 
105
  if ( "xpath" == $this->options['status'] ){
106
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing statuses...', 'pmxi_plugin'));
107
  $post_status = array();
108
  if (!empty($this->options['status_xpath'])){
109
+ $post_status = XmlImportParser::factory($xml, $cxpath, $this->options['status_xpath'], $file)->parse($records); $tmp_files[] = $file;
110
  }
111
  else{
112
  count($titles) and $post_status = array_fill(0, count($titles), '');
113
  }
114
  }
115
 
116
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing authors...', 'pmxi_plugin'));
117
  $post_author = array();
118
  $current_user = wp_get_current_user();
119
 
120
  if (!empty($this->options['author'])){
121
+ $post_author = XmlImportParser::factory($xml, $cxpath, $this->options['author'], $file)->parse($records); $tmp_files[] = $file;
122
  foreach ($post_author as $key => $author) {
123
  $user = get_user_by('login', $author) or $user = get_user_by('slug', $author) or $user = get_user_by('email', $author) or ctype_digit($author) and $user = get_user_by('id', $author);
124
  $post_author[$key] = (!empty($user)) ? $user->ID : $current_user->ID;
128
  count($titles) and $post_author = array_fill(0, count($titles), $current_user->ID);
129
  }
130
 
131
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing slugs...', 'pmxi_plugin'));
132
  $post_slug = array();
133
  if (!empty($this->options['post_slug'])){
134
+ $post_slug = XmlImportParser::factory($xml, $cxpath, $this->options['post_slug'], $file)->parse($records); $tmp_files[] = $file;
135
  }
136
  else{
137
  count($titles) and $post_slug = array_fill(0, count($titles), '');
138
  }
139
 
140
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
141
  $contents = XmlImportParser::factory(
142
  (intval($this->template['is_keep_linebreaks']) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
143
+ $cxpath,
144
  $this->template['content'],
145
  $file)->parse($records
146
  ); $tmp_files[] = $file;
147
 
148
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing dates...', 'pmxi_plugin'));
149
  if ('specific' == $this->options['date_type']) {
150
+ $dates = XmlImportParser::factory($xml, $cxpath, $this->options['date'], $file)->parse($records); $tmp_files[] = $file;
151
  $warned = array(); // used to prevent the same notice displaying several times
152
  foreach ($dates as $i => $d) {
153
+ if ($d == 'now') $d = current_time('mysql'); // Replace 'now' with the WordPress local time to account for timezone offsets (WordPress references its local time during publishing rather than the server’s time so it should use that)
154
  $time = strtotime($d);
155
  if (FALSE === $time) {
156
  in_array($d, $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $d));
157
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
158
  $time = time();
159
  }
160
  $dates[$i] = date('Y-m-d H:i:s', $time);
161
  }
162
  } else {
163
+ $dates_start = XmlImportParser::factory($xml, $cxpath, $this->options['date_start'], $file)->parse($records); $tmp_files[] = $file;
164
+ $dates_end = XmlImportParser::factory($xml, $cxpath, $this->options['date_end'], $file)->parse($records); $tmp_files[] = $file;
165
  $warned = array(); // used to prevent the same notice displaying several times
166
  foreach ($dates_start as $i => $d) {
167
  $time_start = strtotime($dates_start[$i]);
168
  if (FALSE === $time_start) {
169
  in_array($dates_start[$i], $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $dates_start[$i]));
170
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
171
  $time_start = time();
172
  }
173
  $time_end = strtotime($dates_end[$i]);
174
  if (FALSE === $time_end) {
175
  in_array($dates_end[$i], $warned) or $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: unrecognized date format `%s`, assigning current date', 'pmxi_plugin'), $warned[] = $dates_end[$i]));
176
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
177
  $time_end = time();
178
  }
179
  $dates[$i] = date('Y-m-d H:i:s', mt_rand($time_start, $time_end));
182
 
183
  $tags = array();
184
  if ($this->options['tags']) {
185
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing tags...', 'pmxi_plugin'));
186
+ $tags_raw = XmlImportParser::factory($xml, $cxpath, $this->options['tags'], $file)->parse($records); $tmp_files[] = $file;
187
  foreach ($tags_raw as $i => $t_raw) {
188
  $tags[$i] = '';
189
  if ('' != $t_raw) $tags[$i] = implode(', ', str_getcsv($t_raw, $this->options['tags_delim']));
203
 
204
  if ((!empty($categories_hierarchy) and is_array($categories_hierarchy))){
205
 
206
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing categories...', 'pmxi_plugin'));
207
  $categories = array();
208
 
209
  foreach ($categories_hierarchy as $k => $category): if ("" == $category->xpath) continue;
210
+ $cats_raw = XmlImportParser::factory($xml, $cxpath, str_replace('\'','"',$category->xpath), $file)->parse($records); $tmp_files[] = $file;
211
  $warned = array(); // used to prevent the same notice displaying several times
212
  foreach ($cats_raw as $i => $c_raw) {
213
  if (empty($categories_hierarchy[$k]->cat_ids[$i])) $categories_hierarchy[$k]->cat_ids[$i] = array();
283
  $tx = get_taxonomy($tx_name);
284
  $taxonomies[$tx_name] = array();
285
  if (!empty($tx->object_type) and in_array($taxonomies_object_type, $tx->object_type)) {
286
+ $chunk == 1 and $logger and call_user_func($logger, sprintf(__('Composing terms for `%s` taxonomy...', 'pmxi_plugin'), $tx->labels->name));
287
  $txes = array();
288
 
289
  $taxonomies_hierarchy = json_decode($tx_template);
290
  foreach ($taxonomies_hierarchy as $k => $taxonomy){ if ("" == $taxonomy->xpath) continue;
291
+ $txes_raw = XmlImportParser::factory($xml, $cxpath, str_replace('\'','"',$taxonomy->xpath), $file)->parse($records); $tmp_files[] = $file;
292
  $warned = array();
293
  foreach ($txes_raw as $i => $tx_raw) {
294
  if (empty($taxonomies_hierarchy[$k]->txn_names[$i])) $taxonomies_hierarchy[$k]->txn_names[$i] = array();
345
  }
346
  }
347
  }; endif;
348
+ // [/custom taxonomies]
349
 
350
  // serialized featured images
351
  if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
353
  $logger and call_user_func($logger, __('<b>WARNING</b>: No featured images will be created', 'pmxi_plugin'));
354
  PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
355
  } else {
356
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing URLs for featured images...', 'pmxi_plugin'));
357
  $featured_images = array();
358
  if ($this->options['featured_image']) {
359
  // Detect if images is separated by comma
366
  {
367
  foreach($imgs as $img)
368
  {
369
+ $posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
370
  foreach($posts_images as $i => $val) $featured_images[$i][] = $val;
371
  }
372
  }
373
  else
374
  {
375
+ $featured_images = XmlImportParser::factory($xml, $cxpath, $this->options['featured_image'], $file)->parse($records); $tmp_files[] = $file;
376
  }
377
  }
378
 
386
  $uploads = wp_upload_dir();
387
 
388
  // serialized images meta titles
389
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (titles)...', 'pmxi_plugin'));
390
  $image_meta_titles = array();
391
 
392
  if ($this->options['image_meta_title']) {
401
  {
402
  foreach($imgs as $img)
403
  {
404
+ $posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
405
  foreach($posts_images as $i => $val) $image_meta_titles[$i][] = $val;
406
  }
407
  }
408
  else
409
  {
410
+ $image_meta_titles = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_title'], $file)->parse($records); $tmp_files[] = $file;
411
  }
412
  }
413
 
416
  }
417
 
418
  // serialized images meta captions
419
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (captions)...', 'pmxi_plugin'));
420
  $image_meta_captions = array();
421
  if ($this->options['image_meta_caption']) {
422
  // Detect if images is separated by comma
429
  {
430
  foreach($imgs as $img)
431
  {
432
+ $posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
433
  foreach($posts_images as $i => $val) $image_meta_captions[$i][] = $val;
434
  }
435
  }
436
  else
437
  {
438
+ $image_meta_captions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_caption'], $file)->parse($records); $tmp_files[] = $file;
439
  }
440
  }
441
 
443
  count($titles) and $image_meta_captions = array_fill(0, count($titles), '');
444
  }
445
  // serialized images meta alt text
446
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (alt text)...', 'pmxi_plugin'));
447
  $image_meta_alts = array();
448
  if ($this->options['image_meta_alt']) {
449
  // Detect if images is separated by comma
456
  {
457
  foreach($imgs as $img)
458
  {
459
+ $posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
460
  foreach($posts_images as $i => $val) $image_meta_alts[$i][] = $val;
461
  }
462
  }
463
  else
464
  {
465
+ $image_meta_alts = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_alt'], $file)->parse($records); $tmp_files[] = $file;
466
  }
467
  }
468
 
470
  count($titles) and $image_meta_alts = array_fill(0, count($titles), '');
471
  }
472
  // serialized images meta description
473
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing image meta data (description)...', 'pmxi_plugin'));
474
  $image_meta_descriptions = array();
475
  if ($this->options['image_meta_description']) {
476
  // Detect if images is separated by comma
483
  {
484
  foreach($imgs as $img)
485
  {
486
+ $posts_images = XmlImportParser::factory($xml, $cxpath, trim($img), $file)->parse($records); $tmp_files[] = $file;
487
  foreach($posts_images as $i => $val) $image_meta_descriptions[$i][] = $val;
488
  }
489
  }
490
  else
491
  {
492
+ $image_meta_descriptions = XmlImportParser::factory($xml, $cxpath, $this->options['image_meta_description'], $file)->parse($records); $tmp_files[] = $file;
493
  }
494
  }
495
 
499
  }
500
 
501
  // Composing images suffix
502
+ $chunk == 1 and $this->options['auto_rename_images'] and $logger and call_user_func($logger, __('Composing images suffix...', 'pmxi_plugin'));
503
  $auto_rename_images = array();
504
  if ( $this->options['auto_rename_images'] and ! empty($this->options['auto_rename_images_suffix'])){
505
+ $auto_rename_images = XmlImportParser::factory($xml, $cxpath, $this->options['auto_rename_images_suffix'], $file)->parse($records); $tmp_files[] = $file;
506
  }
507
  else{
508
  count($titles) and $auto_rename_images = array_fill(0, count($titles), '');
512
  if ( ! (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
513
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $uploads['error']);
514
  $logger and call_user_func($logger, __('<b>WARNING</b>: No attachments will be created', 'pmxi_plugin'));
515
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session['pmxi_import']['warnings'];
516
  } else {
517
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing URLs for attachments files...', 'pmxi_plugin'));
518
  $attachments = array();
519
 
520
  if ($this->options['attachments']) {
528
  {
529
  foreach($atchs as $atch)
530
  {
531
+ $posts_attachments = XmlImportParser::factory($xml, $cxpath, trim($atch), $file)->parse($records); $tmp_files[] = $file;
532
  foreach($posts_attachments as $i => $val) $attachments[$i][] = $val;
533
  }
534
  }
535
  else
536
  {
537
+ $attachments = XmlImportParser::factory($xml, $cxpath, $this->options['attachments'], $file)->parse($records); $tmp_files[] = $file;
538
  }
539
  }
540
 
543
  }
544
  }
545
 
546
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing unique keys...', 'pmxi_plugin'));
547
+ $unique_keys = XmlImportParser::factory($xml, $cxpath, $this->options['unique_key'], $file)->parse($records); $tmp_files[] = $file;
548
 
549
+ $chunk == 1 and $logger and call_user_func($logger, __('Processing posts...', 'pmxi_plugin'));
550
 
551
  if ('post' == $this->options['type'] and '' != $this->options['custom_type']) {
552
+ $post_type = ($this->options['custom_type'] == 'product' and class_exists('PMWI_Plugin')) ? $this->options['custom_type'] : 'post';
553
  } else {
554
  $post_type = $this->options['type'];
555
  }
556
+
557
+ $addons = array();
558
+ $addons_data = array();
559
+
560
+ // data parsing for WP All Import add-ons
561
+ foreach (PMXI_Admin_Addons::get_active_addons() as $class) {
562
+ // prepare data to parsing
563
+ $parsingData = array(
564
+ 'import' => $this,
565
+ 'count' => count($titles),
566
+ 'xml' => $xml,
567
+ 'logger' => $logger,
568
+ 'chunk' => $chunk,
569
+ 'xpath_prefix' => $xpath_prefix
570
+ );
571
+ $model_class = str_replace("_Plugin", "_Import_Record", $class);
572
+ $addons[$class] = new $model_class();
573
+ $addons_data[$class] = $addons[$class]->parse($parsingData);
574
+ }
575
 
576
+ // save current import state to variables before import
577
+ $current_post_ids = (!empty($this->current_post_ids)) ? json_decode($this->current_post_ids, true) : array();
578
+ $created = $this->created;
579
+ $updated = $this->updated;
580
+ $skipped = $this->skipped;
581
+
582
+ $specified_records = array();
583
 
584
+ if ($this->options['is_import_specified']) {
585
+
586
+ foreach (preg_split('% *, *%', $this->options['import_specified'], -1, PREG_SPLIT_NO_EMPTY) as $chank) {
587
+ if (preg_match('%^(\d+)-(\d+)$%', $chank, $mtch)) {
588
+ $specified_records = array_merge($specified_records, range(intval($mtch[1]), intval($mtch[2])));
589
+ } else {
590
+ $specified_records = array_merge($specified_records, array(intval($chank)));
591
+ }
592
+ }
593
 
 
 
594
  }
595
 
596
+ foreach ($titles as $i => $void) {
597
+
598
+ wp_cache_flush();
599
+
600
+ do_action('pmxi_before_post_import', $this->id);
601
 
602
  if (empty($titles[$i])) {
603
+ if ($addons_data['PMWI_Plugin'] and !empty($addons_data['PMWI_Plugin']['single_product_parent_ID'][$i])){
604
+ $titles[$i] = $addons_data['PMWI_Plugin']['single_product_parent_ID'][$i] . ' Product Variation';
605
  }
606
  else{
607
+ $skipped++;
608
  $logger and call_user_func($logger, __('<b>SKIPPED</b>: by empty title', 'pmxi_plugin'));
609
  PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
610
+ PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
 
 
 
 
 
 
 
 
 
611
  pmxi_session_commit();
612
  continue;
613
  }
614
  }
615
+
616
  $articleData = array(
617
  'post_type' => $post_type,
618
  'post_status' => ("xpath" == $this->options['status']) ? $post_status[$i] : $this->options['status'],
624
  'post_content' => ($this->template['is_leave_html']) ? html_entity_decode($contents[$i]) : $contents[$i],
625
  'post_date' => $dates[$i],
626
  'post_date_gmt' => get_gmt_from_date($dates[$i]),
627
+ 'post_author' => $post_author[$i],
628
  'tags_input' => $tags[$i]
629
  );
630
 
640
 
641
  // if Auto Matching re-import option selected
642
  if ("manual" != $this->options['duplicate_matching']){
643
+
644
  // find corresponding article among previously imported
645
+
646
+ $postRecord->clear();
647
  $postRecord->getBy(array(
648
  'unique_key' => $unique_keys[$i],
649
  'import_id' => $this->id,
650
  ));
651
  if ( ! $postRecord->isEmpty() )
652
  $post_to_update = get_post($post_to_update_id = $postRecord->post_id);
653
+
654
  // if Manual Matching re-import option seleted
655
  } else {
656
 
662
  ));
663
 
664
  if ('custom field' == $this->options['duplicate_indicator']) {
665
+ $custom_duplicate_value = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_value'], $file)->parse($records); $tmp_files[] = $file;
666
+ $custom_duplicate_name = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
667
  }
668
  else{
669
  count($titles) and $custom_duplicate_name = $custom_duplicate_value = array_fill(0, count($titles), '');
670
  }
671
 
672
  // handle duplicates according to import settings
673
+ if ($duplicates = pmxi_findDuplicates($articleData, $custom_duplicate_name[$i], $custom_duplicate_value[$i], $this->options['duplicate_indicator'])) {
674
  $duplicate_id = array_shift($duplicates);
675
  if ($duplicate_id) {
676
  $post_to_update = get_post($post_to_update_id = $duplicate_id);
677
  }
678
  }
679
  }
680
+
681
+ if (!empty($specified_records)){
682
+ if ( ! in_array($created + $updated + $skipped + 1, $specified_records) ){
683
+ $skipped++;
684
+ if ( ! empty($post_to_update_id) and ! in_array($post_to_update_id, $current_post_ids) ) $current_post_ids[] = $post_to_update_id;
685
+ $logger and call_user_func($logger, __('<b>SKIPPED</b>: by specified records option', 'pmxi_plugin'));
686
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
687
+ $logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
688
+ pmxi_session_commit();
689
+ continue;
690
+ }
691
+ }
692
 
693
  // Duplicate record is founded
694
  if ($post_to_update){
695
  // Do not update already existing records option selected
696
+ if ("yes" == $this->options['is_keep_former_posts']) {
697
+
698
+ if ( ! in_array($post_to_update_id, $current_post_ids) ) $current_post_ids[] = $post_to_update_id;
 
 
 
 
 
 
699
 
700
  // Do not update product variations
701
+ $current_post_ids = apply_filters('pmxi_do_not_update_existing', $current_post_ids, $post_to_update_id);
702
+
703
+ $skipped++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
704
  $logger and call_user_func($logger, sprintf(__('<b>SKIPPED</b>: Previously imported record found for `%s`', 'pmxi_plugin'), $articleData['post_title']));
705
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
706
+ $logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
 
 
 
 
 
707
  pmxi_session_commit();
708
  continue;
709
  }
710
 
711
  $articleData['ID'] = $post_to_update_id;
712
+ // Choose which data to update
713
+ if ( $this->options['update_all_data'] == 'no' ){
714
+ // preserve date of already existing article when duplicate is found
715
+ if ( ! $this->options['is_update_categories'] or ($this->options['is_update_categories'] and $this->options['update_categories_logic'] != "full_update")) {
716
+ // preserve categories and tags of already existing article if corresponding setting is specified
717
+ $cats_list = get_the_category($articleData['ID']);
718
+ $existing_cats = array();
719
+ if (is_wp_error($cats_list)) {
720
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current categories for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
721
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
722
  } else {
723
+ $cats_new = array();
724
+ foreach ($cats_list as $c) {
725
+ $cats_new[] = $c->slug;
726
+ }
727
+ $existing_cats[$i] = $cats_new;
728
+ }
729
+
730
+ // Re-import Post Tags
731
+ if ( ! $this->options['is_update_categories'] or $this->options['update_categories_logic'] == 'add_new'
732
+ or ($this->options['update_categories_logic'] == 'only' and empty($this->options['taxonomies_list']))
733
+ or (! empty($this->options['taxonomies_list']) and is_array($this->options['taxonomies_list']) and ((in_array('post_tag', $this->options['taxonomies_list']) and $this->options['update_categories_logic'] == 'all_except') or (!in_array('post_tag', $this->options['taxonomies_list']) and $this->options['update_categories_logic'] == 'only')))) {
734
+
735
+ $tags_list = get_the_tags($articleData['ID']);
736
+ if (is_wp_error($tags_list)) {
737
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current tags for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
738
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
739
+ } else {
740
+ $tags_new = ($this->options['is_update_categories'] and $this->options['update_categories_logic'] == 'add_new') ? array_filter(explode(",", $tags[$i])) : array();
741
+ if ($tags_list) foreach ($tags_list as $t) {
742
+ if ( ! in_array($t->name, $tags_new) ) $tags_new[] = $t->name;
743
+ }
744
+ $articleData['tags_input'] = implode(', ', $tags_new);
745
  }
 
 
746
  }
747
+
748
+ $existing_taxonomies = array();
749
+ foreach (array_keys($taxonomies) as $tx_name) {
750
+ $txes_list = get_the_terms($articleData['ID'], $tx_name);
751
+ if (is_wp_error($txes_list)) {
752
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to get current taxonomies for article #%d, updating with those read from XML file', 'pmxi_plugin'), $articleData['ID']));
753
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
754
+ } else {
755
+ $txes_new = array();
756
+ if (!empty($txes_list)):
757
+ foreach ($txes_list as $t) {
758
+ $txes_new[] = $t->slug;
759
+ }
760
+ endif;
761
+ $existing_taxonomies[$tx_name][$i] = $txes_new;
762
+ }
763
+ }
764
+ }
765
+ else{
766
+ //Remove existing taxonomies
767
+ foreach (array_keys($taxonomies) as $tx_name) wp_set_object_terms($articleData['ID'], NULL, $tx_name);
768
+ }
769
+ if ( ! $this->options['is_update_dates']) { // preserve date of already existing article when duplicate is found
770
+ $articleData['post_date'] = $post_to_update->post_date;
771
+ $articleData['post_date_gmt'] = $post_to_update->post_date_gmt;
772
+ }
773
+ if ( ! $this->options['is_update_status']) { // preserve status and trashed flag
774
+ $articleData['post_status'] = $post_to_update->post_status;
775
+ }
776
+ if ( ! $this->options['is_update_content']){
777
+ $articleData['post_content'] = $post_to_update->post_content;
778
+ }
779
+ if ( ! $this->options['is_update_title']){
780
+ $articleData['post_title'] = $post_to_update->post_title;
781
+ }
782
+ if ( ! $this->options['is_update_slug']){
783
+ $articleData['post_name'] = $post_to_update->post_name;
784
+ }
785
+ if ( ! $this->options['is_update_excerpt']){
786
+ $articleData['post_excerpt'] = $post_to_update->post_excerpt;
787
+ }
788
+ if ( ! $this->options['is_update_menu_order']){
789
+ $articleData['menu_order'] = $post_to_update->menu_order;
790
+ }
791
+ if ( ! $this->options['is_update_parent']){
792
+ $articleData['post_parent'] = $post_to_update->post_parent;
793
+ }
794
  }
795
+ if ( $this->options['update_all_data'] == 'yes' or ( $this->options['update_all_data'] == 'no' and $this->options['is_update_attachments'])) {
796
+ wp_delete_attachments($articleData['ID'], true, 'files');
797
  }
798
  // handle obsolete attachments (i.e. delete or keep) according to import settings
799
+ if ( $this->options['update_all_data'] == 'yes' or ( $this->options['update_all_data'] == 'no' and $this->options['is_update_images'] and $this->options['update_images_logic'] == "full_update")){
800
+ wp_delete_attachments($articleData['ID'], $this->options['download_images'], 'images');
801
  }
 
802
  }
803
  elseif ( ! $postRecord->isEmpty() ){
804
 
805
  // existing post not found though it's track was found... clear the leftover, plugin will continue to treat record as new
806
  $postRecord->delete();
807
 
808
+ }
809
 
810
  // no new records are created. it will only update posts it finds matching duplicates for
811
+ if ( ! $this->options['create_new_records'] and empty($articleData['ID'])){
812
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
813
+ $logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
814
+ $skipped++;
 
 
 
 
 
 
 
 
 
815
  pmxi_session_commit();
816
  continue;
817
  }
881
  $dest->insert();
882
  } else {
883
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to create cloaked link for %s', 'pmxi_plugin'), $url));
884
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
885
  $link = NULL;
886
  }
887
  }
893
  }
894
  }
895
 
896
+ // insert article being imported
897
+ $pid = ($this->options['is_fast_mode']) ? pmxi_insert_post($articleData, true) : wp_insert_post($articleData, true);
898
 
899
  if (is_wp_error($pid)) {
900
  $logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
901
+ $logger and PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
902
  } else {
903
+
904
+ if ( ! in_array($pid, $current_post_ids) ) $current_post_ids[] = $pid;
 
 
 
 
 
 
905
 
906
  if ("manual" != $this->options['duplicate_matching'] or empty($articleData['ID'])){
907
  // associate post with import
909
  'post_id' => $pid,
910
  'import_id' => $this->id,
911
  'unique_key' => $unique_keys[$i],
912
+ 'product_key' => ($post_type == "product" and PMXI_Admin_Addons::get_addon('PMWI_Plugin')) ? $addons_data['PMWI_Plugin']['single_product_ID'][$i] : ''
913
  ))->insert();
914
  }
915
 
917
  if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ){
918
  set_post_format($pid, $this->options['post_format'] );
919
  }
920
+ // [/post format]
921
+
922
+ // [custom fields]
923
+ if (empty($articleData['ID']) or $this->options['update_all_data'] == 'yes' or ($this->options['update_all_data'] == 'no' and $this->options['is_update_custom_fields']) or ($this->options['update_all_data'] == 'no' and $this->options['is_update_attributes'])) {
924
+
925
+ // Delete all meta keys
926
+ if ( ! empty($articleData['ID']) ) {
927
 
928
+ // Get all existing meta keys
929
+ $existing_meta_keys = array(); foreach (get_post_meta($pid, '') as $cur_meta_key => $cur_meta_val) $existing_meta_keys[] = $cur_meta_key;
930
 
931
+ // delete keys which are no longer correspond to import settings
932
+ foreach ($existing_meta_keys as $cur_meta_key) {
933
+
934
+ // Do not delete post meta for features image
935
+ if ( in_array($cur_meta_key, array('_thumbnail_id','_product_image_gallery')) ) continue;
936
+
937
+ $field_to_delete = true;
938
 
939
+ // apply addons filters
940
+ if ( ! apply_filters('pmxi_custom_field_to_delete', $field_to_delete, $pid, $post_type, $this->options, $cur_meta_key) ) continue;
941
 
942
+ // Update all Custom Fields is defined
943
+ if ($this->options['update_all_data'] == 'yes' or ($this->options['update_all_data'] == 'no' and $this->options['is_update_custom_fields'] and $this->options['update_custom_fields_logic'] == "full_update")) {
944
+ delete_post_meta($pid, $cur_meta_key);
945
+ }
946
+ // Update only these Custom Fields, leave the rest alone
947
+ elseif ($this->options['update_all_data'] == 'no' and $this->options['is_update_custom_fields'] and $this->options['update_custom_fields_logic'] == "only"){
948
+ if (!empty($this->options['custom_fields_list']) and is_array($this->options['custom_fields_list']) and in_array($cur_meta_key, $this->options['custom_fields_list'])) delete_post_meta($pid, $cur_meta_key);
949
+ }
950
+ // Leave these fields alone, update all other Custom Fields
951
+ elseif ($this->options['update_all_data'] == 'no' and $this->options['is_update_custom_fields'] and $this->options['update_custom_fields_logic'] == "all_except"){
952
+ if ( empty($this->options['custom_fields_list']) or ! in_array($cur_meta_key, $this->options['custom_fields_list'])) delete_post_meta($pid, $cur_meta_key);
953
+ }
954
+
955
+ }
956
+ }
957
+
958
+ }
959
+ // [/custom fields]
960
+
961
+ // [addons import]
962
+
963
+ // prepare data for import
964
+ $importData = array(
965
+ 'pid' => $pid,
966
+ 'i' => $i,
967
+ 'import' => $this,
968
+ 'articleData' => $articleData,
969
+ 'xml' => $xml,
970
+ 'is_cron' => $is_cron,
971
+ 'logger' => $logger,
972
+ 'xpath_prefix' => $xpath_prefix
973
+ );
974
+
975
+ // deligate operation to addons
976
+ foreach (PMXI_Admin_Addons::get_active_addons() as $class) $addons[$class]->import($importData);
977
+
978
+ // [/addons import]
979
+
980
+ // Page Template
981
  if ('post' != $articleData['post_type'] and !empty($this->options['page_template'])) update_post_meta($pid, '_wp_page_template', $this->options['page_template']);
982
 
983
  // [featured image]
984
+ if ( $articleData['post_type'] == 'product' and class_exists('PMWI_Plugin') and ! empty($uploads) and false === $uploads['error'] and !empty($featured_images[$i]) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_images']))) {
985
 
986
  require_once(ABSPATH . 'wp-admin/includes/image.php');
987
 
989
  if ( ! is_array($image_meta_titles[$i]) ) $image_meta_titles[$i] = array($image_meta_titles[$i]);
990
  if ( ! is_array($image_meta_captions[$i]) ) $image_meta_captions[$i] = array($image_meta_captions[$i]);
991
  if ( ! is_array($image_meta_descriptions[$i]) ) $image_meta_descriptions[$i] = array($image_meta_descriptions[$i]);
992
+
993
  $success_images = false;
994
  $gallery_attachment_ids = array();
995
 
1009
  foreach ($imgs as $img_key => $img_url) { if (empty($img_url)) continue;
1010
 
1011
  $url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
1012
+ $img_ext = pmxi_getExtensionFromStr($url);
1013
+ if ($img_ext == "") $img_ext = pmxi_get_remote_image_ext($url);
1014
+
1015
+ $image_name = (($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? url_title($auto_rename_images[$i] . '_' . str_replace("." . $img_ext, "", array_shift(explode('?', basename($url))))) : str_replace("." . $img_ext, "", array_shift(explode('?', basename($url))))) . (("" != $img_ext) ? '.' . $img_ext : '');
1016
 
1017
  // if wizard store image data to custom field
1018
  $create_image = false;
1027
  imagejpeg($img, $image_filepath);
1028
  if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1029
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
1030
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1031
  } else {
1032
  $create_image = true;
1033
  }
1039
  $image_filepath = $uploads['path'] . '/' . url_title($image_filename);
1040
 
1041
  // keep existing and add newest images
1042
+ if ( ! empty($articleData['ID']) and $this->options['is_update_images'] and $this->options['update_images_logic'] == "add_new" and $this->options['update_all_data'] == "no"){
1043
  $attachment_imgs = get_posts( array(
1044
  'post_type' => 'attachment',
1045
  'posts_per_page' => -1,
1049
  if ( $attachment_imgs ) {
1050
  foreach ( $attachment_imgs as $attachment_img ) {
1051
  if ($attachment_img->guid == $uploads['url'] . '/' . $image_name){
1052
+ $download_image = false;
1053
+ $success_images = true;
1054
+ if ( ! has_post_thumbnail($pid) )
1055
+ set_post_thumbnail($pid, $attachment_img->ID);
1056
+ else
1057
+ $gallery_attachment_ids[] = $attachment_img->ID;
1058
+
1059
  $logger and call_user_func($logger, sprintf(__('<b>Image SKIPPED</b>: The image %s is always exists for the %s', 'pmxi_plugin'), basename($attachment_img->guid), $articleData['post_title']));
1060
  }
1061
+ }
 
1062
  }
1063
  }
1064
 
1067
  // do not download images
1068
  if ( ! $this->options['download_images'] ){
1069
 
1070
+ $image_filename = $image_name;
1071
+ $image_filepath = $uploads['path'] . '/' . url_title( $image_filename );
1072
 
1073
  if ( @file_exists($image_filepath) ){
1074
  $download_image = false;
1075
  if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1076
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $image_filepath));
1077
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1078
+ @unlink($image_filepath);
1079
  } else {
1080
  $create_image = true;
1081
  }
1085
  if ($download_image){
1086
 
1087
  if ( ! get_file_curl($url, $image_filepath) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1088
+ @unlink($image_filepath); // delete file since failed upload may result in empty file created
1089
  } elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1090
  $create_image = true;
1091
  }
1096
 
1097
  if ( ! get_file_curl($url, $image_filepath) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1098
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
1099
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1100
+ @unlink($image_filepath); // delete file since failed upload may result in empty file created
1101
  } elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1102
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s is not a valid image and cannot be set as featured one', 'pmxi_plugin'), $url));
1103
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1104
+ @unlink($image_filepath);
1105
  } else {
1106
  $create_image = true;
1107
  }
 
1108
  }
1109
  }
1110
+ }
1111
+ }
1112
 
1113
  if ($create_image){
1114
 
1125
  $attachment['post_content'] = $image_meta['caption'];
1126
  }
1127
 
1128
+ $attid = ($this->options['is_fast_mode']) ? pmxi_insert_attachment($attachment, $image_filepath, $pid) : wp_insert_attachment($attachment, $image_filepath, $pid);
1129
 
1130
  if (is_wp_error($attid)) {
1131
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $attid->get_error_message());
1132
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1133
  } else {
1134
  // you must first include the image.php file
1135
  // for the function wp_generate_attachment_metadata() to work
1143
  if ( ! empty($img_descriptions[$img_key]) ) $update_attachment_meta['post_content'] = $img_descriptions[$img_key];
1144
  if ( ! empty($img_alts[$img_key]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$img_key]);
1145
 
1146
+ if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
1147
+
 
 
1148
  }
1149
 
1150
  do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
1151
 
1152
  $success_images = true;
1153
+ if ( ! has_post_thumbnail($pid) )
1154
+ set_post_thumbnail($pid, $attid);
1155
+ else
1156
+ $gallery_attachment_ids[] = $attid;
 
 
 
 
1157
  }
1158
  }
1159
  }
1160
  }
1161
+ }
 
1162
  // Set product gallery images
1163
  if ( $post_type == "product" and !empty($gallery_attachment_ids) )
1164
  update_post_meta($pid, '_product_image_gallery', implode(',', $gallery_attachment_ids));
1165
  // Create entry as Draft if no images are downloaded successfully
1166
+ if ( ! $success_images and "yes" == $this->options['create_draft'] ) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
1167
  }
1168
  // [/featured image]
1169
 
1170
  // [attachments]
1171
+ if ( ! empty($uploads) and false === $uploads['error'] and !empty($attachments[$i]) and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ($this->options['update_all_data'] == "no" and $this->options['is_update_attachments']))) {
1172
 
1173
  // you must first include the image.php file
1174
  // for the function wp_generate_attachment_metadata() to work
1188
 
1189
  if ( ! get_file_curl(trim($atch_url), $attachment_filepath) and ! @file_put_contents($attachment_filepath, @file_get_contents(trim($atch_url)))) {
1190
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Attachment file %s cannot be saved locally as %s', 'pmxi_plugin'), trim($atch_url), $attachment_filepath));
1191
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1192
  unlink($attachment_filepath); // delete file since failed upload may result in empty file created
1193
  } elseif( ! $wp_filetype = wp_check_filetype(basename($attachment_filename), null )) {
1194
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Can\'t detect attachment file type %s', 'pmxi_plugin'), trim($atch_url)));
1195
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1196
  } else {
1197
 
1198
  $attachment_data = array(
1202
  'post_content' => '',
1203
  'post_status' => 'inherit'
1204
  );
1205
+ $attach_id = ($this->options['is_fast_mode']) ? pmxi_insert_attachment( $attachment_data, $attachment_filepath, $pid ) : wp_insert_attachment( $attachment_data, $attachment_filepath, $pid );
1206
 
1207
  if (is_wp_error($attach_id)) {
1208
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $pid->get_error_message());
1209
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1210
+ } else {
 
1211
  wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attachment_filepath));
1212
+ do_action( 'pmxi_attachment_uploaded', $pid, $attid, $image_filepath);
1213
  }
1214
  }
1215
  }
1219
  // [/attachments]
1220
 
1221
  // [custom taxonomies]
1222
+ if ($articleData['post_type'] == 'product' and class_exists('PMWI_Plugin') and !empty($taxonomies)){
1223
+
1224
+ foreach ($taxonomies as $tx_name => $txes) {
1225
+
1226
+ // Skip updating product attributes
1227
+ if ( PMXI_Admin_Addons::get_addon('PMWI_Plugin') and strpos($tx_name, "pa_") === 0 ) continue;
1228
+
1229
+ if ( empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_categories'] )) {
1230
+
1231
+ if (!empty($articleData['ID'])){
1232
+ if ($this->options['update_all_data'] == "no" and $this->options['update_categories_logic'] == "all_except" and !empty($this->options['taxonomies_list'])
1233
+ and is_array($this->options['taxonomies_list']) and in_array($tx_name, $this->options['taxonomies_list'])) continue;
1234
+ if ($this->options['update_all_data'] == "no" and $this->options['update_categories_logic'] == "only" and ((!empty($this->options['taxonomies_list'])
1235
+ and is_array($this->options['taxonomies_list']) and ! in_array($tx_name, $this->options['taxonomies_list'])) or empty($this->options['taxonomies_list']))) continue;
1236
+ }
1237
 
1238
  $assign_taxes = array();
1239
 
1240
+ if ($this->options['update_categories_logic'] == "add_new" and !empty($existing_taxonomies[$tx_name][$i])){
1241
  $assign_taxes = $existing_taxonomies[$tx_name][$i];
1242
  unset($existing_taxonomies[$tx_name][$i]);
1243
  }
1244
+ elseif(!empty($existing_taxonomies[$tx_name][$i])){
1245
+ unset($existing_taxonomies[$tx_name][$i]);
1246
+ }
1247
 
1248
  // create term if not exists
1249
  if (!empty($txes[$i])):
1250
  foreach ($txes[$i] as $key => $single_tax) {
1251
+ if (is_array($single_tax)){
1252
 
1253
+ $parent_id = (!empty($single_tax['parent'])) ? pmxi_recursion_taxes($single_tax['parent'], $tx_name, $txes[$i], $key) : '';
1254
 
1255
  $term = is_exists_term($tx_name, $single_tax['name'], (int)$parent_id);
1256
 
1265
 
1266
  if ( is_wp_error($term) ){
1267
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: `%s`', 'pmxi_plugin'), $term->get_error_message()));
1268
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1269
  }
1270
  elseif (!empty($term)) {
1271
  $cat_id = $term['term_id'];
1280
  endif;
1281
  if (!empty($assign_taxes)){
1282
  // associate taxes with post
1283
+ $term_ids = wp_set_object_terms($pid, $assign_taxes, $tx_name);
1284
  if (is_wp_error($term_ids)) {
1285
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$term_ids->get_error_message());
1286
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1287
  }
1288
  }
1289
  }
1290
  }
1291
+ if (!empty($existing_taxonomies) and $this->options['update_all_data'] == "no" and $this->options['is_update_categories'] and $this->options['update_categories_logic'] != 'full_update') {
1292
  foreach ($existing_taxonomies as $tx_name => $txes) {
1293
+ // Skip updating product attributes
1294
+ if ( PMXI_Admin_Addons::get_addon('PMWI_Plugin') and strpos($tx_name, "pa_") === 0 ) continue;
1295
+
1296
  if (!empty($txes[$i])){
1297
  $term_ids = wp_set_object_terms($pid, $txes[$i], $tx_name);
1298
  if (is_wp_error($term_ids)) {
1299
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$term_ids->get_error_message());
1300
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1301
  }
1302
  }
1303
  }
1308
  // [categories]
1309
  if (!empty($cats[$i])) {
1310
 
1311
+ if ( empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_categories'] )) {
1312
 
1313
+ wp_set_object_terms( $pid, NULL, 'category' );
1314
 
1315
+ $is_update_cats = true;
1316
 
1317
+ if (!empty($articleData['ID'])){
1318
+ if ($this->options['update_all_data'] == "no" and $this->options['update_categories_logic'] == "all_except" and !empty($this->options['taxonomies_list'])
1319
+ and is_array($this->options['taxonomies_list']) and in_array('category', $this->options['taxonomies_list'])) $is_update_cats = false;
1320
+ if ($this->options['update_all_data'] == "no" and $this->options['update_categories_logic'] == "only" and ((!empty($this->options['taxonomies_list'])
1321
+ and is_array($this->options['taxonomies_list']) and ! in_array('category', $this->options['taxonomies_list'])) or empty($this->options['taxonomies_list']))) $is_update_cats = false;
1322
  }
1323
 
1324
+ if ($is_update_cats){
1325
+ $assign_cats = array();
1326
 
1327
+ if ($this->options['update_categories_logic'] == "add_new" and !empty($existing_cats[$i])){
1328
+ $assign_cats = $existing_cats[$i];
1329
+ unset($existing_cats[$i]);
1330
+ }
1331
+ elseif(!empty($existing_cats[$i])){
1332
+ unset($existing_cats[$i]);
1333
+ }
1334
 
1335
+ // create categories if it's doesn't exists
1336
+ foreach ($cats[$i] as $key => $single_cat) {
1337
 
1338
+ if (is_array($single_cat)){
1339
+
1340
+ $parent_id = (!empty($single_cat['parent'])) ? pmxi_recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
1341
+
1342
+ $term = is_exists_term('category', $single_cat['name'], (int)$parent_id);
1343
+
1344
+ if ( empty($term) and !is_wp_error($term) ){
1345
+ $term_attr = array('parent'=> (!empty($parent_id)) ? $parent_id : 0);
1346
+ $term = wp_insert_term(
1347
+ $single_cat['name'], // the term
1348
+ 'category', // the taxonomy
1349
+ $term_attr
1350
+ );
1351
+ }
1352
+
1353
+ if ( is_wp_error($term) ){
1354
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: `%s`', 'pmxi_plugin'), $term->get_error_message()));
1355
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1356
+ }
1357
+ elseif ( ! empty($term) ) {
1358
+ $cat_id = $term['term_id'];
1359
+ if ($cat_id and $single_cat['assign'])
1360
+ {
1361
+ $term = get_term_by('id', $cat_id, 'category');
1362
+ if ( ! in_array($term->slug, $assign_cats)) $assign_cats[] = $term->slug;
1363
+ }
1364
  }
1365
+ }
1366
+ }
 
1367
 
1368
+ // associate categories with post
1369
+ $cats_ids = wp_set_object_terms($pid, $assign_cats, 'category');
1370
+ if (is_wp_error($cats_ids)) {
1371
+ $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$cats_ids->get_error_message());
1372
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1373
+ }
1374
+ }
1375
  }
1376
  }
1377
 
1378
+ if (!empty($existing_cats[$i]) and $this->options['update_all_data'] == "no" and (!$this->options['is_update_categories'] or ($this->options['is_update_categories'] and $this->options['update_categories_logic'] != 'full_update'))) {
1379
+ $cats_ids = wp_set_object_terms($pid, $existing_cats[$i], 'category');
 
1380
  if (is_wp_error($cats_ids)) {
1381
  $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': '.$cats_ids->get_error_message());
1382
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1383
  }
1384
  }
1385
  // [/categories]
1386
 
1387
+ if (empty($articleData['ID'])) {
 
1388
  $logger and call_user_func($logger, sprintf(__('`%s` post created successfully', 'pmxi_plugin'), $articleData['post_title']));
1389
+ } else {
 
1390
  $logger and call_user_func($logger, sprintf(__('`%s` post updated successfully', 'pmxi_plugin'), $articleData['post_title']));
1391
+ }
1392
+
1393
  do_action( 'pmxi_saved_post', $pid); // hook that was triggered immediately after post saved
1394
 
1395
+ if (empty($articleData['ID'])) $created++; else $updated++;
 
 
 
 
 
 
 
 
1396
 
1397
+ if ( ! $is_cron and "default" == $this->options['import_processing'] ){
1398
+ $processed_records = $created + $updated + $skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
1399
+ $logger and call_user_func($logger, sprintf(__('<span class="processing_info"><span class="created_count">%s</span><span class="updated_count">%s</span><span class="percents_count">%s</span></span>', 'pmxi_plugin'), $created, $updated, ceil(($processed_records/$this->count) * 100)));
 
 
 
 
1400
  }
1401
+
1402
+ }
1403
 
1404
+ do_action('pmxi_after_post_import', $this->id);
1405
+
1406
+ $logger and PMXI_Plugin::$session['pmxi_import']['chunk_number'] = ++PMXI_Plugin::$session->data['pmxi_import']['chunk_number'];
1407
  }
1408
 
1409
+ wp_cache_flush();
1410
+
1411
+ $current_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1412
+
1413
+ $this->set(array(
1414
+ 'imported' => $created + $updated,
1415
+ 'created' => $created,
1416
+ 'updated' => $updated,
1417
+ 'skipped' => $skipped,
1418
+ 'queue_chunk_number' => $created + $updated + $skipped,
1419
+ 'current_post_ids' => json_encode(array_unique(array_merge($current_ids, $current_post_ids)))
1420
+ ))->update();
1421
 
1422
+ if ( ! $is_cron ){
1423
 
1424
+ pmxi_session_commit();
1425
 
1426
+ $records_count = $this->created + $this->updated + $this->skipped + PMXI_Plugin::$session->data['pmxi_import']['errors'];
1427
 
1428
+ $is_import_complete = ($records_count == $this->count);
 
 
1429
 
1430
+ // Delete posts that are no longer present in your file
1431
+ if ( $is_import_complete and ! empty($this->options['is_delete_missing'])) {
 
 
 
 
 
 
 
 
 
 
 
1432
 
1433
+ $logger and call_user_func($logger, 'Removing previously imported posts which are no longer actual...');
1434
+ $postList = new PMXI_Post_List();
1435
+ $current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1436
 
1437
+ $missing_ids = array();
1438
+ foreach ($postList->getBy(array('import_id' => $this->id, 'post_id NOT IN' => $current_post_ids)) as $missingPost) {
1439
+
1440
+ $missing_ids[] = $missingPost['post_id'];
1441
 
1442
+ // Instead of deletion, set Custom Field
1443
+ if ($this->options['is_update_missing_cf']){
1444
+ update_post_meta( $missingPost['post_id'], $this->options['update_missing_cf_name'], $this->options['update_missing_cf_value'] );
1445
+ }
 
1446
 
1447
+ // Instead of deletion, change post status to Draft
1448
+ if ($this->options['set_missing_to_draft']) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $missingPost['post_id']) );
 
 
1449
 
1450
+ // Delete posts that are no longer present in your file
1451
+ if ( ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
1452
 
1453
+ // Remove attachments
1454
+ empty($this->options['is_keep_attachments']) and wp_delete_attachments($missingPost['post_id'], true, 'files');
1455
+ // Remove images
1456
+ empty($this->options['is_keep_imgs']) and wp_delete_attachments($missingPost['post_id'], $this->options['download_images']);
1457
 
1458
+ // Delete record form pmxi_posts
1459
+ $missingRecord = new PMXI_Post_Record();
1460
+ $missingRecord->getById($missingPost['id'])->delete();
 
 
 
 
1461
 
1462
+ // Clear post's relationships
1463
+ wp_delete_object_term_relationships($missingPost['post_id'], get_object_taxonomies('' != $this->options['custom_type'] ? $this->options['custom_type'] : 'post'));
1464
+
1465
+ }
1466
+
1467
+ }
1468
+
1469
+ // Delete posts from database
1470
+ if (!empty($missing_ids) && is_array($missing_ids) and ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
1471
+
1472
+ $sql = "delete a,b,c
1473
+ FROM ".$this->wpdb->posts." a
1474
+ LEFT JOIN ".$this->wpdb->term_relationships." b ON ( a.ID = b.object_id )
1475
+ LEFT JOIN ".$this->wpdb->postmeta." c ON ( a.ID = c.post_id )
1476
+ WHERE a.ID IN (".implode(',', $missing_ids).")";
1477
+
1478
+ $this->wpdb->query(
1479
+ $this->wpdb->prepare($sql, '')
1480
+ );
1481
+
1482
+ do_action('pmxi_delete_post', $missing_ids);
1483
+ }
1484
 
 
 
 
 
 
 
 
1485
  }
1486
 
1487
+ // Set out of stock status for missing records [Woocommerce add-on option]
1488
+ if ( $is_import_complete and empty($this->options['is_delete_missing']) and $post_type == "product" and class_exists('PMWI_Plugin') and !empty($this->options['missing_records_stock_status'])) {
1489
+
1490
+ $logger and call_user_func($logger, 'Update stock status previously imported posts which are no longer actual...');
1491
+ $postList = new PMXI_Post_List();
1492
+ $current_post_ids = (empty($this->current_post_ids)) ? array() : json_decode($this->current_post_ids, true);
1493
+ foreach ($postList->getBy(array('import_id' => $this->id, 'post_id NOT IN' => $current_post_ids)) as $missingPost) {
1494
+ update_post_meta( $missingPost['post_id'], '_stock_status', 'outofstock' );
1495
+ update_post_meta( $missingPost['post_id'], '_stock', 0 );
1496
+ }
1497
+
1498
+ }
1499
+ }
1500
 
1501
  } catch (XmlImportException $e) {
1502
  $logger and call_user_func($logger, __('<b>ERROR</b>', 'pmxi_plugin') . ': ' . $e->getMessage());
1503
  PMXI_Plugin::$session['pmxi_import']['errors'] = ++PMXI_Plugin::$session->data['pmxi_import']['errors'];
1504
+ }
 
 
1505
 
1506
+ $logger and $is_import_complete and call_user_func($logger, __('Cleaning temporary data...', 'pmxi_plugin'));
1507
  foreach ($tmp_files as $file) { // remove all temporary files created
1508
  unlink($file);
1509
  }
1510
 
1511
  if (($is_cron or $is_import_complete) and $this->options['is_delete_source']) {
1512
+ $logger and call_user_func($logger, __('Deleting source XML file...', 'pmxi_plugin'));
1513
+
1514
+ // Delete chunks
1515
+ foreach (PMXI_Helper::safe_glob($uploads['path'] . '/pmxi_chunk_*', PMXI_Helper::GLOB_RECURSE | PMXI_Helper::GLOB_PATH) as $filePath) {
1516
+ @file_exists($filePath) and @unlink($filePath);
1517
+ }
1518
+
1519
  if ($this->type != "ftp"){
1520
  if ( ! @unlink($this->path)) {
1521
  $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: Unable to remove %s', 'pmxi_plugin'), $this->path));
1532
  }
1533
  }
1534
  }
1535
+
1536
  if ( ! $is_cron and $is_import_complete ){
1537
+
1538
  $this->set(array(
1539
+ 'processing' => 0, // unlock cron requests
1540
  'triggered' => 0,
1541
  'queue_chunk_number' => 0,
1542
+ 'current_post_ids' => '',
1543
+ 'registered_on' => date('Y-m-d H:i:s')
1544
+ ))->update();
1545
+
1546
  $logger and call_user_func($logger, 'Done');
1547
  }
1548
 
1549
  remove_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // return any filtering rules back if they has been disabled for import procedure
1550
 
1551
  return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1552
  }
1553
+
1554
  public function _filter_has_cap_unfiltered_html($caps)
1555
  {
1556
  $caps['unfiltered_html'] = true;
1557
  return $caps;
1558
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1559
 
1560
  /**
1561
  * Clear associations with posts
1568
  if ( ! $keepPosts) {
1569
  $ids = array();
1570
  foreach ($post->getBy('import_id', $this->id)->convertRecords() as $p) {
1571
+ // Remove attachments
1572
+ empty($this->options['is_keep_attachments']) and wp_delete_attachments($p->post_id, true, 'files');
1573
+ // Remove images
1574
+ empty($this->options['is_keep_imgs']) and wp_delete_attachments($p->post_id, $this->options['download_images']);
1575
  $ids[] = $p->post_id;
1576
  }
1577
  if (!empty($ids)){
plugin.php CHANGED
@@ -2,8 +2,8 @@
2
  /*
3
  Plugin Name: WP All Import
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
5
- Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. Perform scheduled updates and overwrite of existing import jobs. Free lite edition.
6
- Version: 3.0.4
7
  Author: Soflyy
8
  */
9
 
@@ -28,7 +28,7 @@ define('PMXI_ROOT_URL', rtrim(plugin_dir_url(__FILE__), '/'));
28
  */
29
  define('PMXI_PREFIX', 'pmxi_');
30
 
31
- define('PMXI_VERSION', '3.0.4');
32
 
33
  define('PMXI_EDITION', 'free');
34
 
@@ -75,7 +75,7 @@ final class PMXI_Plugin {
75
  * Max allowed file size (bytes) to import in default mode
76
  * @var int
77
  */
78
- const LARGE_SIZE = 0; // all files will importing in large import mode
79
 
80
  public static $session;
81
 
@@ -84,7 +84,6 @@ final class PMXI_Plugin {
84
  public static $is_csv = false;
85
 
86
  public static $csv_path = false;
87
-
88
  /**
89
  * Return singletone instance
90
  * @return PMXI_Plugin
@@ -150,7 +149,9 @@ final class PMXI_Plugin {
150
  */
151
  public function getTablePrefix() {
152
  global $wpdb;
153
- return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix) . self::PREFIX;
 
 
154
  }
155
 
156
  /**
@@ -159,7 +160,7 @@ final class PMXI_Plugin {
159
  */
160
  public function getWPPrefix() {
161
  global $wpdb;
162
- return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix);
163
  }
164
 
165
  /**
@@ -168,8 +169,8 @@ final class PMXI_Plugin {
168
  * @param string $pluginFilePath Plugin main file
169
  */
170
  protected function __construct() {
171
-
172
- // create/update required database tables
173
 
174
  // regirster autoloading method
175
  if (function_exists('__autoload') and ! in_array('__autoload', spl_autoload_functions())) { // make sure old way of autoloading classes is not broken
@@ -233,8 +234,75 @@ final class PMXI_Plugin {
233
  }
234
 
235
  // register admin page pre-dispatcher
236
- add_action('admin_init', array($this, '__adminInit'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  }
239
 
240
  /**
@@ -362,7 +430,7 @@ final class PMXI_Plugin {
362
  }
363
  }
364
  }
365
-
366
  return FALSE;
367
  }
368
 
@@ -496,6 +564,22 @@ final class PMXI_Plugin {
496
  }
497
  }
498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
499
  /**
500
  * Method returns default import options, main utility of the method is to avoid warnings when new
501
  * option is introduced but already registered imports don't have it
@@ -527,6 +611,8 @@ final class PMXI_Plugin {
527
  'ping_status' => 'open',
528
  'create_draft' => 'no',
529
  'author' => '',
 
 
530
  'featured_image' => '',
531
  'attachments' => '',
532
  'is_import_specified' => 0,
@@ -536,46 +622,51 @@ final class PMXI_Plugin {
536
  'unique_key' => '',
537
  'feed_type' => 'auto',
538
 
 
539
  'is_delete_missing' => 0,
 
540
  'is_update_missing_cf' => 0,
541
- 'is_keep_former_posts' => 'no',
542
- 'is_keep_status' => 0,
543
- 'is_keep_content' => 0,
544
- 'is_keep_title' => 0,
545
- 'is_keep_excerpt' => 0,
546
- 'is_keep_categories' => 0,
 
 
 
 
 
 
 
 
 
 
 
 
 
 
547
  'is_keep_attachments' => 0,
548
- 'is_keep_images' => 0,
549
- 'is_duplicates' => 0,
550
- 'is_keep_dates' => 0,
551
- 'is_keep_menu_order' => 0,
552
- 'is_keep_parent' => 0,
553
- 'is_keep_attachments_on_update' => 0,
554
- 'records_per_request' => 10,
555
- 'not_create_records' => 0,
556
- 'no_create_featured_image' => 0,
557
-
558
- 'duplicate_indicator' => 'title',
559
- 'duplicate_action' => 'keep',
560
- 'is_update_previous' => 0,
561
- 'is_scheduled' => '',
562
- 'scheduled_period' => '',
563
- 'post_excerpt' => '',
564
- 'post_slug' => '',
565
- 'keep_custom_fields' => 0,
566
- 'keep_custom_fields_specific' => '',
567
- 'keep_custom_fields_except' => '',
568
- 'friendly_name' => '',
569
  'custom_duplicate_name' => '',
570
  'custom_duplicate_value' => '',
571
- 'duplicate_matching' => 'auto',
572
- 'create_chunks' => 0,
573
- 'update_missing_cf_name' => '',
574
- 'update_missing_cf_value' => '',
 
575
  'auto_rename_images' => 0,
576
  'auto_rename_images_suffix' => '',
577
- 'images_name' => 'filename',
578
- 'is_add_newest_categories' => 0,
579
  'post_format' => 'standard',
580
  'encoding' => 'UTF-8',
581
  'delimiter' => '',
@@ -589,12 +680,17 @@ final class PMXI_Plugin {
589
  'image_meta_description' => '',
590
  'image_meta_description_delim' => '',
591
  'status_xpath' => '',
592
- 'download_images' => 1
 
 
 
 
 
593
  );
594
  }
595
 
596
  /*
597
- * Convert csv to xml using yahoo API
598
  */
599
  public static function csv_to_xml($csv_url){
600
 
2
  /*
3
  Plugin Name: WP All Import
4
  Plugin URI: http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=plugins-page&utm_campaign=free+plugin
5
+ Description: The most powerful solution for importing XML and CSV files to WordPress. Create Posts and Pages with content from any XML or CSV file. A paid upgrade to WP All Import Pro is available for support and additional features.
6
+ Version: 3.1.0
7
  Author: Soflyy
8
  */
9
 
28
  */
29
  define('PMXI_PREFIX', 'pmxi_');
30
 
31
+ define('PMXI_VERSION', '3.1.0');
32
 
33
  define('PMXI_EDITION', 'free');
34
 
75
  * Max allowed file size (bytes) to import in default mode
76
  * @var int
77
  */
78
+ const LARGE_SIZE = 0; // all files will importing in large import mode
79
 
80
  public static $session;
81
 
84
  public static $is_csv = false;
85
 
86
  public static $csv_path = false;
 
87
  /**
88
  * Return singletone instance
89
  * @return PMXI_Plugin
149
  */
150
  public function getTablePrefix() {
151
  global $wpdb;
152
+
153
+ //return ($this->isNetwork() ? $wpdb->base_prefix : $wpdb->prefix) . self::PREFIX;
154
+ return $wpdb->prefix . self::PREFIX;
155
  }
156
 
157
  /**
160
  */
161
  public function getWPPrefix() {
162
  global $wpdb;
163
+ return ($this->isNetwork()) ? $wpdb->base_prefix : $wpdb->prefix;
164
  }
165
 
166
  /**
169
  * @param string $pluginFilePath Plugin main file
170
  */
171
  protected function __construct() {
172
+
173
+ $this->load_plugin_textdomain();
174
 
175
  // regirster autoloading method
176
  if (function_exists('__autoload') and ! in_array('__autoload', spl_autoload_functions())) { // make sure old way of autoloading classes is not broken
234
  }
235
 
236
  // register admin page pre-dispatcher
237
+ add_action('admin_init', array($this, '__adminInit'));
238
+ add_action('admin_init', array($this, '_fix_options'));
239
+
240
+ global $wpdb;
241
+
242
+ if (function_exists('is_multisite') && is_multisite()) {
243
+ // check if it is a network activation - if so, run the activation function for each blog id
244
+ if (isset($_GET['networkwide']) && ($_GET['networkwide'] == 1)) {
245
+ $old_blog = $wpdb->blogid;
246
+ // Get all blog ids
247
+ $blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
248
+ foreach ($blogids as $blog_id) {
249
+ switch_to_blog($blog_id);
250
+ $this->__add_feed_type_fix(); // feature to version 2.22
251
+ }
252
+ switch_to_blog($old_blog);
253
+ return;
254
+ }
255
+ }
256
+
257
+ $this->__add_feed_type_fix(); // feature to version 2.22
258
+ }
259
 
260
+ /**
261
+ * convert imports options
262
+ * compatibility with version 3.3
263
+ */
264
+ public function _fix_options(){
265
+ $imports = new PMXI_Import_List();
266
+ $post = new PMXI_Post_Record();
267
+
268
+ foreach ($imports->setColumns($imports->getTable() . '.*')->getBy(array('large_import' => 'Yes'))->convertRecords() as $imp){
269
+
270
+ $imp->getById($imp->id);
271
+
272
+ if ( ! $imp->isEmpty() and empty($imp->options['converted_options'])){
273
+
274
+ $options = $imp->options;
275
+
276
+ $options['update_all_data'] = 'no';
277
+ $options['create_new_records'] = ( ! empty($options['not_create_records'])) ? 0 : 1;
278
+ $options['is_update_status'] = ( ! empty($options['is_keep_status']) ) ? 0 : 1;
279
+ $options['is_update_content'] = ( ! empty($options['is_keep_content'])) ? 0 : 1;
280
+ $options['is_update_title'] = ( ! empty($options['is_keep_title'])) ? 0 : 1;
281
+ $options['is_update_excerpt'] = ( ! empty($options['is_keep_excerpt'])) ? 0 : 1;
282
+ $options['is_update_categories'] = ( ! empty($options['is_keep_categories'])) ? 0 : 1;
283
+ $options['is_update_attachments'] = ( ! empty($options['is_keep_attachments_on_update'])) ? 0 : 1;
284
+ $options['is_update_images'] = ( ! empty($options['is_keep_images'])) ? 0 : 1;
285
+ $options['is_update_dates'] = ( ! empty($options['is_keep_dates'])) ? 0 : 1;
286
+ $options['is_update_menu_order'] = ( ! empty($options['is_keep_menu_order'])) ? 0 : 1;
287
+ $options['is_update_parent'] = ( ! empty($options['is_keep_parent'])) ? 0 : 1;
288
+ $options['is_update_custom_fields'] = ( ! empty($options['keep_custom_fields'])) ? 0 : 1;
289
+ if ("" != $options['keep_custom_fields_specific'] or "" != $options['keep_custom_fields_except']){
290
+ $options['custom_fields_list'] = ( ! empty($options['keep_custom_fields'])) ? explode(',', $options['keep_custom_fields_except']) : explode(',', $options['keep_custom_fields_specific']);
291
+ $options['update_custom_fields_logic'] = ( ! empty($options['is_update_custom_fields'])) ? 'only' : 'all_except';
292
+ }
293
+ if ( ! empty($options['is_keep_categories']) and ! empty($options['is_add_newest_categories'])){
294
+ $options['is_update_categories'] = 1;
295
+ $options['update_categories_logic'] = 'add_new';
296
+
297
+ }
298
+ $options['converted_options'] = 1;
299
+ $imp->set(array(
300
+ 'options' => $options
301
+ ))->update();
302
+
303
+ }
304
+ }
305
+
306
  }
307
 
308
  /**
430
  }
431
  }
432
  }
433
+
434
  return FALSE;
435
  }
436
 
564
  }
565
  }
566
 
567
+ public function __add_feed_type_fix(){
568
+
569
+ $table = $this->getTablePrefix() . 'imports';
570
+ global $wpdb;
571
+ $tablefields = $wpdb->get_results("DESCRIBE {$table};");
572
+ $parent_import_id = false;
573
+
574
+ // Check if field exists
575
+ foreach ($tablefields as $tablefield) {
576
+ if ('parent_import_id' == $tablefield->Field) $parent_import_id = true;
577
+ }
578
+
579
+ if (!$parent_import_id) $wpdb->query("ALTER TABLE {$table} ADD `parent_import_id` BIGINT(20) NOT NULL DEFAULT 0;");
580
+
581
+ }
582
+
583
  /**
584
  * Method returns default import options, main utility of the method is to avoid warnings when new
585
  * option is introduced but already registered imports don't have it
611
  'ping_status' => 'open',
612
  'create_draft' => 'no',
613
  'author' => '',
614
+ 'post_excerpt' => '',
615
+ 'post_slug' => '',
616
  'featured_image' => '',
617
  'attachments' => '',
618
  'is_import_specified' => 0,
622
  'unique_key' => '',
623
  'feed_type' => 'auto',
624
 
625
+ 'create_new_records' => 1,
626
  'is_delete_missing' => 0,
627
+ 'set_missing_to_draft' => 0,
628
  'is_update_missing_cf' => 0,
629
+ 'update_missing_cf_name' => '',
630
+ 'update_missing_cf_value' => '',
631
+
632
+ 'is_keep_former_posts' => 'no',
633
+ 'is_update_status' => 1,
634
+ 'is_update_content' => 1,
635
+ 'is_update_title' => 1,
636
+ 'is_update_slug' => 1,
637
+ 'is_update_excerpt' => 1,
638
+ 'is_update_categories' => 1,
639
+ 'update_categories_logic' => 'full_update',
640
+ 'taxonomies_list' => array(),
641
+ 'taxonomies_only_list' => array(),
642
+ 'taxonomies_except_list' => array(),
643
+ 'is_update_attachments' => 1,
644
+ 'is_update_images' => 1,
645
+ 'update_images_logic' => 'full_update',
646
+ 'is_update_dates' => 1,
647
+ 'is_update_menu_order' => 1,
648
+ 'is_update_parent' => 1,
649
  'is_keep_attachments' => 0,
650
+ 'is_keep_imgs' => 0,
651
+
652
+ 'is_update_custom_fields' => 1,
653
+ 'update_custom_fields_logic' => 'full_update',
654
+ 'custom_fields_list' => array(),
655
+ 'custom_fields_only_list' => array(),
656
+ 'custom_fields_except_list' => array(),
657
+
658
+ 'duplicate_matching' => 'auto',
659
+ 'duplicate_indicator' => 'title',
 
 
 
 
 
 
 
 
 
 
 
660
  'custom_duplicate_name' => '',
661
  'custom_duplicate_value' => '',
662
+ 'is_update_previous' => 0,
663
+ 'is_scheduled' => '',
664
+ 'scheduled_period' => '',
665
+ 'friendly_name' => '',
666
+ 'records_per_request' => 20,
667
  'auto_rename_images' => 0,
668
  'auto_rename_images_suffix' => '',
669
+ 'images_name' => 'filename',
 
670
  'post_format' => 'standard',
671
  'encoding' => 'UTF-8',
672
  'delimiter' => '',
680
  'image_meta_description' => '',
681
  'image_meta_description_delim' => '',
682
  'status_xpath' => '',
683
+ 'download_images' => 1,
684
+ 'converted_options' => 0,
685
+ 'update_all_data' => 'yes',
686
+ 'is_fast_mode' => 0,
687
+ 'chuncking' => 1,
688
+ 'import_processing' => 'ajax'
689
  );
690
  }
691
 
692
  /*
693
+ * Convert csv to xml
694
  */
695
  public static function csv_to_xml($csv_url){
696
 
readme.txt CHANGED
@@ -3,26 +3,29 @@ Contributors: soflyy
3
  Tags: wordpress, xml, csv, datafeed, import
4
  Requires at least: 3.6.1
5
  Tested up to: 3.8
6
- Stable tag: 3.0.4
7
 
8
- WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
9
 
10
  == Description ==
11
 
12
- WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
 
13
 
14
  WP All Import has a four step import process and an intuitive drag & drop interface that makes complicated import tasks simple and fast.
15
 
16
  There are no special requirements that the elements in your file must be laid out in a certain way. WP All Import really can import any XML or CSV file.
17
 
18
- WP All Import can be used for everything from building a store with an affiliate datafeed to displaying live stock quotes or sports scores to building a real estate portal.
 
 
19
 
20
  = WP All Import Professional Edition =
21
  [youtube http://www.youtube.com/watch?v=3LfbN7uWcTA /]
22
 
23
- *WP All Import Pro* is a $99 upgrade that adds the following features to the free version of WP All Import:
24
 
25
- * Import to Custom Post Types - commonly used to import to Automotiv, OpenHouse, Listings, and WooCommerce, as well as any other theme or plugin that makes use of Custom Post Types.
26
 
27
  * Cron Job/Recurring Imports - WP All Import pro can check periodically check a file for updates, and add, edit, and delete to the imported posts accordingly.
28
 
@@ -30,13 +33,11 @@ WP All Import can be used for everything from building a store with an affiliate
30
 
31
  * Import images to the post media gallery - WP All Import can download images from URLs in an XML or CSV file and put them in the media gallery.
32
 
33
- * Import files from a URL - Download and import files from external websites.
34
-
35
- * URL imports are integrated with the recurring/cron imports feature, so WP All Import can periodically re-download the files and add, edit, and delete posts accordingly.
36
 
37
  * Execution of Custom PHP Functions on data, i.e. use something like [my_function({xpath/to/a/field[1]})] in your template, to pass the value of {xpath/to/a/field[1]} to my_function and display whatever it returns.
38
 
39
- * Pro version customers also get access to e-mail technical support.
40
 
41
  [Upgrade to the professional edition of WP All Import.](http://www.wpallimport.com/upgrade-to-pro)
42
 
@@ -61,14 +62,15 @@ Either: -
61
  * Upload the plugin from the Plugins page in WordPress
62
  * Unzip wp-all-import.zip and upload the contents to /wp-content/plugins/, and then activate the plugin from the Plugins page in WordPress
63
 
 
 
64
 
65
  == Frequently Asked Questions ==
66
 
67
- *What Size Files Can WP All Import Handle?*
68
- With the release of WP All Import version 3, WP All Import can now handle files of any size and any number of records, as long as the web hosting provider can too. Typically, WP All Import can comfortably import files of 200Mb and larger in most shared hosting environments (HostGator, etc). Please see this page for more details: http://www.wpallimport.com/how-big
69
 
70
- *What are the benefits of the $99 professional version?*
71
- Support for Custom Post Types, Custom Taxonomies, Custom Fields, cron jobs/recurring imports, download and importing of images to the post media gallery, and URL uploads.
72
 
73
  *The answer to all of the following questions is yes:*
74
 
@@ -85,6 +87,16 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
85
 
86
  == Changelog ==
87
 
 
 
 
 
 
 
 
 
 
 
88
  = 3.0.4 =
89
  * Fixed import categories;
90
  * Updated UI/UX;
@@ -97,7 +109,7 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
97
  * Added support for the WooCommerce add-on
98
 
99
  = 3.0 =
100
- * Too many changes to list. It’s basically a new product compared to v2.
101
 
102
  = 2.14 =
103
  * Category list delimiter bug fix
3
  Tags: wordpress, xml, csv, datafeed, import
4
  Requires at least: 3.6.1
5
  Tested up to: 3.8
6
+ Stable tag: 3.1.0
7
 
8
+ WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
9
 
10
  == Description ==
11
 
12
+ *“It's a wonderful plugin that does so much, so well that it's hard to list all of the features. But I'll tell you this, I was able to import the content of a pair of websites running the ModX CMS into a WordPress install in less than 30 minutes. No joke!”*
13
+ **Alex Vasquez** - DigiSavvy Co-Founder & WordCamp Los Angeles Organizer
14
 
15
  WP All Import has a four step import process and an intuitive drag & drop interface that makes complicated import tasks simple and fast.
16
 
17
  There are no special requirements that the elements in your file must be laid out in a certain way. WP All Import really can import any XML or CSV file.
18
 
19
+ WP All Import can be used for everything from migrating content from a legacy CMS to WordPress to building a store with an affiliate datafeed to displaying live stock quotes or sports scores to building a real estate portal.
20
+
21
+ Our YouTube channel has many [videos showing WP All Import in action.](http://www.youtube.com/soflyyplugins) You may also enjoy our [documentation of advanced features.](http://www.wpallimport.com/documentation/) For technical support from the developers, please consider purchasing WP All Import Pro.
22
 
23
  = WP All Import Professional Edition =
24
  [youtube http://www.youtube.com/watch?v=3LfbN7uWcTA /]
25
 
26
+ *WP All Import Pro* is a paid upgrade that includes premium support and adds the following features:
27
 
28
+ * Import to Custom Post Types - commonly used to import to Automotiv, OpenHouse, Listings, as well as any other theme or plugin that makes use of Custom Post Types.
29
 
30
  * Cron Job/Recurring Imports - WP All Import pro can check periodically check a file for updates, and add, edit, and delete to the imported posts accordingly.
31
 
33
 
34
  * Import images to the post media gallery - WP All Import can download images from URLs in an XML or CSV file and put them in the media gallery.
35
 
36
+ * Import files from a URL - Download and import files from external websites, even if they are password protected with HTTP authentication. URL imports are integrated with the recurring/cron imports feature, so WP All Import can periodically re-download the files and add, edit, and delete posts accordingly.
 
 
37
 
38
  * Execution of Custom PHP Functions on data, i.e. use something like [my_function({xpath/to/a/field[1]})] in your template, to pass the value of {xpath/to/a/field[1]} to my_function and display whatever it returns.
39
 
40
+ * Pro version customers also get access to our customer portal with documentation and tutorials, and e-mail technical support.
41
 
42
  [Upgrade to the professional edition of WP All Import.](http://www.wpallimport.com/upgrade-to-pro)
43
 
62
  * Upload the plugin from the Plugins page in WordPress
63
  * Unzip wp-all-import.zip and upload the contents to /wp-content/plugins/, and then activate the plugin from the Plugins page in WordPress
64
 
65
+ Still need help? Read this excellent article: http://www.wpbeginner.com/beginners-guide/step-by-step-guide-to-install-a-wordpress-plugin-for-beginners/
66
+
67
 
68
  == Frequently Asked Questions ==
69
 
70
+ **What Size Files Can WP All Import Handle?**
71
+ It depends on your hosting provider’s settings. We’ve imported files of 200Mb and up, even on shared hosts. WP All Import splits your file into manageable chunks.
72
 
73
+ Various settings are available to make it possible to import larger files or speed up your import: http://www.wpallimport.com/documentation/step-4/import-processing/
 
74
 
75
  *The answer to all of the following questions is yes:*
76
 
87
 
88
  == Changelog ==
89
 
90
+ = 3.1.0 =
91
+ * Compatibility with WP 3.8
92
+ * Compatibility with WPAI WooCommerce add-on (paid) 1.2.4
93
+ * Performance Improvements
94
+ * Improved UI
95
+ * Lots of bug fixes
96
+ * New Record Matching section
97
+ * Added option to set Post Status with XPath (the value of presented XPath should be one of the following: publish, draft, trash)
98
+ * Preview navigation
99
+
100
  = 3.0.4 =
101
  * Fixed import categories;
102
  * Updated UI/UX;
109
  * Added support for the WooCommerce add-on
110
 
111
  = 3.0 =
112
+ * Free edition of 3.0 pro release
113
 
114
  = 2.14 =
115
  * Category list delimiter bug fix
schema.php CHANGED
@@ -40,22 +40,23 @@ CREATE TABLE {$table_prefix}templates (
40
  ) $charset_collate;
41
  CREATE TABLE {$table_prefix}imports (
42
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
 
43
  name VARCHAR(255) NOT NULL DEFAULT '',
44
  friendly_name VARCHAR(255) NOT NULL DEFAULT '',
45
  type VARCHAR(32) NOT NULL DEFAULT '',
46
- feed_type ENUM('xml','csv','zip','gz','') NOT NULL DEFAULT '',
47
  path TEXT,
48
  xpath TEXT,
49
  template LONGTEXT,
50
  options TEXT,
51
  scheduled VARCHAR(64) NOT NULL DEFAULT '',
52
- registered_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
53
- large_import ENUM('Yes','No') NOT NULL DEFAULT 'No',
54
  root_element VARCHAR(255) DEFAULT '',
55
  processing BOOL NOT NULL DEFAULT 0,
56
  triggered BOOL NOT NULL DEFAULT 0,
57
  queue_chunk_number BIGINT(20) NOT NULL DEFAULT 0,
58
- current_post_ids TEXT,
59
  first_import TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
60
  count BIGINT(20) NOT NULL DEFAULT 0,
61
  imported BIGINT(20) NOT NULL DEFAULT 0,
@@ -70,7 +71,7 @@ CREATE TABLE {$table_prefix}posts (
70
  import_id BIGINT(20) UNSIGNED NOT NULL,
71
  unique_key TEXT,
72
  product_key TEXT,
73
- PRIMARY KEY (id)
74
  ) $charset_collate;
75
  CREATE TABLE {$table_prefix}files (
76
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
40
  ) $charset_collate;
41
  CREATE TABLE {$table_prefix}imports (
42
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
43
+ parent_import_id BIGINT(20) NOT NULL DEFAULT 0,
44
  name VARCHAR(255) NOT NULL DEFAULT '',
45
  friendly_name VARCHAR(255) NOT NULL DEFAULT '',
46
  type VARCHAR(32) NOT NULL DEFAULT '',
47
+ feed_type ENUM('xml','csv','zip','gz','') NOT NULL DEFAULT '',
48
  path TEXT,
49
  xpath TEXT,
50
  template LONGTEXT,
51
  options TEXT,
52
  scheduled VARCHAR(64) NOT NULL DEFAULT '',
53
+ registered_on DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
54
+ large_import ENUM('Yes','No') NOT NULL DEFAULT 'No',
55
  root_element VARCHAR(255) DEFAULT '',
56
  processing BOOL NOT NULL DEFAULT 0,
57
  triggered BOOL NOT NULL DEFAULT 0,
58
  queue_chunk_number BIGINT(20) NOT NULL DEFAULT 0,
59
+ current_post_ids LONGBLOB,
60
  first_import TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
61
  count BIGINT(20) NOT NULL DEFAULT 0,
62
  imported BIGINT(20) NOT NULL DEFAULT 0,
71
  import_id BIGINT(20) UNSIGNED NOT NULL,
72
  unique_key TEXT,
73
  product_key TEXT,
74
+ PRIMARY KEY (id)
75
  ) $charset_collate;
76
  CREATE TABLE {$table_prefix}files (
77
  id BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
static/css/admin-wp-3.8.css ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .pmxi_plugin textarea, .pmxi_plugin .options input, .pmxi_plugin select, .pmxi_plugin p, .pmxi_plugin .wp_attachment_details label[for="content"]{
2
+ font-size: 12px !important;
3
+ }
4
+ .pmxi_plugin form.template .back{
5
+ top: 14px !important;
6
+ float: left;
7
+ }
8
+ .pmxi_plugin .submit-buttons .large_button{
9
+ font-size: 14px !important;
10
+ }
11
+ .pmxi_plugin .submit-buttons .large_button:hover{
12
+ vertical-align: baseline !important;
13
+ };
static/css/admin.css CHANGED
@@ -76,6 +76,7 @@
76
  /*line-height: 25px;
77
  height: 25px;*/
78
  min-height: 21px;
 
79
  }
80
  .pmxi_plugin div.input > * {
81
  vertical-align: middle;
@@ -83,6 +84,7 @@
83
  .pmxi_plugin .options input[type=text], .pmxi_plugin .options select {
84
  /*background: #fafafa !important;*/
85
  border: 1px solid #aaa !important;
 
86
  }
87
  .pmxi_plugin .note {
88
  color: #666666;
@@ -102,6 +104,7 @@
102
  .pmxi_plugin table.layout td {
103
  vertical-align: top;
104
  border: none;
 
105
  }
106
  .pmxi_plugin table.layout td.left {
107
  min-width: 490px;
@@ -259,7 +262,7 @@
259
  }
260
  .pmxi_plugin table.form-table td,
261
  .pmxi_plugin table.form-table th {
262
- padding: 0;
263
  vertical-align: top;
264
  }
265
  .pmxi_plugin .post-type-options table.form-table th {
@@ -305,6 +308,13 @@
305
  color: #464646;
306
  background: #DFDFDF;
307
  font-size: 12px;
 
 
 
 
 
 
 
308
  }
309
  .pmxi_plugin .tag .xml {
310
  max-height: 525px;
@@ -320,7 +330,7 @@
320
  }
321
  .pmxi_plugin .tag .navigation {
322
  float: right;
323
- margin: -2px -12px 0 0;
324
  }
325
  .pmxi_plugin .tag .navigation a,
326
  .pmxi_plugin .tag .navigation span {
@@ -905,12 +915,12 @@ table.xml table {
905
  color: red;
906
  text-align: center;
907
  }
908
- .pmxi_plugin #reimported_notify{
909
  border: 1px solid #AFAFAF;
910
  margin-bottom: 20px;
911
  padding: 10px 20px;
912
  }
913
- .pmxi_plugin #reimported_notify p span{
914
  color:#ccc;
915
  }
916
  .pmxi_plugin .action_buttons{
@@ -979,36 +989,34 @@ table.xml table {
979
  border: 1px solid #C5DBEC;*/
980
  height: 40px;
981
  line-height: 39px;
982
- margin-left: 10px;
983
  /*width: 90px;*/
984
  }
985
  .pmxi_plugin .drag-element .assign_post{
986
  float: left;
 
987
  }
988
  .pmxi_plugin .drag-element .widefat{
989
  margin-left: 1%;
990
  width: 85%;
991
  }
992
- .pmxi_plugin .upgrade_link{
993
- color: #21759B;
994
  }
995
- .pmxi_plugin .pmxi_stars{
996
- display: inline-block;
997
- background: url("../img/stars.png") no-repeat;
998
- width: 125px;
999
- height: 24px;
1000
- position: relative;
1001
- top:10px;
1002
  }
1003
- .pmxi_plugin .updated_bottom{
1004
- background-color: #FFFFE0;
1005
- border-color: #E6DB55;
1006
- margin: 5px 0 15px;
1007
- padding: 0 0.6em;
1008
- -moz-border-radius: 3px 3px 3px 3px;
1009
- border-radius: 3px;
1010
- border-style: solid;
1011
- border-width: 1px;
 
1012
  }
1013
  .pmxi_plugin .load_options{
1014
  height: 0;
@@ -1024,6 +1032,7 @@ table.xml table {
1024
  .pmxi_plugin .form-field textarea{
1025
  width:80%;
1026
  }
 
1027
  /* Tabs */
1028
  .pmxi_plugin .nav-tab-wrapper{
1029
  display: none;
@@ -1103,7 +1112,7 @@ table.xml table {
1103
  }
1104
  .pmxi_plugin .fix_checkbox{
1105
  position: relative;
1106
- /*top: -2px;*/
1107
  }
1108
  .pmxi_plugin .newline{
1109
  line-height: 16px;
@@ -1147,4 +1156,203 @@ table.xml table {
1147
  padding-left: 15px;
1148
  position: absolute;
1149
  top: 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1150
  }
76
  /*line-height: 25px;
77
  height: 25px;*/
78
  min-height: 21px;
79
+ font-size: 12px !important;
80
  }
81
  .pmxi_plugin div.input > * {
82
  vertical-align: middle;
84
  .pmxi_plugin .options input[type=text], .pmxi_plugin .options select {
85
  /*background: #fafafa !important;*/
86
  border: 1px solid #aaa !important;
87
+ font-size: 12px !important;
88
  }
89
  .pmxi_plugin .note {
90
  color: #666666;
104
  .pmxi_plugin table.layout td {
105
  vertical-align: top;
106
  border: none;
107
+ font-size: 12px !important;
108
  }
109
  .pmxi_plugin table.layout td.left {
110
  min-width: 490px;
262
  }
263
  .pmxi_plugin table.form-table td,
264
  .pmxi_plugin table.form-table th {
265
+ /*padding: 0;*/
266
  vertical-align: top;
267
  }
268
  .pmxi_plugin .post-type-options table.form-table th {
308
  color: #464646;
309
  background: #DFDFDF;
310
  font-size: 12px;
311
+ border-top: 1px solid #DFDFDF;
312
+ -moz-border-radius-topleft: 4px;
313
+ -webkit-border-top-left-radius: 4px;
314
+ border-top-left-radius: 4px;
315
+ -moz-border-radius-topright: 4px;
316
+ -webkit-border-top-right-radius: 4px;
317
+ border-top-right-radius: 4px;
318
  }
319
  .pmxi_plugin .tag .xml {
320
  max-height: 525px;
330
  }
331
  .pmxi_plugin .tag .navigation {
332
  float: right;
333
+ margin: 2px -12px 0 0;
334
  }
335
  .pmxi_plugin .tag .navigation a,
336
  .pmxi_plugin .tag .navigation span {
915
  color: red;
916
  text-align: center;
917
  }
918
+ .pmxi_plugin .reimported_notify{
919
  border: 1px solid #AFAFAF;
920
  margin-bottom: 20px;
921
  padding: 10px 20px;
922
  }
923
+ .pmxi_plugin .reimported_notify p span{
924
  color:#ccc;
925
  }
926
  .pmxi_plugin .action_buttons{
989
  border: 1px solid #C5DBEC;*/
990
  height: 40px;
991
  line-height: 39px;
992
+ margin-left: 10px;
993
  /*width: 90px;*/
994
  }
995
  .pmxi_plugin .drag-element .assign_post{
996
  float: left;
997
+ margin-top: 2px;
998
  }
999
  .pmxi_plugin .drag-element .widefat{
1000
  margin-left: 1%;
1001
  width: 85%;
1002
  }
1003
+ .pmxi_plugin .ui-tabs-hide{
1004
+ display: none !important;
1005
  }
1006
+ .pmxi_plugin .auto_nested{
1007
+ float: left;
1008
+ margin-left: 3px;
 
 
 
 
1009
  }
1010
+ .pmxi_plugin .existing_meta_values{
1011
+ clear: both;
1012
+ display: block;
1013
+ margin: 15px;
1014
+ }
1015
+ .pmxi_plugin .custom-params tr td{
1016
+ width: 50%;
1017
+ }
1018
+ .pmxi_plugin .custom-params tr td.action{
1019
+ width:100% !important;
1020
  }
1021
  .pmxi_plugin .load_options{
1022
  height: 0;
1032
  .pmxi_plugin .form-field textarea{
1033
  width:80%;
1034
  }
1035
+
1036
  /* Tabs */
1037
  .pmxi_plugin .nav-tab-wrapper{
1038
  display: none;
1112
  }
1113
  .pmxi_plugin .fix_checkbox{
1114
  position: relative;
1115
+ margin: 0px !important;
1116
  }
1117
  .pmxi_plugin .newline{
1118
  line-height: 16px;
1156
  padding-left: 15px;
1157
  position: absolute;
1158
  top: 0;
1159
+ }
1160
+ .pmxi_plugin .chosen-container-multi .chosen-choices li.search-field input[type="text"]{
1161
+ height: 25px !important;
1162
+ width: auto !important;
1163
+ }
1164
+ .pmxi_plugin .chosen-container-multi .chosen-choices{
1165
+ margin: 5px 0px !important;
1166
+ }
1167
+ .pmxi_plugin .pmxi_tips_pointer{
1168
+ position: absolute;
1169
+ right: 0;
1170
+ }
1171
+ .pmxi_plugin .wp-pointer-content{
1172
+ padding: 10px;
1173
+ }
1174
+ .pmxi_plugin .wp-pointer-content ul{
1175
+ margin-left: 20px;
1176
+ }
1177
+ .pmxi_plugin .processing_info{
1178
+ display: none;
1179
+ }
1180
+ .pmxi_plugin input[type="text"][name="tagno"]{
1181
+ margin-left: 5px;
1182
+ padding: 3px;
1183
+ width: 40px;
1184
+ border: 1px solid #BBBBBB;
1185
+ -moz-border-radius: 3px;
1186
+ -khtml-border-radius: 3px;
1187
+ -webkit-border-radius: 3px;
1188
+ border-radius: 3px;
1189
+ text-align: center;
1190
+ }
1191
+ #post-preview div.title{
1192
+ text-align:right;
1193
+ border-bottom: 2px solid #ccc;
1194
+ padding-bottom:5px;
1195
+ font-style:italic;
1196
+ }
1197
+ .pmxi_plugin .pl17{
1198
+ padding-left:17px;
1199
+ }
1200
+
1201
+ /*--------------------------------------------------------------------------
1202
+ *
1203
+ * Add-Ons
1204
+ *
1205
+ *-------------------------------------------------------------------------*/
1206
+
1207
+ .pmxi_plugin #pmxi-add-ons {
1208
+ margin-bottom: 20px;
1209
+ }
1210
+
1211
+ .pmxi_plugin .pmxi-add-on-group {
1212
+ margin-top: 20px;
1213
+ padding-top: 20px;
1214
+ border-top: #F5F5F5 solid 1px;
1215
+ }
1216
+
1217
+ .pmxi_plugin .pmxi-add-on-group:first-child {
1218
+ margin-top: 0;
1219
+ padding-top: 0;
1220
+ border-top: 0 none;
1221
+ }
1222
+
1223
+ .pmxi_plugin .pmxi-add-on {
1224
+ float: left;
1225
+ width: 220px;
1226
+ margin: 10px;
1227
+ }
1228
+
1229
+ .pmxi_plugin .pmxi-add-on h3 {
1230
+ margin-top: 0.5em;
1231
+ }
1232
+
1233
+ .pmxi_plugin .pmxi-add-on h3 a {
1234
+ color: inherit;
1235
+ text-decoration: none;
1236
+ }
1237
+
1238
+ .pmxi_plugin .pmxi-add-on .inner {
1239
+ min-height: 145px;
1240
+ }
1241
+
1242
+ .pmxi_plugin .pmxi-add-on-active .button {
1243
+ padding-left: 4px;
1244
+ }
1245
+
1246
+ .pmxi_plugin .pmxi-sprite-tick {
1247
+ width: 14px;
1248
+ height: 14px;
1249
+ margin: 4px 5px 0 0;
1250
+ background-position: 0px -300px;
1251
+ }
1252
+
1253
+ .pmxi_plugin .wp-box {
1254
+ background: none repeat scroll 0 0 #FFFFFF;
1255
+ border: 1px solid #E1E1E1;
1256
+ box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
1257
+ position: relative;
1258
+ }
1259
+ .pmxi_plugin .wp-box .inner {
1260
+ padding: 15px;
1261
+ }
1262
+ .pmxi_plugin .wp-box .footer{
1263
+ background: none repeat scroll 0 0 #F5F5F5;
1264
+ border-top: 1px solid #E1E1E1;
1265
+ overflow: hidden;
1266
+ padding: 10px;
1267
+ position: absolute;
1268
+ bottom:0;
1269
+ width:91%;
1270
+ }
1271
+
1272
+ #pmxi-add-ons .pmxi-add-on-title {
1273
+ float: left;
1274
+ width: 100%;
1275
+ margin: 25px 0 25px;
1276
+ border-top: #F5F5F5 solid 1px;
1277
+ }
1278
+ .pmxi_plugin .form-table td{
1279
+ padding: 0px;
1280
+ }
1281
+ .pmxi_plugin #pmxi_value{
1282
+ display: inline-block;
1283
+ height: 28px;
1284
+ margin: 0;
1285
+ padding: 3px;
1286
+ position: relative;
1287
+ top: 2px;
1288
+ width: 50px;
1289
+ }
1290
+ .pmxi_plugin #pmxi_add_rule{
1291
+ display: block;
1292
+ float: right;
1293
+ margin: 5px;
1294
+ }
1295
+ .pmxi_plugin #filtering_rules{
1296
+ border: 1px solid;
1297
+ margin: 15px 0;
1298
+ position: relative;
1299
+ }
1300
+ .pmxi_plugin .filtering_rules li{
1301
+ position: relative;
1302
+ }
1303
+ .pmxi_plugin .filtering_rules li .condition{
1304
+ padding: 2px;
1305
+ display: block;
1306
+ }
1307
+ .pmxi_plugin .filtering_rules li .condition label{
1308
+ margin: 0px 3px;
1309
+ }
1310
+ .pmxi_plugin .pmxi_group_rule{
1311
+ margin-left: -55px;
1312
+ }
1313
+ .pmxi_plugin #apply_filters{
1314
+ float: right;
1315
+ }
1316
+ .pmxi_plugin .filtering_rules li strong{
1317
+ text-transform: uppercase;
1318
+ }
1319
+ .pmxi_plugin #pmxi_xml_element{
1320
+ width:180px;
1321
+ }
1322
+ .pmxi_plugin div.input label, .pmxi_plugin .form-field{
1323
+ font-size: 12px !important;
1324
+ }
1325
+ .pmxi_plugin input[type="radio"]{
1326
+ margin-left: 4px;
1327
+ }
1328
+ .pmxi_plugin .main_choise{
1329
+ float: left;
1330
+ margin-right: 5px;
1331
+ padding: 5px 0;
1332
+ }
1333
+
1334
+ .pmxi_plugin .pmxi_stars{
1335
+ display: inline-block;
1336
+ background: url("../img/stars.png") no-repeat;
1337
+ width: 125px;
1338
+ height: 24px;
1339
+ position: relative;
1340
+ top:10px;
1341
+ }
1342
+ .pmxi_plugin .updated_bottom{
1343
+ background-color: #FFFFE0;
1344
+ border-color: #E6DB55;
1345
+ margin: 15px 0 15px;
1346
+ padding: 0 0.6em;
1347
+ -moz-border-radius: 3px 3px 3px 3px;
1348
+ border-radius: 3px;
1349
+ border-style: solid;
1350
+ border-width: 1px;
1351
+ }
1352
+ .pmxi_plugin .upgrade_link{
1353
+ color: #21759B;
1354
+ font-size: 1.3em;
1355
+ }
1356
+ .pmxi_plugin .ui-progressbar{
1357
+ height: 32px;
1358
  }
static/img/add-ons/acf-thumb.jpg ADDED
Binary file
static/img/add-ons/woo-commerce-thumb.jpg ADDED
Binary file
static/js/admin.js CHANGED
@@ -33,13 +33,70 @@
33
  $(this).attr('original-title', $(this).attr('title'));
34
  $(this).removeAttr('title');
35
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
 
37
  // swither show/hide logic
38
- $('input.switcher').change(function (e) {
 
39
  if ($(this).is(':radio:checked')) {
40
  $(this).parents('form').find('input.switcher:radio[name="' + $(this).attr('name') + '"]').not(this).change();
41
  }
42
  var $targets = $('.switcher-target-' + $(this).attr('id'));
 
43
  var is_show = $(this).is(':checked'); if ($(this).is('.switcher-reversed')) is_show = ! is_show;
44
  if (is_show) {
45
  $targets.fadeIn();
@@ -104,6 +161,15 @@
104
  $('form.no-enter-submit').find('input,select,textarea').not('*[type="submit"]').keydown(function (e) {
105
  if (13 == e.keyCode) e.preventDefault();
106
  });
 
 
 
 
 
 
 
 
 
107
 
108
  // choose file form: option selection dynamic
109
  // options form: highlight options of selected post type
@@ -117,10 +183,12 @@
117
  // template form: auto submit when `load template` list value is picked
118
  $('form.template, form.options').find('select[name="load_template"]').change(function () {
119
  $(this).parents('form').submit();
120
- });
 
121
  // template form: preview button
122
  $('form.template').each(function () {
123
  var $form = $(this);
 
124
  var set_encoding = false;
125
  var $modal = $('<div></div>').dialog({
126
  autoOpen: false,
@@ -137,6 +205,55 @@
137
  if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
138
  $.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
139
  $modal.removeClass('loading').html(response).dialog('option', 'position', 'center');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
140
  if (set_encoding){
141
  var $tag = $('.tag');
142
  $tag.addClass('loading').css('opacity', 0.7);
@@ -153,7 +270,7 @@
153
  }
154
  set_encoding = false;
155
  }, 'html');
156
- }
157
  });
158
  return false;
159
  });
@@ -352,10 +469,7 @@
352
  });
353
  var xpathChanged = function () {
354
  if ($input.val() == $input.data('checkedValue')) return;
355
- var xpath_elements = $input.val().split('[');
356
- var xpath_parts = xpath_elements[0].split('/');
357
- xpath_elements[0] = '';
358
- $input.val('/' + xpath_parts[xpath_parts.length - 1] + ((xpath_elements.length) ? xpath_elements.join('[') : ''));
359
  $form.addClass('loading');
360
  $form.find('.xml-element.selected').removeClass('selected'); // clear current selection
361
  // request server to return elements which correspond to xpath entered
@@ -364,21 +478,29 @@
364
  $xml.parents('fieldset:first').addClass('preload');
365
  go_to_template = false;
366
  $submit.hide();
367
- var evaluate = function(pointer, chunk){
368
- $.post('admin.php?page=pmxi-admin-import&action=evaluate', {xpath: $input.val(), show_element: $goto_element.val(), root_element:$root_element.val(), delimiter:$csv_delimiter.val(), pointer:pointer, chunk:chunk}, function (response) {
369
  if (response.result){
370
  $('.ajax-console').html(response.html);
371
  $input.attr('readonly', false).change(function(){$goto_element.val(1); xpathChanged();});
372
  $form.removeClass('loading');
373
  $xml.parents('fieldset:first').removeClass('preload');
374
- go_to_template = true;
375
- $submit.show();
 
 
 
 
376
  }
377
- else evaluate(response.pointer, response.chunk);
 
 
 
 
378
 
379
- }, "json");
380
  }
381
- evaluate(0, 0);
382
  };
383
  $next_element.live('click', function(){
384
  var matches_count = ($('.matches_count').length) ? parseInt($('.matches_count').html()) : 0;
@@ -394,9 +516,24 @@
394
  var show_element = Math.max(Math.min(parseInt($goto_element.val()), matches_count), 1);
395
  $goto_element.val(show_element); $input.data('checkedValue', ''); xpathChanged();
396
  });
397
- $get_default_xpath.click(function(){$root_element.val($(this).attr('root')); $goto_element.val(1); $input.val($(this).attr('rel')); xpathChanged();});
 
 
 
 
 
 
 
 
 
 
 
 
398
  $('.change_root_element').click(function(){
399
- $root_element.val($(this).attr('rel')); $goto_element.val(1); $input.val('/' + $(this).attr('rel')); xpathChanged();
 
 
 
400
  });
401
  $input.change(function(){$goto_element.val(1); xpathChanged();}).change();
402
  $input.keyup(function (e) {
@@ -409,6 +546,156 @@
409
  xpathChanged();
410
  }
411
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
  });
413
 
414
  $('form.choose-elements').find('input[type="submit"]').click(function(e){
@@ -442,6 +729,27 @@
442
  }, 'html');
443
  return false;
444
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
  });
446
  return this;
447
  };
@@ -501,7 +809,7 @@
501
  if (parent_td.find('input:first').val() == '') parent_td.find('.hierarhy-output').val('');
502
  });
503
 
504
- $('.add-new-ico').click(function(){
505
  var count = $(this).parents('tr:first').find('ol.sortable').find('li').length + 1;
506
  $(this).parents('tr:first').find('ol.sortable').append('<li id="item_'+count+'"><div class="drag-element"><input type="checkbox" class="assign_post" checked="checked"/><input type="text" value="" class="widefat"></div><a class="icon-item remove-ico" href="javascript:void(0);"></a></li>');
507
  $(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
@@ -522,12 +830,31 @@
522
  if ( ! $(this).is(':checked') && ! $(this).parents('.form-field:first').hasClass('template')){
523
  $(this).val('0').attr('checked','checked');
524
  }
525
- });
526
 
527
  $(this).parents('form:first').submit();
528
  });
529
 
530
- /* END Categories hierarchy */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
531
 
532
  // chunk files upload
533
  if ($('#plupload-ui').length)
@@ -557,54 +884,52 @@
557
 
558
  $('#large_import_toggle').click(function(){
559
  $('#large_import_xpath').slideToggle();
560
- });
561
 
562
- $('.pmxi_plugin').find('.nav-tab').click(function(){
563
- $('.nav-tab').removeClass('nav-tab-active');
564
- $(this).addClass('nav-tab-active');
565
- $('.pmxi_tab').hide();
566
- $('div#' + $(this).attr('rel')).fadeIn();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  });
568
 
569
- if ($('#pmxi_tabs').length){
570
- if ($('form.options').length){
571
- $('.nav-tab').removeClass('nav-tab-active');
572
- if ($('#selected_post_type').val() != ''){
573
- var post_type_founded = false;
574
- $('.pmxi_tab').hide();
575
- $('input[name=custom_type]').each(function(i){
576
- if ($(this).val() == $('#selected_post_type').val()) {
577
- $('.nav-tab[rel='+ $(this).val() +']').addClass('nav-tab-active');
578
- $(this).parents('.pmxi_tab:first').show();
579
- post_type_founded = true;
580
- }
581
- });
582
- if ( ! post_type_founded){
583
- if ($('#selected_type').val() == 'post'){
584
- $('.nav-tab[rel=posts]').addClass('nav-tab-active');
585
- $('div#posts').show();
586
- }
587
- else{
588
- $('.nav-tab[rel=pages]').addClass('nav-tab-active');
589
- $('div#pages').show();
590
- }
591
- }
592
- }
593
- else if ($('#selected_type').val() != ''){
594
- if ($('#selected_type').val() == 'post'){
595
- $('.nav-tab[rel=posts]').addClass('nav-tab-active');
596
- $('div#posts').show();
597
- }
598
- else{
599
- $('.nav-tab[rel=pages]').addClass('nav-tab-active');
600
- $('div#pages').show();
601
- }
602
- }
603
- $('.nav-tab-wrapper').show();
604
  }
605
- else
606
- $('#pmxi_tabs').tabs().show();
607
- }
608
 
609
  if ($('#upload_process').length){
610
  $('#upload_process').progressbar({ value: (($('#progressbar').html() != '') ? 100 : 0) });
@@ -657,5 +982,26 @@
657
  $('input[name=keep_custom_fields]').click(function(){
658
  $(this).parents('.input:first').find('.keep_except').slideToggle();
659
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
660
 
661
  });})(jQuery);
33
  $(this).attr('original-title', $(this).attr('title'));
34
  $(this).removeAttr('title');
35
  });
36
+
37
+ if ($('#pmxi_tabs').length){
38
+ if ($('form.options').length){
39
+ $('.nav-tab').removeClass('nav-tab-active');
40
+ if ($('#selected_post_type').val() != ''){
41
+ var post_type_founded = false;
42
+ $('.pmxi_tab').hide();
43
+ $('input[name=custom_type]').each(function(i){
44
+ if ($(this).val() == $('#selected_post_type').val()) {
45
+ $('.nav-tab[rel='+ $(this).val() +']').addClass('nav-tab-active');
46
+ $(this).parents('.pmxi_tab:first').show();
47
+ post_type_founded = true;
48
+ }
49
+ });
50
+ if ( ! post_type_founded){
51
+ if ($('#selected_type').val() == 'post'){
52
+ $('.nav-tab[rel=posts]').addClass('nav-tab-active');
53
+ $('div#posts').show();
54
+ }
55
+ else{
56
+ $('.nav-tab[rel=pages]').addClass('nav-tab-active');
57
+ $('div#pages').show();
58
+ }
59
+ }
60
+ }
61
+ else if ($('#selected_type').val() != ''){
62
+ if ($('#selected_type').val() == 'post'){
63
+ $('.nav-tab[rel=posts]').addClass('nav-tab-active');
64
+ $('div#posts').show();
65
+ }
66
+ else{
67
+ $('.nav-tab[rel=pages]').addClass('nav-tab-active');
68
+ $('div#pages').show();
69
+ }
70
+ }
71
+ $('.nav-tab-wrapper').show();
72
+ }
73
+ else
74
+ $('#pmxi_tabs').tabs().show();
75
+ }
76
+
77
+ $('.pmxi_plugin').find('.nav-tab').click(function(){
78
+ $('.nav-tab').removeClass('nav-tab-active');
79
+ $(this).addClass('nav-tab-active');
80
+ $('.pmxi_tab').hide();
81
+ $('div#' + $(this).attr('rel')).fadeIn();
82
+
83
+ if ( parseInt($('div#' + $(this).attr('rel')).find('.is_disabled').val()) ) {
84
+ $('div#' + $(this).attr('rel')).find('input, select, textarea').attr('disabled','disabled');
85
+ }
86
+ else {
87
+ $('div#' + $(this).attr('rel')).find('input, select, textarea').removeAttr('disabled');
88
+ }
89
+
90
+ });
91
 
92
  // swither show/hide logic
93
+ $('input.switcher').live('change', function (e) {
94
+
95
  if ($(this).is(':radio:checked')) {
96
  $(this).parents('form').find('input.switcher:radio[name="' + $(this).attr('name') + '"]').not(this).change();
97
  }
98
  var $targets = $('.switcher-target-' + $(this).attr('id'));
99
+
100
  var is_show = $(this).is(':checked'); if ($(this).is('.switcher-reversed')) is_show = ! is_show;
101
  if (is_show) {
102
  $targets.fadeIn();
161
  $('form.no-enter-submit').find('input,select,textarea').not('*[type="submit"]').keydown(function (e) {
162
  if (13 == e.keyCode) e.preventDefault();
163
  });
164
+
165
+ // enter-submit form on step 1
166
+ if ($('.pmxi_step_1').length){
167
+ $('body').keydown(function (e) {
168
+ if (13 == e.keyCode){
169
+ $('form.choose-file').submit();
170
+ }
171
+ });
172
+ }
173
 
174
  // choose file form: option selection dynamic
175
  // options form: highlight options of selected post type
183
  // template form: auto submit when `load template` list value is picked
184
  $('form.template, form.options').find('select[name="load_template"]').change(function () {
185
  $(this).parents('form').submit();
186
+ });
187
+
188
  // template form: preview button
189
  $('form.template').each(function () {
190
  var $form = $(this);
191
+ var $preview = $('#post-preview');
192
  var set_encoding = false;
193
  var $modal = $('<div></div>').dialog({
194
  autoOpen: false,
205
  if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
206
  $.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
207
  $modal.removeClass('loading').html(response).dialog('option', 'position', 'center');
208
+ var $tag = $('.tag');
209
+ var tagno = parseInt($tag.find('input[name="tagno"]').val());
210
+ $preview.find('.navigation a').live('click', function () {
211
+ tagno += '#prev' == $(this).attr('href') ? -1 : 1;
212
+ $tag.addClass('loading').css('opacity', 0.7);
213
+ $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
214
+ var $indicator = $('<span />').insertBefore($tag);
215
+ $tag.replaceWith(data);
216
+ $indicator.next().tag().prevObject.remove();
217
+ if ($('#variations_xpath').length){
218
+ $('#variations_xpath').data('checkedValue', '').change();
219
+ }
220
+ if ($('.layout').length){
221
+ var offset = $('.layout').offset();
222
+ if ($(document).scrollTop() > offset.top)
223
+ $('.tag').css({'top':(($(document).scrollTop() - offset.top) ? $(document).scrollTop() - offset.top : 0) + 'px'});
224
+ else
225
+ $('.tag').css({'top':''});
226
+ }
227
+ $preview.find('input[name="tagno"]').die();
228
+ $preview.find('.navigation a').die('click');
229
+ $form.find('.preview').click();
230
+ }, 'html');
231
+ return false;
232
+ });
233
+ $preview.find('input[name="tagno"]').live('change', function () {
234
+ tagno = (parseInt($(this).val()) > parseInt($preview.find('.pmxi_count').html())) ? $preview.find('.pmxi_count').html() : ( (parseInt($(this).val())) ? $(this).val() : 1 );
235
+ $tag.addClass('loading').css('opacity', 0.7);
236
+ $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
237
+ var $indicator = $('<span />').insertBefore($tag);
238
+ $tag.replaceWith(data);
239
+ $indicator.next().tag().prevObject.remove();
240
+ if ($('#variations_xpath').length){
241
+ $('#variations_xpath').data('checkedValue', '').change();
242
+ }
243
+ if ($('.layout').length){
244
+ var offset = $('.layout').offset();
245
+ if ($(document).scrollTop() > offset.top)
246
+ $('.tag').css({'top':(($(document).scrollTop() - offset.top) ? $(document).scrollTop() - offset.top : 0) + 'px'});
247
+ else
248
+ $('.tag').css({'top':''});
249
+ }
250
+ $preview.find('input[name="tagno"]').die();
251
+ $preview.find('.navigation a').die('click');
252
+ $form.find('.preview').click();
253
+ }, 'html');
254
+ return false;
255
+ });
256
+
257
  if (set_encoding){
258
  var $tag = $('.tag');
259
  $tag.addClass('loading').css('opacity', 0.7);
270
  }
271
  set_encoding = false;
272
  }, 'html');
273
+ }
274
  });
275
  return false;
276
  });
469
  });
470
  var xpathChanged = function () {
471
  if ($input.val() == $input.data('checkedValue')) return;
472
+
 
 
 
473
  $form.addClass('loading');
474
  $form.find('.xml-element.selected').removeClass('selected'); // clear current selection
475
  // request server to return elements which correspond to xpath entered
478
  $xml.parents('fieldset:first').addClass('preload');
479
  go_to_template = false;
480
  $submit.hide();
481
+ var evaluate = function(){
482
+ $.post('admin.php?page=pmxi-admin-import&action=evaluate', {xpath: $input.val(), show_element: $goto_element.val(), root_element:$root_element.val(), delimiter:$csv_delimiter.val()}, function (response) {
483
  if (response.result){
484
  $('.ajax-console').html(response.html);
485
  $input.attr('readonly', false).change(function(){$goto_element.val(1); xpathChanged();});
486
  $form.removeClass('loading');
487
  $xml.parents('fieldset:first').removeClass('preload');
488
+ go_to_template = true;
489
+ $('#pmxi_xml_element').find('option').each(function(){
490
+ if ($(this).val() != "") $(this).remove();
491
+ });
492
+ $('#pmxi_xml_element').append(response.render_element);
493
+ $submit.show();
494
  }
495
+ }, "json").fail(function() {
496
+
497
+ $xml.parents('fieldset:first').removeClass('preload');
498
+ $form.removeClass('loading');
499
+ $('.ajax-console').html('<div class="error inline"><p>No matching elements found for XPath expression specified.</p></div>');
500
 
501
+ });
502
  }
503
+ evaluate();
504
  };
505
  $next_element.live('click', function(){
506
  var matches_count = ($('.matches_count').length) ? parseInt($('.matches_count').html()) : 0;
516
  var show_element = Math.max(Math.min(parseInt($goto_element.val()), matches_count), 1);
517
  $goto_element.val(show_element); $input.data('checkedValue', ''); xpathChanged();
518
  });
519
+
520
+ var reset_filters = function(){
521
+ $('#apply_filters').hide();
522
+ $('.filtering_rules').empty();
523
+ $('#filtering_rules').find('p').show();
524
+ }
525
+
526
+ $get_default_xpath.click(function(){
527
+ $input.val($(this).attr('rel'));
528
+ if ($input.val() == $input.data('checkedValue')) return;
529
+ reset_filters();
530
+ $root_element.val($(this).attr('root')); $goto_element.val(1); xpathChanged();
531
+ });
532
  $('.change_root_element').click(function(){
533
+ $input.val('/' + $(this).attr('rel'));
534
+ if ($input.val() == $input.data('checkedValue')) return;
535
+ reset_filters();
536
+ $root_element.val($(this).attr('rel')); $goto_element.val(1); xpathChanged();
537
  });
538
  $input.change(function(){$goto_element.val(1); xpathChanged();}).change();
539
  $input.keyup(function (e) {
546
  xpathChanged();
547
  }
548
  });
549
+
550
+ /* Advanced Filtering */
551
+
552
+ $('.filtering_rules').nestedSortable({
553
+ handle: 'div',
554
+ items: 'li',
555
+ toleranceElement: '> div',
556
+ update: function () {
557
+ $('.filtering_rules').find('.condition').show();
558
+ $('.filtering_rules').find('.condition:last').hide();
559
+ }
560
+ });
561
+
562
+ $('#pmxi_add_rule').click(function(){
563
+
564
+ var $el = $('#pmxi_xml_element');
565
+ var $rule = $('#pmxi_rule');
566
+ var $val = $('#pmxi_value');
567
+
568
+ if ($el.val() == "" || $rule.val() == "") return;
569
+
570
+ if ($rule.val() != 'is_empty' && $rule.val() != "is_not_empty" && $val.val() == "") return;
571
+
572
+ var relunumber = $('.filtering_rules').find('li').length;
573
+
574
+ var html = '<li><div class="drag-element">';
575
+ html += '<input type="hidden" value="'+ $el.val() +'" class="pmxi_xml_element"/>';
576
+ html += '<input type="hidden" value="'+ $rule.val() +'" class="pmxi_rule"/>';
577
+ html += '<input type="hidden" value="'+ $val.val() +'" class="pmxi_value"/>';
578
+ html += '<span>' + $el.val() + ' <strong>' + $rule.find('option:selected').html() + '</strong> "' + $val.val() +'"</span>';
579
+ html += '<span class="condition"> <label for="rule_and_'+relunumber+'">AND</label><input id="rule_and_'+relunumber+'" type="radio" value="and" name="rule_'+relunumber+'" checked="checked" class="rule_condition"/><label for="rule_or_'+relunumber+'">OR</label><input id="rule_or_'+relunumber+'" type="radio" value="or" name="rule_'+relunumber+'" class="rule_condition"/> </span>';
580
+ html += '</div><a href="javascript:void(0);" class="icon-item remove-ico"></a></li>';
581
+
582
+ $('#apply_filters').show();
583
+ $('#filtering_rules').find('p').hide();
584
+
585
+ $('.filtering_rules').append(html);
586
+
587
+ $('.filtering_rules').find('.condition').show();
588
+ $('.filtering_rules').find('.condition:last').hide();
589
+
590
+ $el.prop('selectedIndex',0);
591
+ $rule.prop('selectedIndex',0);
592
+ $val.val('');
593
+ $('#pmxi_value').show();
594
+
595
+ });
596
+
597
+ $('.filtering_rules').find('.remove-ico').live('click', function(){
598
+ $(this).parents('li:first').remove();
599
+ if (!$('.filtering_rules').find('li').length){
600
+ $('#apply_filters').hide();
601
+ $('#filtering_rules').find('p').show();
602
+ }
603
+ });
604
+
605
+ $('#pmxi_rule').change(function(){
606
+ if ($(this).val() == 'is_empty' || $(this).val() == 'is_not_empty')
607
+ $('#pmxi_value').hide();
608
+ else
609
+ $('#pmxi_value').show();
610
+ });
611
+
612
+ var filter = '[';
613
+
614
+ var xpath_builder = function(rules_box, lvl){
615
+
616
+ var rules = rules_box.children('li');
617
+
618
+ if (lvl && rules.length > 1) filter += ' (';
619
+
620
+ rules.each(function(){
621
+
622
+ var node = $(this).children('.drag-element').find('.pmxi_xml_element').val();
623
+ var condition = $(this).children('.drag-element').find('.pmxi_rule').val();
624
+ var value = $(this).children('.drag-element').find('.pmxi_value').val();
625
+
626
+ var clause = ($(this).children('.drag-element').find('.condition').is(':visible')) ? $(this).children('.drag-element').find('input.rule_condition:checked').val() : false;
627
+
628
+ var is_attr = false;
629
+
630
+ if (node.indexOf('@') != -1){
631
+ is_attr = true;
632
+ node_name = node.split('@')[0];
633
+ attr_name = node.split('@')[1];
634
+ }
635
+
636
+ filter += (is_attr) ? node_name.replace(/->/g, '/') : node.replace(/->/g, '/');
637
+
638
+ if (is_attr) filter += '[@' + attr_name;
639
+
640
+ switch (condition){
641
+ case 'equals':
642
+ filter += ' = %s';
643
+ break;
644
+ case 'greater':
645
+ filter += ' > %s';
646
+ break;
647
+ case 'equals_or_greater':
648
+ filter += ' >= %s';
649
+ break;
650
+ case 'less':
651
+ filter += ' < %s';
652
+ break;
653
+ case 'equals_or_less':
654
+ filter += ' =< %s';
655
+ break;
656
+ case 'contains':
657
+ filter += '[contains(.,"%s")]';
658
+ break;
659
+ case 'is_empty':
660
+ filter += '[not(text())]';
661
+ break;
662
+ case 'is_not_empty':
663
+ filter += '[text()]';
664
+ break;
665
+ }
666
+
667
+ filter = filter.replace('%s', value);
668
+
669
+ if (is_attr) filter += ']';
670
+
671
+ if (clause) filter += ' ' + clause + ' ';
672
+
673
+ if ($(this).children('ol').length){
674
+ $(this).children('ol').each(function(){
675
+ if ($(this).children('li').length) xpath_builder($(this), 1);
676
+ });
677
+ }
678
+ });
679
+
680
+ if (lvl && rules.length > 1) filter += ') ';
681
+
682
+ }
683
+
684
+ $('#apply_filters').click(function(){
685
+
686
+ var xpath = $('input[name=xpath]').val();
687
+
688
+ filter = '[';
689
+
690
+ xpath_builder($('.filtering_rules'), 0);
691
+
692
+ filter += ']';
693
+
694
+ $input.val( $input.val().split('[')[0] + filter);
695
+
696
+ $input.data('checkedValue', ''); xpathChanged();
697
+
698
+ });
699
  });
700
 
701
  $('form.choose-elements').find('input[type="submit"]').click(function(e){
729
  }, 'html');
730
  return false;
731
  });
732
+ $tag.find('input[name="tagno"]').live('change', function () {
733
+ tagno = (parseInt($(this).val()) > parseInt($tag.find('.pmxi_count').html())) ? $tag.find('.pmxi_count').html() : ( (parseInt($(this).val())) ? $(this).val() : 1 );
734
+ $(this).val(tagno);
735
+ $tag.addClass('loading').css('opacity', 0.7);
736
+ $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
737
+ var $indicator = $('<span />').insertBefore($tag);
738
+ $tag.replaceWith(data);
739
+ $indicator.next().tag().prevObject.remove();
740
+ if ($('#variations_xpath').length){
741
+ $('#variations_xpath').data('checkedValue', '').change();
742
+ }
743
+ if ($('.layout').length){
744
+ var offset = $('.layout').offset();
745
+ if ($(document).scrollTop() > offset.top)
746
+ $('.tag').css({'top':(($(document).scrollTop() - offset.top) ? $(document).scrollTop() - offset.top : 0) + 'px'});
747
+ else
748
+ $('.tag').css({'top':''});
749
+ }
750
+ }, 'html');
751
+ return false;
752
+ });
753
  });
754
  return this;
755
  };
809
  if (parent_td.find('input:first').val() == '') parent_td.find('.hierarhy-output').val('');
810
  });
811
 
812
+ $('.add-new-ico').live('click', function(){
813
  var count = $(this).parents('tr:first').find('ol.sortable').find('li').length + 1;
814
  $(this).parents('tr:first').find('ol.sortable').append('<li id="item_'+count+'"><div class="drag-element"><input type="checkbox" class="assign_post" checked="checked"/><input type="text" value="" class="widefat"></div><a class="icon-item remove-ico" href="javascript:void(0);"></a></li>');
815
  $(this).parents('td:first').find('.hierarhy-output').val(window.JSON.stringify($(this).parents('.sortable:first').nestedSortable('toArray', {startDepthCount: 0})));
830
  if ( ! $(this).is(':checked') && ! $(this).parents('.form-field:first').hasClass('template')){
831
  $(this).val('0').attr('checked','checked');
832
  }
833
+ });
834
 
835
  $(this).parents('form:first').submit();
836
  });
837
 
838
+ /* END Categories hierarchy */
839
+
840
+ // manage screen: cron url
841
+ $('.get_cron_url').each(function () {
842
+ var $form = $(this);
843
+ var $modal = $('<div></div>').dialog({
844
+ autoOpen: false,
845
+ modal: true,
846
+ title: 'Cron URLs',
847
+ width: 760,
848
+ maxHeight: 600,
849
+ open: function(event, ui) {
850
+ $(this).dialog('option', 'height', 'auto').css({'max-height': $(this).dialog('option', 'maxHeight') - $(this).prev().height() - 24, 'overflow-y': 'auto'});
851
+ }
852
+ });
853
+ $form.find('a').click(function () {
854
+ $modal.addClass('loading').empty().dialog('open').dialog('option', 'position', 'center');
855
+ $modal.removeClass('loading').html('<textarea style="width:100%; height:100%;">' + $form.find('a').attr('rel') + '</textarea>').dialog('option', 'position', 'center');
856
+ });
857
+ });
858
 
859
  // chunk files upload
860
  if ($('#plupload-ui').length)
884
 
885
  $('#large_import_toggle').click(function(){
886
  $('#large_import_xpath').slideToggle();
887
+ });
888
 
889
+ // Step 4 - custom meta keys helper
890
+ $('.existing_meta_keys').change(function(){
891
+ var parent_fieldset = $(this).parents('fieldset');
892
+ var key = $(this).find('option:selected').val();
893
+
894
+ if ("" != $(this).val()) {
895
+ parent_fieldset.find('input[name^=custom_name]:visible').each(function(){
896
+ if ("" == $(this).val()) $(this).parents('tr:first').remove();
897
+ });
898
+ parent_fieldset.find('a.action[href="#add"]').click();
899
+ parent_fieldset.find('input[name^=custom_name]:visible:last').val($(this).val());
900
+
901
+ $(this).prop('selectedIndex',0);
902
+
903
+ parent_fieldset.addClass('loading');
904
+
905
+ $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: key}, function (data) {
906
+
907
+ parent_fieldset.find('input[name^=custom_name]:visible:last').after(data);
908
+
909
+ parent_fieldset.removeClass('loading');
910
+
911
+ }, 'html');
912
+ }
913
  });
914
 
915
+ $('input[name^=custom_name]').live('change', function(){
916
+ var $ths = $(this);
917
+ $ths.parents('fieldset:first').addClass('loading');
918
+ $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: $ths.val()}, function (data) {
919
+ $ths.nextAll().remove();
920
+ $ths.after(data);
921
+ $ths.parents('fieldset:first').removeClass('loading');
922
+ }, 'html');
923
+
924
+ });
925
+
926
+ $('.existing_meta_values').live('change', function(){
927
+ var parent_fieldset = $(this).parents('.form-field:first');
928
+ if ($(this).val() != ""){
929
+ parent_fieldset.find('textarea').val($(this).val());
930
+ $(this).prop('selectedIndex', 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
931
  }
932
+ });
 
 
933
 
934
  if ($('#upload_process').length){
935
  $('#upload_process').progressbar({ value: (($('#progressbar').html() != '') ? 100 : 0) });
982
  $('input[name=keep_custom_fields]').click(function(){
983
  $(this).parents('.input:first').find('.keep_except').slideToggle();
984
  });
985
+
986
+ $('.pmxi_choosen').each(function(){
987
+ $(this).find(".choosen_input").select2({tags: $(this).find('.choosen_values').html().split(',')});
988
+ });
989
+
990
+ $('.pmxi_tips_pointer').click(function(){
991
+ $(this).pointer({
992
+ content: $('#record_matching_pointer').html(),
993
+ position: {
994
+ edge: 'right',
995
+ align: 'center'
996
+ },
997
+ pointerWidth: 715,
998
+ close: function() {
999
+ $.post( ajaxurl, {
1000
+ pointer: 'pksn1',
1001
+ action: 'dismiss-wp-pointer'
1002
+ });
1003
+ }
1004
+ }).pointer('open');
1005
+ });
1006
 
1007
  });})(jQuery);
static/js/jquery/css/select2/select2-bootstrap.css ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .form-control .select2-choice {
2
+ border: 0;
3
+ border-radius: 2px;
4
+ }
5
+
6
+ .form-control .select2-choice .select2-arrow {
7
+ border-radius: 0 2px 2px 0;
8
+ }
9
+
10
+ .form-control.select2-container {
11
+ height: auto !important;
12
+ padding: 0px;
13
+ }
14
+
15
+ .form-control.select2-container.select2-dropdown-open {
16
+ border-color: #5897FB;
17
+ border-radius: 3px 3px 0 0;
18
+ }
19
+
20
+ .form-control .select2-container.select2-dropdown-open .select2-choices {
21
+ border-radius: 3px 3px 0 0;
22
+ }
23
+
24
+ .form-control.select2-container .select2-choices {
25
+ border: 0 !important;
26
+ border-radius: 3px;
27
+ }
28
+
29
+ .control-group.warning .select2-container .select2-choice,
30
+ .control-group.warning .select2-container .select2-choices,
31
+ .control-group.warning .select2-container-active .select2-choice,
32
+ .control-group.warning .select2-container-active .select2-choices,
33
+ .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choice,
34
+ .control-group.warning .select2-dropdown-open.select2-drop-above .select2-choices,
35
+ .control-group.warning .select2-container-multi.select2-container-active .select2-choices {
36
+ border: 1px solid #C09853 !important;
37
+ }
38
+
39
+ .control-group.warning .select2-container .select2-choice div {
40
+ border-left: 1px solid #C09853 !important;
41
+ background: #FCF8E3 !important;
42
+ }
43
+
44
+ .control-group.error .select2-container .select2-choice,
45
+ .control-group.error .select2-container .select2-choices,
46
+ .control-group.error .select2-container-active .select2-choice,
47
+ .control-group.error .select2-container-active .select2-choices,
48
+ .control-group.error .select2-dropdown-open.select2-drop-above .select2-choice,
49
+ .control-group.error .select2-dropdown-open.select2-drop-above .select2-choices,
50
+ .control-group.error .select2-container-multi.select2-container-active .select2-choices {
51
+ border: 1px solid #B94A48 !important;
52
+ }
53
+
54
+ .control-group.error .select2-container .select2-choice div {
55
+ border-left: 1px solid #B94A48 !important;
56
+ background: #F2DEDE !important;
57
+ }
58
+
59
+ .control-group.info .select2-container .select2-choice,
60
+ .control-group.info .select2-container .select2-choices,
61
+ .control-group.info .select2-container-active .select2-choice,
62
+ .control-group.info .select2-container-active .select2-choices,
63
+ .control-group.info .select2-dropdown-open.select2-drop-above .select2-choice,
64
+ .control-group.info .select2-dropdown-open.select2-drop-above .select2-choices,
65
+ .control-group.info .select2-container-multi.select2-container-active .select2-choices {
66
+ border: 1px solid #3A87AD !important;
67
+ }
68
+
69
+ .control-group.info .select2-container .select2-choice div {
70
+ border-left: 1px solid #3A87AD !important;
71
+ background: #D9EDF7 !important;
72
+ }
73
+
74
+ .control-group.success .select2-container .select2-choice,
75
+ .control-group.success .select2-container .select2-choices,
76
+ .control-group.success .select2-container-active .select2-choice,
77
+ .control-group.success .select2-container-active .select2-choices,
78
+ .control-group.success .select2-dropdown-open.select2-drop-above .select2-choice,
79
+ .control-group.success .select2-dropdown-open.select2-drop-above .select2-choices,
80
+ .control-group.success .select2-container-multi.select2-container-active .select2-choices {
81
+ border: 1px solid #468847 !important;
82
+ }
83
+
84
+ .control-group.success .select2-container .select2-choice div {
85
+ border-left: 1px solid #468847 !important;
86
+ background: #DFF0D8 !important;
87
+ }
static/js/jquery/css/select2/select2-spinner.gif ADDED
Binary file
static/js/jquery/css/select2/select2.css ADDED
@@ -0,0 +1,617 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
3
+ */
4
+ .select2-container {
5
+ margin: 0;
6
+ position: relative;
7
+ display: inline-block;
8
+ /* inline-block for ie7 */
9
+ zoom: 1;
10
+ *display: inline;
11
+ vertical-align: middle;
12
+ width:100%;
13
+ }
14
+
15
+ .select2-container,
16
+ .select2-drop,
17
+ .select2-search,
18
+ .select2-search input {
19
+ /*
20
+ Force border-box so that % widths fit the parent
21
+ container without overlap because of margin/padding.
22
+
23
+ More Info : http://www.quirksmode.org/css/box.html
24
+ */
25
+ -webkit-box-sizing: border-box; /* webkit */
26
+ -moz-box-sizing: border-box; /* firefox */
27
+ box-sizing: border-box; /* css3 */
28
+ }
29
+
30
+ .select2-container .select2-choice {
31
+ display: block;
32
+ height: 26px;
33
+ padding: 0 0 0 8px;
34
+ overflow: hidden;
35
+ position: relative;
36
+
37
+ border: 1px solid #aaa;
38
+ white-space: nowrap;
39
+ line-height: 26px;
40
+ color: #444;
41
+ text-decoration: none;
42
+
43
+ border-radius: 4px;
44
+
45
+ background-clip: padding-box;
46
+
47
+ -webkit-touch-callout: none;
48
+ -webkit-user-select: none;
49
+ -moz-user-select: none;
50
+ -ms-user-select: none;
51
+ user-select: none;
52
+
53
+ background-color: #fff;
54
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
55
+ background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
56
+ background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
57
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
58
+ background-image: linear-gradient(top, #fff 0%, #eee 50%);
59
+ }
60
+
61
+ .select2-container.select2-drop-above .select2-choice {
62
+ border-bottom-color: #aaa;
63
+
64
+ border-radius: 0 0 4px 4px;
65
+
66
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
67
+ background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
68
+ background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
69
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
70
+ background-image: linear-gradient(top, #eee 0%, #fff 90%);
71
+ }
72
+
73
+ .select2-container.select2-allowclear .select2-choice .select2-chosen {
74
+ margin-right: 42px;
75
+ }
76
+
77
+ .select2-container .select2-choice > .select2-chosen {
78
+ margin-right: 26px;
79
+ display: block;
80
+ overflow: hidden;
81
+
82
+ white-space: nowrap;
83
+
84
+ text-overflow: ellipsis;
85
+ }
86
+
87
+ .select2-container .select2-choice abbr {
88
+ display: none;
89
+ width: 12px;
90
+ height: 12px;
91
+ position: absolute;
92
+ right: 24px;
93
+ top: 8px;
94
+
95
+ font-size: 1px;
96
+ text-decoration: none;
97
+
98
+ border: 0;
99
+ background: url('select2.png') right top no-repeat;
100
+ cursor: pointer;
101
+ outline: 0;
102
+ }
103
+
104
+ .select2-container.select2-allowclear .select2-choice abbr {
105
+ display: inline-block;
106
+ }
107
+
108
+ .select2-container .select2-choice abbr:hover {
109
+ background-position: right -11px;
110
+ cursor: pointer;
111
+ }
112
+
113
+ .select2-drop-mask {
114
+ border: 0;
115
+ margin: 0;
116
+ padding: 0;
117
+ position: fixed;
118
+ left: 0;
119
+ top: 0;
120
+ min-height: 100%;
121
+ min-width: 100%;
122
+ height: auto;
123
+ width: auto;
124
+ opacity: 0;
125
+ z-index: 9998;
126
+ /* styles required for IE to work */
127
+ background-color: #fff;
128
+ filter: alpha(opacity=0);
129
+ }
130
+
131
+ .select2-drop {
132
+ width: 100%;
133
+ margin-top: -1px;
134
+ position: absolute;
135
+ z-index: 9999;
136
+ top: 100%;
137
+
138
+ background: #fff;
139
+ color: #000;
140
+ border: 1px solid #aaa;
141
+ border-top: 0;
142
+
143
+ border-radius: 0 0 4px 4px;
144
+
145
+ -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
146
+ box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
147
+ }
148
+
149
+ .select2-drop-auto-width {
150
+ border-top: 1px solid #aaa;
151
+ width: auto;
152
+ }
153
+
154
+ .select2-drop-auto-width .select2-search {
155
+ padding-top: 4px;
156
+ }
157
+
158
+ .select2-drop.select2-drop-above {
159
+ margin-top: 1px;
160
+ border-top: 1px solid #aaa;
161
+ border-bottom: 0;
162
+
163
+ border-radius: 4px 4px 0 0;
164
+
165
+ -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
166
+ box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
167
+ }
168
+
169
+ .select2-drop-active {
170
+ border: 1px solid #5897fb;
171
+ border-top: none;
172
+ }
173
+
174
+ .select2-drop.select2-drop-above.select2-drop-active {
175
+ border-top: 1px solid #5897fb;
176
+ }
177
+
178
+ .select2-container .select2-choice .select2-arrow {
179
+ display: inline-block;
180
+ width: 18px;
181
+ height: 100%;
182
+ position: absolute;
183
+ right: 0;
184
+ top: 0;
185
+
186
+ border-left: 1px solid #aaa;
187
+ border-radius: 0 4px 4px 0;
188
+
189
+ background-clip: padding-box;
190
+
191
+ background: #ccc;
192
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
193
+ background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
194
+ background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
195
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
196
+ background-image: linear-gradient(top, #ccc 0%, #eee 60%);
197
+ }
198
+
199
+ .select2-container .select2-choice .select2-arrow b {
200
+ display: block;
201
+ width: 100%;
202
+ height: 100%;
203
+ background: url('select2.png') no-repeat 0 1px;
204
+ }
205
+
206
+ .select2-search {
207
+ display: inline-block;
208
+ width: 100%;
209
+ min-height: 26px;
210
+ margin: 0;
211
+ padding-left: 4px;
212
+ padding-right: 4px;
213
+
214
+ position: relative;
215
+ z-index: 10000;
216
+
217
+ white-space: nowrap;
218
+ }
219
+
220
+ .select2-search input {
221
+ width: 100%;
222
+ height: auto !important;
223
+ min-height: 26px;
224
+ padding: 4px 20px 4px 5px;
225
+ margin: 0;
226
+
227
+ outline: 0;
228
+ font-family: sans-serif;
229
+ font-size: 1em;
230
+
231
+ border: 1px solid #aaa;
232
+ border-radius: 0;
233
+
234
+ -webkit-box-shadow: none;
235
+ box-shadow: none;
236
+
237
+ background: #fff url('select2.png') no-repeat 100% -22px;
238
+ background: url('select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
239
+ background: url('select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
240
+ background: url('select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
241
+ background: url('select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
242
+ }
243
+
244
+ .select2-drop.select2-drop-above .select2-search input {
245
+ margin-top: 4px;
246
+ }
247
+
248
+ .select2-search input.select2-active {
249
+ background: #fff url('select2-spinner.gif') no-repeat 100%;
250
+ background: url('select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
251
+ background: url('select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
252
+ background: url('select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
253
+ background: url('select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
254
+ }
255
+
256
+ .select2-container-active .select2-choice,
257
+ .select2-container-active .select2-choices {
258
+ border: 1px solid #5897fb;
259
+ outline: none;
260
+
261
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
262
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
263
+ }
264
+
265
+ .select2-dropdown-open .select2-choice {
266
+ border-bottom-color: transparent;
267
+ -webkit-box-shadow: 0 1px 0 #fff inset;
268
+ box-shadow: 0 1px 0 #fff inset;
269
+
270
+ border-bottom-left-radius: 0;
271
+ border-bottom-right-radius: 0;
272
+
273
+ background-color: #eee;
274
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
275
+ background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
276
+ background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
277
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
278
+ background-image: linear-gradient(top, #fff 0%, #eee 50%);
279
+ }
280
+
281
+ .select2-dropdown-open.select2-drop-above .select2-choice,
282
+ .select2-dropdown-open.select2-drop-above .select2-choices {
283
+ border: 1px solid #5897fb;
284
+ border-top-color: transparent;
285
+
286
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
287
+ background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
288
+ background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
289
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
290
+ background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
291
+ }
292
+
293
+ .select2-dropdown-open .select2-choice .select2-arrow {
294
+ background: transparent;
295
+ border-left: none;
296
+ filter: none;
297
+ }
298
+ .select2-dropdown-open .select2-choice .select2-arrow b {
299
+ background-position: -18px 1px;
300
+ }
301
+
302
+ /* results */
303
+ .select2-results {
304
+ max-height: 200px;
305
+ padding: 0 0 0 4px;
306
+ margin: 4px 4px 4px 0;
307
+ position: relative;
308
+ overflow-x: hidden;
309
+ overflow-y: auto;
310
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
311
+ }
312
+
313
+ .select2-results ul.select2-result-sub {
314
+ margin: 0;
315
+ padding-left: 0;
316
+ }
317
+
318
+ .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
319
+ .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
320
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
321
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
322
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
323
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
324
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
325
+
326
+ .select2-results li {
327
+ list-style: none;
328
+ display: list-item;
329
+ background-image: none;
330
+ }
331
+
332
+ .select2-results li.select2-result-with-children > .select2-result-label {
333
+ font-weight: bold;
334
+ }
335
+
336
+ .select2-results .select2-result-label {
337
+ padding: 3px 7px 4px;
338
+ margin: 0;
339
+ cursor: pointer;
340
+
341
+ min-height: 1em;
342
+
343
+ -webkit-touch-callout: none;
344
+ -webkit-user-select: none;
345
+ -moz-user-select: none;
346
+ -ms-user-select: none;
347
+ user-select: none;
348
+ }
349
+
350
+ .select2-results .select2-highlighted {
351
+ background: #3875d7;
352
+ color: #fff;
353
+ }
354
+
355
+ .select2-results li em {
356
+ background: #feffde;
357
+ font-style: normal;
358
+ }
359
+
360
+ .select2-results .select2-highlighted em {
361
+ background: transparent;
362
+ }
363
+
364
+ .select2-results .select2-highlighted ul {
365
+ background: #fff;
366
+ color: #000;
367
+ }
368
+
369
+
370
+ .select2-results .select2-no-results,
371
+ .select2-results .select2-searching,
372
+ .select2-results .select2-selection-limit {
373
+ background: #f4f4f4;
374
+ display: list-item;
375
+ }
376
+
377
+ /*
378
+ disabled look for disabled choices in the results dropdown
379
+ */
380
+ .select2-results .select2-disabled.select2-highlighted {
381
+ color: #666;
382
+ background: #f4f4f4;
383
+ display: list-item;
384
+ cursor: default;
385
+ }
386
+ .select2-results .select2-disabled {
387
+ background: #f4f4f4;
388
+ display: list-item;
389
+ cursor: default;
390
+ }
391
+
392
+ .select2-results .select2-selected {
393
+ display: none;
394
+ }
395
+
396
+ .select2-more-results.select2-active {
397
+ background: #f4f4f4 url('select2-spinner.gif') no-repeat 100%;
398
+ }
399
+
400
+ .select2-more-results {
401
+ background: #f4f4f4;
402
+ display: list-item;
403
+ }
404
+
405
+ /* disabled styles */
406
+
407
+ .select2-container.select2-container-disabled .select2-choice {
408
+ background-color: #f4f4f4;
409
+ background-image: none;
410
+ border: 1px solid #ddd;
411
+ cursor: default;
412
+ }
413
+
414
+ .select2-container.select2-container-disabled .select2-choice .select2-arrow {
415
+ background-color: #f4f4f4;
416
+ background-image: none;
417
+ border-left: 0;
418
+ }
419
+
420
+ .select2-container.select2-container-disabled .select2-choice abbr {
421
+ display: none;
422
+ }
423
+
424
+
425
+ /* multiselect */
426
+
427
+ .select2-container-multi .select2-choices {
428
+ height: auto !important;
429
+ height: 1%;
430
+ margin: 3px 0px;
431
+ padding: 5px;
432
+ position: relative;
433
+
434
+ border: 1px solid #aaa;
435
+ cursor: text;
436
+ overflow: hidden;
437
+
438
+ background-color: #fff;
439
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
440
+ background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
441
+ background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
442
+ background-image: linear-gradient(top, #eee 1%, #fff 15%);
443
+ }
444
+
445
+ .select2-locked {
446
+ padding: 3px 5px 3px 5px !important;
447
+ }
448
+
449
+ .select2-container-multi .select2-choices {
450
+ min-height: 26px;
451
+ }
452
+
453
+ .select2-container-multi.select2-container-active .select2-choices {
454
+ border: 1px solid #5897fb;
455
+ outline: none;
456
+
457
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
458
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
459
+ }
460
+ .select2-container-multi .select2-choices li {
461
+ float: left;
462
+ list-style: none;
463
+ }
464
+ .select2-container-multi .select2-choices .select2-search-field {
465
+ margin: 0;
466
+ padding: 0;
467
+ white-space: nowrap;
468
+ }
469
+
470
+ .select2-container-multi .select2-choices .select2-search-field input {
471
+ padding: 5px;
472
+ margin: 1px 0;
473
+
474
+ font-family: sans-serif;
475
+ font-size: 100%;
476
+ color: #666;
477
+ outline: 0;
478
+ border: 0;
479
+ -webkit-box-shadow: none;
480
+ box-shadow: none;
481
+ background: transparent !important;
482
+ border:none !important;
483
+ }
484
+
485
+ .select2-container-multi .select2-choices .select2-search-field input.select2-active {
486
+ background: #fff url('select2-spinner.gif') no-repeat 100% !important;
487
+ }
488
+
489
+ .select2-default {
490
+ color: #999 !important;
491
+ }
492
+
493
+ .select2-container-multi .select2-choices .select2-search-choice {
494
+ padding: 3px 5px 3px 18px;
495
+ margin: 3px 0 3px 5px;
496
+ position: relative;
497
+
498
+ line-height: 13px;
499
+ color: #333;
500
+ cursor: default;
501
+ border: 1px solid #aaaaaa;
502
+
503
+ border-radius: 3px;
504
+
505
+ -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
506
+ box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
507
+
508
+ background-clip: padding-box;
509
+
510
+ -webkit-touch-callout: none;
511
+ -webkit-user-select: none;
512
+ -moz-user-select: none;
513
+ -ms-user-select: none;
514
+ user-select: none;
515
+
516
+ background-color: #e4e4e4;
517
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
518
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
519
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
520
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
521
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
522
+ }
523
+ .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
524
+ cursor: default;
525
+ }
526
+ .select2-container-multi .select2-choices .select2-search-choice-focus {
527
+ background: #d4d4d4;
528
+ }
529
+
530
+ .select2-search-choice-close {
531
+ display: block;
532
+ width: 12px;
533
+ height: 13px;
534
+ position: absolute;
535
+ right: 3px;
536
+ top: 4px;
537
+
538
+ font-size: 1px;
539
+ outline: none;
540
+ background: url('select2.png') right top no-repeat;
541
+ }
542
+
543
+ .select2-container-multi .select2-search-choice-close {
544
+ left: 3px;
545
+ }
546
+
547
+ .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
548
+ background-position: right -11px;
549
+ }
550
+ .select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
551
+ background-position: right -11px;
552
+ }
553
+
554
+ /* disabled styles */
555
+ .select2-container-multi.select2-container-disabled .select2-choices {
556
+ background-color: #f4f4f4;
557
+ background-image: none;
558
+ border: 1px solid #ddd;
559
+ cursor: default;
560
+ }
561
+
562
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
563
+ padding: 3px 5px 3px 5px;
564
+ border: 1px solid #ddd;
565
+ background-image: none;
566
+ background-color: #f4f4f4;
567
+ }
568
+
569
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
570
+ background: none;
571
+ }
572
+ /* end multiselect */
573
+
574
+
575
+ .select2-result-selectable .select2-match,
576
+ .select2-result-unselectable .select2-match {
577
+ text-decoration: underline;
578
+ }
579
+
580
+ .select2-offscreen, .select2-offscreen:focus {
581
+ clip: rect(0 0 0 0) !important;
582
+ width: 1px !important;
583
+ height: 1px !important;
584
+ border: 0 !important;
585
+ margin: 0 !important;
586
+ padding: 0 !important;
587
+ overflow: hidden !important;
588
+ position: absolute !important;
589
+ outline: 0 !important;
590
+ left: 0px !important;
591
+ top: 0px !important;
592
+ }
593
+
594
+ .select2-display-none {
595
+ display: none;
596
+ }
597
+
598
+ .select2-measure-scrollbar {
599
+ position: absolute;
600
+ top: -10000px;
601
+ left: -10000px;
602
+ width: 100px;
603
+ height: 100px;
604
+ overflow: scroll;
605
+ }
606
+ /* Retina-ize icons */
607
+
608
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
609
+ .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
610
+ background-image: url('select2x2.png') !important;
611
+ background-repeat: no-repeat !important;
612
+ background-size: 60px 40px !important;
613
+ }
614
+ .select2-search input {
615
+ background-position: 100% -21px !important;
616
+ }
617
+ }
static/js/jquery/css/select2/select2.png ADDED
Binary file
static/js/jquery/jquery.mjs.nestedSortable.js CHANGED
@@ -343,7 +343,7 @@
343
  .match(o.expression || (/(.+)[-=_](.+)/));
344
  pid = parentItem[2];
345
  }
346
-
347
  if (id) {
348
  ret.push({"item_id": id[2], "parent_id": pid, "delim": $(item).parents('.post_taxonomy:first').find('input.tax_delim').val(), "left": left, "right": right, "xpath":$(item).find('input.widefat').val(), "assign":$(item).find('input.assign_post:first').is(':checked'), "auto_nested":$(item).parents('.post_taxonomy:first').find('input.taxonomy_auto_nested').is(':checked')});
349
  }
343
  .match(o.expression || (/(.+)[-=_](.+)/));
344
  pid = parentItem[2];
345
  }
346
+
347
  if (id) {
348
  ret.push({"item_id": id[2], "parent_id": pid, "delim": $(item).parents('.post_taxonomy:first').find('input.tax_delim').val(), "left": left, "right": right, "xpath":$(item).find('input.widefat').val(), "assign":$(item).find('input.assign_post:first').is(':checked'), "auto_nested":$(item).parents('.post_taxonomy:first').find('input.taxonomy_auto_nested').is(':checked')});
349
  }
static/js/jquery/select2.min.js ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright 2012 Igor Vaynberg
3
+
4
+ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
5
+
6
+ This software is licensed under the Apache License, Version 2.0 (the "Apache License") or the GNU
7
+ General Public License version 2 (the "GPL License"). You may choose either license to govern your
8
+ use of this software only upon the condition that you accept all of the terms of either the Apache
9
+ License or the GPL License.
10
+
11
+ You may obtain a copy of the Apache License and the GPL License at:
12
+
13
+ http://www.apache.org/licenses/LICENSE-2.0
14
+ http://www.gnu.org/licenses/gpl-2.0.html
15
+
16
+ Unless required by applicable law or agreed to in writing, software distributed under the Apache License
17
+ or the GPL Licesnse is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
18
+ either express or implied. See the Apache License and the GPL License for the specific language governing
19
+ permissions and limitations under the Apache License and the GPL License.
20
+ */
21
+ !function(a){"undefined"==typeof a.fn.each2&&a.extend(a.fn,{each2:function(b){for(var c=a([0]),d=-1,e=this.length;++d<e&&(c.context=c[0]=this[d])&&b.call(c[0],d,c)!==!1;);return this}})}(jQuery),function(a,b){"use strict";function n(a){var b,c,d,e;if(!a||a.length<1)return a;for(b="",c=0,d=a.length;d>c;c++)e=a.charAt(c),b+=m[e]||e;return b}function o(a,b){for(var c=0,d=b.length;d>c;c+=1)if(q(a,b[c]))return c;return-1}function p(){var b=a(l);b.appendTo("body");var c={width:b.width()-b[0].clientWidth,height:b.height()-b[0].clientHeight};return b.remove(),c}function q(a,c){return a===c?!0:a===b||c===b?!1:null===a||null===c?!1:a.constructor===String?a+""==c+"":c.constructor===String?c+""==a+"":!1}function r(b,c){var d,e,f;if(null===b||b.length<1)return[];for(d=b.split(c),e=0,f=d.length;f>e;e+=1)d[e]=a.trim(d[e]);return d}function s(a){return a.outerWidth(!1)-a.width()}function t(c){var d="keyup-change-value";c.on("keydown",function(){a.data(c,d)===b&&a.data(c,d,c.val())}),c.on("keyup",function(){var e=a.data(c,d);e!==b&&c.val()!==e&&(a.removeData(c,d),c.trigger("keyup-change"))})}function u(c){c.on("mousemove",function(c){var d=i;(d===b||d.x!==c.pageX||d.y!==c.pageY)&&a(c.target).trigger("mousemove-filtered",c)})}function v(a,c,d){d=d||b;var e;return function(){var b=arguments;window.clearTimeout(e),e=window.setTimeout(function(){c.apply(d,b)},a)}}function w(a){var c,b=!1;return function(){return b===!1&&(c=a(),b=!0),c}}function x(a,b){var c=v(a,function(a){b.trigger("scroll-debounced",a)});b.on("scroll",function(a){o(a.target,b.get())>=0&&c(a)})}function y(a){a[0]!==document.activeElement&&window.setTimeout(function(){var d,b=a[0],c=a.val().length;a.focus(),a.is(":visible")&&b===document.activeElement&&(b.setSelectionRange?b.setSelectionRange(c,c):b.createTextRange&&(d=b.createTextRange(),d.collapse(!1),d.select()))},0)}function z(b){b=a(b)[0];var c=0,d=0;if("selectionStart"in b)c=b.selectionStart,d=b.selectionEnd-c;else if("selection"in document){b.focus();var e=document.selection.createRange();d=document.selection.createRange().text.length,e.moveStart("character",-b.value.length),c=e.text.length-d}return{offset:c,length:d}}function A(a){a.preventDefault(),a.stopPropagation()}function B(a){a.preventDefault(),a.stopImmediatePropagation()}function C(b){if(!h){var c=b[0].currentStyle||window.getComputedStyle(b[0],null);h=a(document.createElement("div")).css({position:"absolute",left:"-10000px",top:"-10000px",display:"none",fontSize:c.fontSize,fontFamily:c.fontFamily,fontStyle:c.fontStyle,fontWeight:c.fontWeight,letterSpacing:c.letterSpacing,textTransform:c.textTransform,whiteSpace:"nowrap"}),h.attr("class","select2-sizer"),a("body").append(h)}return h.text(b.val()),h.width()}function D(b,c,d){var e,g,f=[];e=b.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0===this.indexOf("select2-")&&f.push(this)})),e=c.attr("class"),e&&(e=""+e,a(e.split(" ")).each2(function(){0!==this.indexOf("select2-")&&(g=d(this),g&&f.push(g))})),b.attr("class",f.join(" "))}function E(a,b,c,d){var e=n(a.toUpperCase()).indexOf(n(b.toUpperCase())),f=b.length;return 0>e?(c.push(d(a)),void 0):(c.push(d(a.substring(0,e))),c.push("<span class='select2-match'>"),c.push(d(a.substring(e,e+f))),c.push("</span>"),c.push(d(a.substring(e+f,a.length))),void 0)}function F(a){var b={"\\":"&#92;","&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#47;"};return String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})}function G(c){var d,e=null,f=c.quietMillis||100,g=c.url,h=this;return function(i){window.clearTimeout(d),d=window.setTimeout(function(){var d=c.data,f=g,j=c.transport||a.fn.select2.ajaxDefaults.transport,k={type:c.type||"GET",cache:c.cache||!1,jsonpCallback:c.jsonpCallback||b,dataType:c.dataType||"json"},l=a.extend({},a.fn.select2.ajaxDefaults.params,k);d=d?d.call(h,i.term,i.page,i.context):null,f="function"==typeof f?f.call(h,i.term,i.page,i.context):f,e&&e.abort(),c.params&&(a.isFunction(c.params)?a.extend(l,c.params.call(h)):a.extend(l,c.params)),a.extend(l,{url:f,dataType:c.dataType,data:d,success:function(a){var b=c.results(a,i.page);i.callback(b)}}),e=j.call(h,l)},f)}}function H(b){var d,e,c=b,f=function(a){return""+a.text};a.isArray(c)&&(e=c,c={results:e}),a.isFunction(c)===!1&&(e=c,c=function(){return e});var g=c();return g.text&&(f=g.text,a.isFunction(f)||(d=g.text,f=function(a){return a[d]})),function(b){var g,d=b.term,e={results:[]};return""===d?(b.callback(c()),void 0):(g=function(c,e){var h,i;if(c=c[0],c.children){h={};for(i in c)c.hasOwnProperty(i)&&(h[i]=c[i]);h.children=[],a(c.children).each2(function(a,b){g(b,h.children)}),(h.children.length||b.matcher(d,f(h),c))&&e.push(h)}else b.matcher(d,f(c),c)&&e.push(c)},a(c().results).each2(function(a,b){g(b,e.results)}),b.callback(e),void 0)}}function I(c){var d=a.isFunction(c);return function(e){var f=e.term,g={results:[]};a(d?c():c).each(function(){var a=this.text!==b,c=a?this.text:this;(""===f||e.matcher(f,c))&&g.results.push(a?this:{id:this,text:this})}),e.callback(g)}}function J(b,c){if(a.isFunction(b))return!0;if(!b)return!1;throw new Error(c+" must be a function or a falsy value")}function K(b){return a.isFunction(b)?b():b}function L(b){var c=0;return a.each(b,function(a,b){b.children?c+=L(b.children):c++}),c}function M(a,c,d,e){var h,i,j,k,l,f=a,g=!1;if(!e.createSearchChoice||!e.tokenSeparators||e.tokenSeparators.length<1)return b;for(;;){for(i=-1,j=0,k=e.tokenSeparators.length;k>j&&(l=e.tokenSeparators[j],i=a.indexOf(l),!(i>=0));j++);if(0>i)break;if(h=a.substring(0,i),a=a.substring(i+l.length),h.length>0&&(h=e.createSearchChoice.call(this,h,c),h!==b&&null!==h&&e.id(h)!==b&&null!==e.id(h))){for(g=!1,j=0,k=c.length;k>j;j++)if(q(e.id(h),e.id(c[j]))){g=!0;break}g||d(h)}}return f!==a?a:void 0}function N(b,c){var d=function(){};return d.prototype=new b,d.prototype.constructor=d,d.prototype.parent=b.prototype,d.prototype=a.extend(d.prototype,c),d}if(window.Select2===b){var c,d,e,f,g,h,j,k,i={x:0,y:0},c={TAB:9,ENTER:13,ESC:27,SPACE:32,LEFT:37,UP:38,RIGHT:39,DOWN:40,SHIFT:16,CTRL:17,ALT:18,PAGE_UP:33,PAGE_DOWN:34,HOME:36,END:35,BACKSPACE:8,DELETE:46,isArrow:function(a){switch(a=a.which?a.which:a){case c.LEFT:case c.RIGHT:case c.UP:case c.DOWN:return!0}return!1},isControl:function(a){var b=a.which;switch(b){case c.SHIFT:case c.CTRL:case c.ALT:return!0}return a.metaKey?!0:!1},isFunctionKey:function(a){return a=a.which?a.which:a,a>=112&&123>=a}},l="<div class='select2-measure-scrollbar'></div>",m={"\u24b6":"A","\uff21":"A","\xc0":"A","\xc1":"A","\xc2":"A","\u1ea6":"A","\u1ea4":"A","\u1eaa":"A","\u1ea8":"A","\xc3":"A","\u0100":"A","\u0102":"A","\u1eb0":"A","\u1eae":"A","\u1eb4":"A","\u1eb2":"A","\u0226":"A","\u01e0":"A","\xc4":"A","\u01de":"A","\u1ea2":"A","\xc5":"A","\u01fa":"A","\u01cd":"A","\u0200":"A","\u0202":"A","\u1ea0":"A","\u1eac":"A","\u1eb6":"A","\u1e00":"A","\u0104":"A","\u023a":"A","\u2c6f":"A","\ua732":"AA","\xc6":"AE","\u01fc":"AE","\u01e2":"AE","\ua734":"AO","\ua736":"AU","\ua738":"AV","\ua73a":"AV","\ua73c":"AY","\u24b7":"B","\uff22":"B","\u1e02":"B","\u1e04":"B","\u1e06":"B","\u0243":"B","\u0182":"B","\u0181":"B","\u24b8":"C","\uff23":"C","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\xc7":"C","\u1e08":"C","\u0187":"C","\u023b":"C","\ua73e":"C","\u24b9":"D","\uff24":"D","\u1e0a":"D","\u010e":"D","\u1e0c":"D","\u1e10":"D","\u1e12":"D","\u1e0e":"D","\u0110":"D","\u018b":"D","\u018a":"D","\u0189":"D","\ua779":"D","\u01f1":"DZ","\u01c4":"DZ","\u01f2":"Dz","\u01c5":"Dz","\u24ba":"E","\uff25":"E","\xc8":"E","\xc9":"E","\xca":"E","\u1ec0":"E","\u1ebe":"E","\u1ec4":"E","\u1ec2":"E","\u1ebc":"E","\u0112":"E","\u1e14":"E","\u1e16":"E","\u0114":"E","\u0116":"E","\xcb":"E","\u1eba":"E","\u011a":"E","\u0204":"E","\u0206":"E","\u1eb8":"E","\u1ec6":"E","\u0228":"E","\u1e1c":"E","\u0118":"E","\u1e18":"E","\u1e1a":"E","\u0190":"E","\u018e":"E","\u24bb":"F","\uff26":"F","\u1e1e":"F","\u0191":"F","\ua77b":"F","\u24bc":"G","\uff27":"G","\u01f4":"G","\u011c":"G","\u1e20":"G","\u011e":"G","\u0120":"G","\u01e6":"G","\u0122":"G","\u01e4":"G","\u0193":"G","\ua7a0":"G","\ua77d":"G","\ua77e":"G","\u24bd":"H","\uff28":"H","\u0124":"H","\u1e22":"H","\u1e26":"H","\u021e":"H","\u1e24":"H","\u1e28":"H","\u1e2a":"H","\u0126":"H","\u2c67":"H","\u2c75":"H","\ua78d":"H","\u24be":"I","\uff29":"I","\xcc":"I","\xcd":"I","\xce":"I","\u0128":"I","\u012a":"I","\u012c":"I","\u0130":"I","\xcf":"I","\u1e2e":"I","\u1ec8":"I","\u01cf":"I","\u0208":"I","\u020a":"I","\u1eca":"I","\u012e":"I","\u1e2c":"I","\u0197":"I","\u24bf":"J","\uff2a":"J","\u0134":"J","\u0248":"J","\u24c0":"K","\uff2b":"K","\u1e30":"K","\u01e8":"K","\u1e32":"K","\u0136":"K","\u1e34":"K","\u0198":"K","\u2c69":"K","\ua740":"K","\ua742":"K","\ua744":"K","\ua7a2":"K","\u24c1":"L","\uff2c":"L","\u013f":"L","\u0139":"L","\u013d":"L","\u1e36":"L","\u1e38":"L","\u013b":"L","\u1e3c":"L","\u1e3a":"L","\u0141":"L","\u023d":"L","\u2c62":"L","\u2c60":"L","\ua748":"L","\ua746":"L","\ua780":"L","\u01c7":"LJ","\u01c8":"Lj","\u24c2":"M","\uff2d":"M","\u1e3e":"M","\u1e40":"M","\u1e42":"M","\u2c6e":"M","\u019c":"M","\u24c3":"N","\uff2e":"N","\u01f8":"N","\u0143":"N","\xd1":"N","\u1e44":"N","\u0147":"N","\u1e46":"N","\u0145":"N","\u1e4a":"N","\u1e48":"N","\u0220":"N","\u019d":"N","\ua790":"N","\ua7a4":"N","\u01ca":"NJ","\u01cb":"Nj","\u24c4":"O","\uff2f":"O","\xd2":"O","\xd3":"O","\xd4":"O","\u1ed2":"O","\u1ed0":"O","\u1ed6":"O","\u1ed4":"O","\xd5":"O","\u1e4c":"O","\u022c":"O","\u1e4e":"O","\u014c":"O","\u1e50":"O","\u1e52":"O","\u014e":"O","\u022e":"O","\u0230":"O","\xd6":"O","\u022a":"O","\u1ece":"O","\u0150":"O","\u01d1":"O","\u020c":"O","\u020e":"O","\u01a0":"O","\u1edc":"O","\u1eda":"O","\u1ee0":"O","\u1ede":"O","\u1ee2":"O","\u1ecc":"O","\u1ed8":"O","\u01ea":"O","\u01ec":"O","\xd8":"O","\u01fe":"O","\u0186":"O","\u019f":"O","\ua74a":"O","\ua74c":"O","\u01a2":"OI","\ua74e":"OO","\u0222":"OU","\u24c5":"P","\uff30":"P","\u1e54":"P","\u1e56":"P","\u01a4":"P","\u2c63":"P","\ua750":"P","\ua752":"P","\ua754":"P","\u24c6":"Q","\uff31":"Q","\ua756":"Q","\ua758":"Q","\u024a":"Q","\u24c7":"R","\uff32":"R","\u0154":"R","\u1e58":"R","\u0158":"R","\u0210":"R","\u0212":"R","\u1e5a":"R","\u1e5c":"R","\u0156":"R","\u1e5e":"R","\u024c":"R","\u2c64":"R","\ua75a":"R","\ua7a6":"R","\ua782":"R","\u24c8":"S","\uff33":"S","\u1e9e":"S","\u015a":"S","\u1e64":"S","\u015c":"S","\u1e60":"S","\u0160":"S","\u1e66":"S","\u1e62":"S","\u1e68":"S","\u0218":"S","\u015e":"S","\u2c7e":"S","\ua7a8":"S","\ua784":"S","\u24c9":"T","\uff34":"T","\u1e6a":"T","\u0164":"T","\u1e6c":"T","\u021a":"T","\u0162":"T","\u1e70":"T","\u1e6e":"T","\u0166":"T","\u01ac":"T","\u01ae":"T","\u023e":"T","\ua786":"T","\ua728":"TZ","\u24ca":"U","\uff35":"U","\xd9":"U","\xda":"U","\xdb":"U","\u0168":"U","\u1e78":"U","\u016a":"U","\u1e7a":"U","\u016c":"U","\xdc":"U","\u01db":"U","\u01d7":"U","\u01d5":"U","\u01d9":"U","\u1ee6":"U","\u016e":"U","\u0170":"U","\u01d3":"U","\u0214":"U","\u0216":"U","\u01af":"U","\u1eea":"U","\u1ee8":"U","\u1eee":"U","\u1eec":"U","\u1ef0":"U","\u1ee4":"U","\u1e72":"U","\u0172":"U","\u1e76":"U","\u1e74":"U","\u0244":"U","\u24cb":"V","\uff36":"V","\u1e7c":"V","\u1e7e":"V","\u01b2":"V","\ua75e":"V","\u0245":"V","\ua760":"VY","\u24cc":"W","\uff37":"W","\u1e80":"W","\u1e82":"W","\u0174":"W","\u1e86":"W","\u1e84":"W","\u1e88":"W","\u2c72":"W","\u24cd":"X","\uff38":"X","\u1e8a":"X","\u1e8c":"X","\u24ce":"Y","\uff39":"Y","\u1ef2":"Y","\xdd":"Y","\u0176":"Y","\u1ef8":"Y","\u0232":"Y","\u1e8e":"Y","\u0178":"Y","\u1ef6":"Y","\u1ef4":"Y","\u01b3":"Y","\u024e":"Y","\u1efe":"Y","\u24cf":"Z","\uff3a":"Z","\u0179":"Z","\u1e90":"Z","\u017b":"Z","\u017d":"Z","\u1e92":"Z","\u1e94":"Z","\u01b5":"Z","\u0224":"Z","\u2c7f":"Z","\u2c6b":"Z","\ua762":"Z","\u24d0":"a","\uff41":"a","\u1e9a":"a","\xe0":"a","\xe1":"a","\xe2":"a","\u1ea7":"a","\u1ea5":"a","\u1eab":"a","\u1ea9":"a","\xe3":"a","\u0101":"a","\u0103":"a","\u1eb1":"a","\u1eaf":"a","\u1eb5":"a","\u1eb3":"a","\u0227":"a","\u01e1":"a","\xe4":"a","\u01df":"a","\u1ea3":"a","\xe5":"a","\u01fb":"a","\u01ce":"a","\u0201":"a","\u0203":"a","\u1ea1":"a","\u1ead":"a","\u1eb7":"a","\u1e01":"a","\u0105":"a","\u2c65":"a","\u0250":"a","\ua733":"aa","\xe6":"ae","\u01fd":"ae","\u01e3":"ae","\ua735":"ao","\ua737":"au","\ua739":"av","\ua73b":"av","\ua73d":"ay","\u24d1":"b","\uff42":"b","\u1e03":"b","\u1e05":"b","\u1e07":"b","\u0180":"b","\u0183":"b","\u0253":"b","\u24d2":"c","\uff43":"c","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\xe7":"c","\u1e09":"c","\u0188":"c","\u023c":"c","\ua73f":"c","\u2184":"c","\u24d3":"d","\uff44":"d","\u1e0b":"d","\u010f":"d","\u1e0d":"d","\u1e11":"d","\u1e13":"d","\u1e0f":"d","\u0111":"d","\u018c":"d","\u0256":"d","\u0257":"d","\ua77a":"d","\u01f3":"dz","\u01c6":"dz","\u24d4":"e","\uff45":"e","\xe8":"e","\xe9":"e","\xea":"e","\u1ec1":"e","\u1ebf":"e","\u1ec5":"e","\u1ec3":"e","\u1ebd":"e","\u0113":"e","\u1e15":"e","\u1e17":"e","\u0115":"e","\u0117":"e","\xeb":"e","\u1ebb":"e","\u011b":"e","\u0205":"e","\u0207":"e","\u1eb9":"e","\u1ec7":"e","\u0229":"e","\u1e1d":"e","\u0119":"e","\u1e19":"e","\u1e1b":"e","\u0247":"e","\u025b":"e","\u01dd":"e","\u24d5":"f","\uff46":"f","\u1e1f":"f","\u0192":"f","\ua77c":"f","\u24d6":"g","\uff47":"g","\u01f5":"g","\u011d":"g","\u1e21":"g","\u011f":"g","\u0121":"g","\u01e7":"g","\u0123":"g","\u01e5":"g","\u0260":"g","\ua7a1":"g","\u1d79":"g","\ua77f":"g","\u24d7":"h","\uff48":"h","\u0125":"h","\u1e23":"h","\u1e27":"h","\u021f":"h","\u1e25":"h","\u1e29":"h","\u1e2b":"h","\u1e96":"h","\u0127":"h","\u2c68":"h","\u2c76":"h","\u0265":"h","\u0195":"hv","\u24d8":"i","\uff49":"i","\xec":"i","\xed":"i","\xee":"i","\u0129":"i","\u012b":"i","\u012d":"i","\xef":"i","\u1e2f":"i","\u1ec9":"i","\u01d0":"i","\u0209":"i","\u020b":"i","\u1ecb":"i","\u012f":"i","\u1e2d":"i","\u0268":"i","\u0131":"i","\u24d9":"j","\uff4a":"j","\u0135":"j","\u01f0":"j","\u0249":"j","\u24da":"k","\uff4b":"k","\u1e31":"k","\u01e9":"k","\u1e33":"k","\u0137":"k","\u1e35":"k","\u0199":"k","\u2c6a":"k","\ua741":"k","\ua743":"k","\ua745":"k","\ua7a3":"k","\u24db":"l","\uff4c":"l","\u0140":"l","\u013a":"l","\u013e":"l","\u1e37":"l","\u1e39":"l","\u013c":"l","\u1e3d":"l","\u1e3b":"l","\u017f":"l","\u0142":"l","\u019a":"l","\u026b":"l","\u2c61":"l","\ua749":"l","\ua781":"l","\ua747":"l","\u01c9":"lj","\u24dc":"m","\uff4d":"m","\u1e3f":"m","\u1e41":"m","\u1e43":"m","\u0271":"m","\u026f":"m","\u24dd":"n","\uff4e":"n","\u01f9":"n","\u0144":"n","\xf1":"n","\u1e45":"n","\u0148":"n","\u1e47":"n","\u0146":"n","\u1e4b":"n","\u1e49":"n","\u019e":"n","\u0272":"n","\u0149":"n","\ua791":"n","\ua7a5":"n","\u01cc":"nj","\u24de":"o","\uff4f":"o","\xf2":"o","\xf3":"o","\xf4":"o","\u1ed3":"o","\u1ed1":"o","\u1ed7":"o","\u1ed5":"o","\xf5":"o","\u1e4d":"o","\u022d":"o","\u1e4f":"o","\u014d":"o","\u1e51":"o","\u1e53":"o","\u014f":"o","\u022f":"o","\u0231":"o","\xf6":"o","\u022b":"o","\u1ecf":"o","\u0151":"o","\u01d2":"o","\u020d":"o","\u020f":"o","\u01a1":"o","\u1edd":"o","\u1edb":"o","\u1ee1":"o","\u1edf":"o","\u1ee3":"o","\u1ecd":"o","\u1ed9":"o","\u01eb":"o","\u01ed":"o","\xf8":"o","\u01ff":"o","\u0254":"o","\ua74b":"o","\ua74d":"o","\u0275":"o","\u01a3":"oi","\u0223":"ou","\ua74f":"oo","\u24df":"p","\uff50":"p","\u1e55":"p","\u1e57":"p","\u01a5":"p","\u1d7d":"p","\ua751":"p","\ua753":"p","\ua755":"p","\u24e0":"q","\uff51":"q","\u024b":"q","\ua757":"q","\ua759":"q","\u24e1":"r","\uff52":"r","\u0155":"r","\u1e59":"r","\u0159":"r","\u0211":"r","\u0213":"r","\u1e5b":"r","\u1e5d":"r","\u0157":"r","\u1e5f":"r","\u024d":"r","\u027d":"r","\ua75b":"r","\ua7a7":"r","\ua783":"r","\u24e2":"s","\uff53":"s","\xdf":"s","\u015b":"s","\u1e65":"s","\u015d":"s","\u1e61":"s","\u0161":"s","\u1e67":"s","\u1e63":"s","\u1e69":"s","\u0219":"s","\u015f":"s","\u023f":"s","\ua7a9":"s","\ua785":"s","\u1e9b":"s","\u24e3":"t","\uff54":"t","\u1e6b":"t","\u1e97":"t","\u0165":"t","\u1e6d":"t","\u021b":"t","\u0163":"t","\u1e71":"t","\u1e6f":"t","\u0167":"t","\u01ad":"t","\u0288":"t","\u2c66":"t","\ua787":"t","\ua729":"tz","\u24e4":"u","\uff55":"u","\xf9":"u","\xfa":"u","\xfb":"u","\u0169":"u","\u1e79":"u","\u016b":"u","\u1e7b":"u","\u016d":"u","\xfc":"u","\u01dc":"u","\u01d8":"u","\u01d6":"u","\u01da":"u","\u1ee7":"u","\u016f":"u","\u0171":"u","\u01d4":"u","\u0215":"u","\u0217":"u","\u01b0":"u","\u1eeb":"u","\u1ee9":"u","\u1eef":"u","\u1eed":"u","\u1ef1":"u","\u1ee5":"u","\u1e73":"u","\u0173":"u","\u1e77":"u","\u1e75":"u","\u0289":"u","\u24e5":"v","\uff56":"v","\u1e7d":"v","\u1e7f":"v","\u028b":"v","\ua75f":"v","\u028c":"v","\ua761":"vy","\u24e6":"w","\uff57":"w","\u1e81":"w","\u1e83":"w","\u0175":"w","\u1e87":"w","\u1e85":"w","\u1e98":"w","\u1e89":"w","\u2c73":"w","\u24e7":"x","\uff58":"x","\u1e8b":"x","\u1e8d":"x","\u24e8":"y","\uff59":"y","\u1ef3":"y","\xfd":"y","\u0177":"y","\u1ef9":"y","\u0233":"y","\u1e8f":"y","\xff":"y","\u1ef7":"y","\u1e99":"y","\u1ef5":"y","\u01b4":"y","\u024f":"y","\u1eff":"y","\u24e9":"z","\uff5a":"z","\u017a":"z","\u1e91":"z","\u017c":"z","\u017e":"z","\u1e93":"z","\u1e95":"z","\u01b6":"z","\u0225":"z","\u0240":"z","\u2c6c":"z","\ua763":"z"};j=a(document),g=function(){var a=1;return function(){return a++}}(),j.on("mousemove",function(a){i.x=a.pageX,i.y=a.pageY}),d=N(Object,{bind:function(a){var b=this;return function(){a.apply(b,arguments)}},init:function(c){var d,e,f=".select2-results";this.opts=c=this.prepareOpts(c),this.id=c.id,c.element.data("select2")!==b&&null!==c.element.data("select2")&&c.element.data("select2").destroy(),this.container=this.createContainer(),this.containerId="s2id_"+(c.element.attr("id")||"autogen"+g()),this.containerSelector="#"+this.containerId.replace(/([;&,\.\+\*\~':"\!\^#$%@\[\]\(\)=>\|])/g,"\\$1"),this.container.attr("id",this.containerId),this.body=w(function(){return c.element.closest("body")}),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.attr("style",c.element.attr("style")),this.container.css(K(c.containerCss)),this.container.addClass(K(c.containerCssClass)),this.elementTabIndex=this.opts.element.attr("tabindex"),this.opts.element.data("select2",this).attr("tabindex","-1").before(this.container).on("click.select2",A),this.container.data("select2",this),this.dropdown=this.container.find(".select2-drop"),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(c.dropdownCssClass)),this.dropdown.data("select2",this),this.dropdown.on("click",A),this.results=d=this.container.find(f),this.search=e=this.container.find("input.select2-input"),this.queryCount=0,this.resultsPage=0,this.context=null,this.initContainer(),this.container.on("click",A),u(this.results),this.dropdown.on("mousemove-filtered touchstart touchmove touchend",f,this.bind(this.highlightUnderEvent)),x(80,this.results),this.dropdown.on("scroll-debounced",f,this.bind(this.loadMoreIfNeeded)),a(this.container).on("change",".select2-input",function(a){a.stopPropagation()}),a(this.dropdown).on("change",".select2-input",function(a){a.stopPropagation()}),a.fn.mousewheel&&d.mousewheel(function(a,b,c,e){var f=d.scrollTop();e>0&&0>=f-e?(d.scrollTop(0),A(a)):0>e&&d.get(0).scrollHeight-d.scrollTop()+e<=d.height()&&(d.scrollTop(d.get(0).scrollHeight-d.height()),A(a))}),t(e),e.on("keyup-change input paste",this.bind(this.updateResults)),e.on("focus",function(){e.addClass("select2-focused")}),e.on("blur",function(){e.removeClass("select2-focused")}),this.dropdown.on("mouseup",f,this.bind(function(b){a(b.target).closest(".select2-result-selectable").length>0&&(this.highlightUnderEvent(b),this.selectHighlighted(b))})),this.dropdown.on("click mouseup mousedown",function(a){a.stopPropagation()}),a.isFunction(this.opts.initSelection)&&(this.initSelection(),this.monitorSource()),null!==c.maximumInputLength&&this.search.attr("maxlength",c.maximumInputLength);var h=c.element.prop("disabled");h===b&&(h=!1),this.enable(!h);var i=c.element.prop("readonly");i===b&&(i=!1),this.readonly(i),k=k||p(),this.autofocus=c.element.prop("autofocus"),c.element.prop("autofocus",!1),this.autofocus&&this.focus(),this.nextSearchTerm=b},destroy:function(){var a=this.opts.element,c=a.data("select2");this.close(),this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),c!==b&&(c.container.remove(),c.dropdown.remove(),a.removeClass("select2-offscreen").removeData("select2").off(".select2").prop("autofocus",this.autofocus||!1),this.elementTabIndex?a.attr({tabindex:this.elementTabIndex}):a.removeAttr("tabindex"),a.show())},optionToData:function(a){return a.is("option")?{id:a.prop("value"),text:a.text(),element:a.get(),css:a.attr("class"),disabled:a.prop("disabled"),locked:q(a.attr("locked"),"locked")||q(a.data("locked"),!0)}:a.is("optgroup")?{text:a.attr("label"),children:[],element:a.get(),css:a.attr("class")}:void 0},prepareOpts:function(c){var d,e,f,g,h=this;if(d=c.element,"select"===d.get(0).tagName.toLowerCase()&&(this.select=e=c.element),e&&a.each(["id","multiple","ajax","query","createSearchChoice","initSelection","data","tags"],function(){if(this in c)throw new Error("Option '"+this+"' is not allowed for Select2 when attached to a <select> element.")}),c=a.extend({},{populateResults:function(d,e,f){var g,i=this.opts.id;g=function(d,e,j){var k,l,m,n,o,p,q,r,s,t;for(d=c.sortResults(d,e,f),k=0,l=d.length;l>k;k+=1)m=d[k],o=m.disabled===!0,n=!o&&i(m)!==b,p=m.children&&m.children.length>0,q=a("<li></li>"),q.addClass("select2-results-dept-"+j),q.addClass("select2-result"),q.addClass(n?"select2-result-selectable":"select2-result-unselectable"),o&&q.addClass("select2-disabled"),p&&q.addClass("select2-result-with-children"),q.addClass(h.opts.formatResultCssClass(m)),r=a(document.createElement("div")),r.addClass("select2-result-label"),t=c.formatResult(m,r,f,h.opts.escapeMarkup),t!==b&&r.html(t),q.append(r),p&&(s=a("<ul></ul>"),s.addClass("select2-result-sub"),g(m.children,s,j+1),q.append(s)),q.data("select2-data",m),e.append(q)},g(e,d,0)}},a.fn.select2.defaults,c),"function"!=typeof c.id&&(f=c.id,c.id=function(a){return a[f]}),a.isArray(c.element.data("select2Tags"))){if("tags"in c)throw"tags specified as both an attribute 'data-select2-tags' and in options of Select2 "+c.element.attr("id");c.tags=c.element.data("select2Tags")}if(e?(c.query=this.bind(function(a){var f,g,i,c={results:[],more:!1},e=a.term;i=function(b,c){var d;b.is("option")?a.matcher(e,b.text(),b)&&c.push(h.optionToData(b)):b.is("optgroup")&&(d=h.optionToData(b),b.children().each2(function(a,b){i(b,d.children)}),d.children.length>0&&c.push(d))},f=d.children(),this.getPlaceholder()!==b&&f.length>0&&(g=this.getPlaceholderOption(),g&&(f=f.not(g))),f.each2(function(a,b){i(b,c.results)}),a.callback(c)}),c.id=function(a){return a.id},c.formatResultCssClass=function(a){return a.css}):"query"in c||("ajax"in c?(g=c.element.data("ajax-url"),g&&g.length>0&&(c.ajax.url=g),c.query=G.call(c.element,c.ajax)):"data"in c?c.query=H(c.data):"tags"in c&&(c.query=I(c.tags),c.createSearchChoice===b&&(c.createSearchChoice=function(b){return{id:a.trim(b),text:a.trim(b)}}),c.initSelection===b&&(c.initSelection=function(b,d){var e=[];a(r(b.val(),c.separator)).each(function(){var b={id:this,text:this},d=c.tags;a.isFunction(d)&&(d=d()),a(d).each(function(){return q(this.id,b.id)?(b=this,!1):void 0}),e.push(b)}),d(e)}))),"function"!=typeof c.query)throw"query function not defined for Select2 "+c.element.attr("id");return c},monitorSource:function(){var c,d,a=this.opts.element;a.on("change.select2",this.bind(function(){this.opts.element.data("select2-change-triggered")!==!0&&this.initSelection()})),c=this.bind(function(){var c=a.prop("disabled");c===b&&(c=!1),this.enable(!c);var d=a.prop("readonly");d===b&&(d=!1),this.readonly(d),D(this.container,this.opts.element,this.opts.adaptContainerCssClass),this.container.addClass(K(this.opts.containerCssClass)),D(this.dropdown,this.opts.element,this.opts.adaptDropdownCssClass),this.dropdown.addClass(K(this.opts.dropdownCssClass))}),a.on("propertychange.select2",c),this.mutationCallback===b&&(this.mutationCallback=function(a){a.forEach(c)}),d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver,d!==b&&(this.propertyObserver&&(delete this.propertyObserver,this.propertyObserver=null),this.propertyObserver=new d(this.mutationCallback),this.propertyObserver.observe(a.get(0),{attributes:!0,subtree:!1}))},triggerSelect:function(b){var c=a.Event("select2-selecting",{val:this.id(b),object:b});return this.opts.element.trigger(c),!c.isDefaultPrevented()},triggerChange:function(b){b=b||{},b=a.extend({},b,{type:"change",val:this.val()}),this.opts.element.data("select2-change-triggered",!0),this.opts.element.trigger(b),this.opts.element.data("select2-change-triggered",!1),this.opts.element.click(),this.opts.blurOnChange&&this.opts.element.blur()},isInterfaceEnabled:function(){return this.enabledInterface===!0},enableInterface:function(){var a=this._enabled&&!this._readonly,b=!a;return a===this.enabledInterface?!1:(this.container.toggleClass("select2-container-disabled",b),this.close(),this.enabledInterface=a,!0)},enable:function(a){a===b&&(a=!0),this._enabled!==a&&(this._enabled=a,this.opts.element.prop("disabled",!a),this.enableInterface())},disable:function(){this.enable(!1)},readonly:function(a){return a===b&&(a=!1),this._readonly===a?!1:(this._readonly=a,this.opts.element.prop("readonly",a),this.enableInterface(),!0)},opened:function(){return this.container.hasClass("select2-dropdown-open")},positionDropdown:function(){var t,u,v,w,x,b=this.dropdown,c=this.container.offset(),d=this.container.outerHeight(!1),e=this.container.outerWidth(!1),f=b.outerHeight(!1),g=a(window),h=g.width(),i=g.height(),j=g.scrollLeft()+h,l=g.scrollTop()+i,m=c.top+d,n=c.left,o=l>=m+f,p=c.top-f>=this.body().scrollTop(),q=b.outerWidth(!1),r=j>=n+q,s=b.hasClass("select2-drop-above");s?(u=!0,!p&&o&&(v=!0,u=!1)):(u=!1,!o&&p&&(v=!0,u=!0)),v&&(b.hide(),c=this.container.offset(),d=this.container.outerHeight(!1),e=this.container.outerWidth(!1),f=b.outerHeight(!1),j=g.scrollLeft()+h,l=g.scrollTop()+i,m=c.top+d,n=c.left,q=b.outerWidth(!1),r=j>=n+q,b.show()),this.opts.dropdownAutoWidth?(x=a(".select2-results",b)[0],b.addClass("select2-drop-auto-width"),b.css("width",""),q=b.outerWidth(!1)+(x.scrollHeight===x.clientHeight?0:k.width),q>e?e=q:q=e,r=j>=n+q):this.container.removeClass("select2-drop-auto-width"),"static"!==this.body().css("position")&&(t=this.body().offset(),m-=t.top,n-=t.left),r||(n=c.left+e-q),w={left:n,width:e},u?(w.bottom=i-c.top,w.top="auto",this.container.addClass("select2-drop-above"),b.addClass("select2-drop-above")):(w.top=m,w.bottom="auto",this.container.removeClass("select2-drop-above"),b.removeClass("select2-drop-above")),w=a.extend(w,K(this.opts.dropdownCss)),b.css(w)},shouldOpen:function(){var b;return this.opened()?!1:this._enabled===!1||this._readonly===!0?!1:(b=a.Event("select2-opening"),this.opts.element.trigger(b),!b.isDefaultPrevented())},clearDropdownAlignmentPreference:function(){this.container.removeClass("select2-drop-above"),this.dropdown.removeClass("select2-drop-above")},open:function(){return this.shouldOpen()?(this.opening(),!0):!1},opening:function(){var f,b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.addClass("select2-dropdown-open").addClass("select2-container-active"),this.clearDropdownAlignmentPreference(),this.dropdown[0]!==this.body().children().last()[0]&&this.dropdown.detach().appendTo(this.body()),f=a("#select2-drop-mask"),0==f.length&&(f=a(document.createElement("div")),f.attr("id","select2-drop-mask").attr("class","select2-drop-mask"),f.hide(),f.appendTo(this.body()),f.on("mousedown touchstart click",function(b){var d,c=a("#select2-drop");c.length>0&&(d=c.data("select2"),d.opts.selectOnBlur&&d.selectHighlighted({noFocus:!0}),d.close({focus:!0}),b.preventDefault(),b.stopPropagation())})),this.dropdown.prev()[0]!==f[0]&&this.dropdown.before(f),a("#select2-drop").removeAttr("id"),this.dropdown.attr("id","select2-drop"),f.show(),this.positionDropdown(),this.dropdown.show(),this.positionDropdown(),this.dropdown.addClass("select2-drop-active");var g=this;this.container.parents().add(window).each(function(){a(this).on(d+" "+c+" "+e,function(){g.positionDropdown()})})},close:function(){if(this.opened()){var b=this.containerId,c="scroll."+b,d="resize."+b,e="orientationchange."+b;this.container.parents().add(window).each(function(){a(this).off(c).off(d).off(e)}),this.clearDropdownAlignmentPreference(),a("#select2-drop-mask").hide(),this.dropdown.removeAttr("id"),this.dropdown.hide(),this.container.removeClass("select2-dropdown-open").removeClass("select2-container-active"),this.results.empty(),this.clearSearch(),this.search.removeClass("select2-active"),this.opts.element.trigger(a.Event("select2-close"))}},externalSearch:function(a){this.open(),this.search.val(a),this.updateResults(!1)},clearSearch:function(){},getMaximumSelectionSize:function(){return K(this.opts.maximumSelectionSize)},ensureHighlightVisible:function(){var c,d,e,f,g,h,i,b=this.results;if(d=this.highlight(),!(0>d)){if(0==d)return b.scrollTop(0),void 0;c=this.findHighlightableChoices().find(".select2-result-label"),e=a(c[d]),f=e.offset().top+e.outerHeight(!0),d===c.length-1&&(i=b.find("li.select2-more-results"),i.length>0&&(f=i.offset().top+i.outerHeight(!0))),g=b.offset().top+b.outerHeight(!0),f>g&&b.scrollTop(b.scrollTop()+(f-g)),h=e.offset().top-b.offset().top,0>h&&"none"!=e.css("display")&&b.scrollTop(b.scrollTop()+h)}},findHighlightableChoices:function(){return this.results.find(".select2-result-selectable:not(.select2-disabled, .select2-selected)")},moveHighlight:function(b){for(var c=this.findHighlightableChoices(),d=this.highlight();d>-1&&d<c.length;){d+=b;var e=a(c[d]);if(e.hasClass("select2-result-selectable")&&!e.hasClass("select2-disabled")&&!e.hasClass("select2-selected")){this.highlight(d);break}}},highlight:function(b){var d,e,c=this.findHighlightableChoices();return 0===arguments.length?o(c.filter(".select2-highlighted")[0],c.get()):(b>=c.length&&(b=c.length-1),0>b&&(b=0),this.removeHighlight(),d=a(c[b]),d.addClass("select2-highlighted"),this.ensureHighlightVisible(),e=d.data("select2-data"),e&&this.opts.element.trigger({type:"select2-highlight",val:this.id(e),choice:e}),void 0)},removeHighlight:function(){this.results.find(".select2-highlighted").removeClass("select2-highlighted")},countSelectableResults:function(){return this.findHighlightableChoices().length},highlightUnderEvent:function(b){var c=a(b.target).closest(".select2-result-selectable");if(c.length>0&&!c.is(".select2-highlighted")){var d=this.findHighlightableChoices();this.highlight(d.index(c))}else 0==c.length&&this.removeHighlight()},loadMoreIfNeeded:function(){var c,a=this.results,b=a.find("li.select2-more-results"),d=this.resultsPage+1,e=this,f=this.search.val(),g=this.context;0!==b.length&&(c=b.offset().top-a.offset().top-a.height(),c<=this.opts.loadMorePadding&&(b.addClass("select2-active"),this.opts.query({element:this.opts.element,term:f,page:d,context:g,matcher:this.opts.matcher,callback:this.bind(function(c){e.opened()&&(e.opts.populateResults.call(this,a,c.results,{term:f,page:d,context:g}),e.postprocessResults(c,!1,!1),c.more===!0?(b.detach().appendTo(a).text(e.opts.formatLoadMore(d+1)),window.setTimeout(function(){e.loadMoreIfNeeded()},10)):b.remove(),e.positionDropdown(),e.resultsPage=d,e.context=c.context,this.opts.element.trigger({type:"select2-loaded",items:c}))})})))},tokenize:function(){},updateResults:function(c){function m(){d.removeClass("select2-active"),h.positionDropdown()}function n(a){e.html(a),m()}var g,i,l,d=this.search,e=this.results,f=this.opts,h=this,j=d.val(),k=a.data(this.container,"select2-last-term");if((c===!0||!k||!q(j,k))&&(a.data(this.container,"select2-last-term",j),c===!0||this.showSearchInput!==!1&&this.opened())){l=++this.queryCount;var o=this.getMaximumSelectionSize();if(o>=1&&(g=this.data(),a.isArray(g)&&g.length>=o&&J(f.formatSelectionTooBig,"formatSelectionTooBig")))return n("<li class='select2-selection-limit'>"+f.formatSelectionTooBig(o)+"</li>"),void 0;if(d.val().length<f.minimumInputLength)return J(f.formatInputTooShort,"formatInputTooShort")?n("<li class='select2-no-results'>"+f.formatInputTooShort(d.val(),f.minimumInputLength)+"</li>"):n(""),c&&this.showSearch&&this.showSearch(!0),void 0;
22
+ if(f.maximumInputLength&&d.val().length>f.maximumInputLength)return J(f.formatInputTooLong,"formatInputTooLong")?n("<li class='select2-no-results'>"+f.formatInputTooLong(d.val(),f.maximumInputLength)+"</li>"):n(""),void 0;f.formatSearching&&0===this.findHighlightableChoices().length&&n("<li class='select2-searching'>"+f.formatSearching()+"</li>"),d.addClass("select2-active"),this.removeHighlight(),i=this.tokenize(),i!=b&&null!=i&&d.val(i),this.resultsPage=1,f.query({element:f.element,term:d.val(),page:this.resultsPage,context:null,matcher:f.matcher,callback:this.bind(function(g){var i;if(l==this.queryCount){if(!this.opened())return this.search.removeClass("select2-active"),void 0;if(this.context=g.context===b?null:g.context,this.opts.createSearchChoice&&""!==d.val()&&(i=this.opts.createSearchChoice.call(h,d.val(),g.results),i!==b&&null!==i&&h.id(i)!==b&&null!==h.id(i)&&0===a(g.results).filter(function(){return q(h.id(this),h.id(i))}).length&&g.results.unshift(i)),0===g.results.length&&J(f.formatNoMatches,"formatNoMatches"))return n("<li class='select2-no-results'>"+f.formatNoMatches(d.val())+"</li>"),void 0;e.empty(),h.opts.populateResults.call(this,e,g.results,{term:d.val(),page:this.resultsPage,context:null}),g.more===!0&&J(f.formatLoadMore,"formatLoadMore")&&(e.append("<li class='select2-more-results'>"+h.opts.escapeMarkup(f.formatLoadMore(this.resultsPage))+"</li>"),window.setTimeout(function(){h.loadMoreIfNeeded()},10)),this.postprocessResults(g,c),m(),this.opts.element.trigger({type:"select2-loaded",items:g})}})})}},cancel:function(){this.close()},blur:function(){this.opts.selectOnBlur&&this.selectHighlighted({noFocus:!0}),this.close(),this.container.removeClass("select2-container-active"),this.search[0]===document.activeElement&&this.search.blur(),this.clearSearch(),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus")},focusSearch:function(){y(this.search)},selectHighlighted:function(a){var b=this.highlight(),c=this.results.find(".select2-highlighted"),d=c.closest(".select2-result").data("select2-data");d?(this.highlight(b),this.onSelect(d,a)):a&&a.noFocus&&this.close()},getPlaceholder:function(){var a;return this.opts.element.attr("placeholder")||this.opts.element.attr("data-placeholder")||this.opts.element.data("placeholder")||this.opts.placeholder||((a=this.getPlaceholderOption())!==b?a.text():b)},getPlaceholderOption:function(){if(this.select){var a=this.select.children("option").first();if(this.opts.placeholderOption!==b)return"first"===this.opts.placeholderOption&&a||"function"==typeof this.opts.placeholderOption&&this.opts.placeholderOption(this.select);if(""===a.text()&&""===a.val())return a}},initContainerWidth:function(){function c(){var c,d,e,f,g,h;if("off"===this.opts.width)return null;if("element"===this.opts.width)return 0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px";if("copy"===this.opts.width||"resolve"===this.opts.width){if(c=this.opts.element.attr("style"),c!==b)for(d=c.split(";"),f=0,g=d.length;g>f;f+=1)if(h=d[f].replace(/\s/g,""),e=h.match(/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i),null!==e&&e.length>=1)return e[1];return"resolve"===this.opts.width?(c=this.opts.element.css("width"),c.indexOf("%")>0?c:0===this.opts.element.outerWidth(!1)?"auto":this.opts.element.outerWidth(!1)+"px"):null}return a.isFunction(this.opts.width)?this.opts.width():this.opts.width}var d=c.call(this);null!==d&&this.container.css("width",d)}}),e=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container"}).html(["<a href='javascript:void(0)' onclick='return false;' class='select2-choice' tabindex='-1'>"," <span class='select2-chosen'>&nbsp;</span><abbr class='select2-search-choice-close'></abbr>"," <span class='select2-arrow'><b></b></span>","</a>","<input class='select2-focusser select2-offscreen' type='text'/>","<div class='select2-drop select2-display-none'>"," <div class='select2-search'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'/>"," </div>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.focusser.prop("disabled",!this.isInterfaceEnabled())},opening:function(){var c,d,e;this.opts.minimumResultsForSearch>=0&&this.showSearch(!0),this.parent.opening.apply(this,arguments),this.showSearchInput!==!1&&this.search.val(this.focusser.val()),this.search.focus(),c=this.search.get(0),c.createTextRange?(d=c.createTextRange(),d.collapse(!1),d.select()):c.setSelectionRange&&(e=this.search.val().length,c.setSelectionRange(e,e)),""===this.search.val()&&this.nextSearchTerm!=b&&(this.search.val(this.nextSearchTerm),this.search.select()),this.focusser.prop("disabled",!0).val(""),this.updateResults(!0),this.opts.element.trigger(a.Event("select2-open"))},close:function(a){this.opened()&&(this.parent.close.apply(this,arguments),a=a||{focus:!0},this.focusser.removeAttr("disabled"),a.focus&&this.focusser.focus())},focus:function(){this.opened()?this.close():(this.focusser.removeAttr("disabled"),this.focusser.focus())},isFocused:function(){return this.container.hasClass("select2-container-active")},cancel:function(){this.parent.cancel.apply(this,arguments),this.focusser.removeAttr("disabled"),this.focusser.focus()},destroy:function(){a("label[for='"+this.focusser.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var b,d=this.container,e=this.dropdown;this.opts.minimumResultsForSearch<0?this.showSearch(!1):this.showSearch(!0),this.selection=b=d.find(".select2-choice"),this.focusser=d.find(".select2-focusser"),this.focusser.attr("id","s2id_autogen"+g()),a("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.focusser.attr("id")),this.focusser.attr("tabindex",this.elementTabIndex),this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){if(a.which===c.PAGE_UP||a.which===c.PAGE_DOWN)return A(a),void 0;switch(a.which){case c.UP:case c.DOWN:return this.moveHighlight(a.which===c.UP?-1:1),A(a),void 0;case c.ENTER:return this.selectHighlighted(),A(a),void 0;case c.TAB:return this.selectHighlighted({noFocus:!0}),void 0;case c.ESC:return this.cancel(a),A(a),void 0}}})),this.search.on("blur",this.bind(function(){document.activeElement===this.body().get(0)&&window.setTimeout(this.bind(function(){this.search.focus()}),0)})),this.focusser.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()&&a.which!==c.TAB&&!c.isControl(a)&&!c.isFunctionKey(a)&&a.which!==c.ESC){if(this.opts.openOnEnter===!1&&a.which===c.ENTER)return A(a),void 0;if(a.which==c.DOWN||a.which==c.UP||a.which==c.ENTER&&this.opts.openOnEnter){if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return;return this.open(),A(a),void 0}return a.which==c.DELETE||a.which==c.BACKSPACE?(this.opts.allowClear&&this.clear(),A(a),void 0):void 0}})),t(this.focusser),this.focusser.on("keyup-change input",this.bind(function(a){if(this.opts.minimumResultsForSearch>=0){if(a.stopPropagation(),this.opened())return;this.open()}})),b.on("mousedown","abbr",this.bind(function(a){this.isInterfaceEnabled()&&(this.clear(),B(a),this.close(),this.selection.focus())})),b.on("mousedown",this.bind(function(b){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.opened()?this.close():this.isInterfaceEnabled()&&this.open(),A(b)})),e.on("mousedown",this.bind(function(){this.search.focus()})),b.on("focus",this.bind(function(a){A(a)})),this.focusser.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})).on("blur",this.bind(function(){this.opened()||(this.container.removeClass("select2-container-active"),this.opts.element.trigger(a.Event("select2-blur")))})),this.search.on("focus",this.bind(function(){this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active")})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.setPlaceholder()},clear:function(b){var c=this.selection.data("select2-data");if(c){var d=a.Event("select2-clearing");if(this.opts.element.trigger(d),d.isDefaultPrevented())return;var e=this.getPlaceholderOption();this.opts.element.val(e?e.val():""),this.selection.find(".select2-chosen").empty(),this.selection.removeData("select2-data"),this.setPlaceholder(),b!==!1&&(this.opts.element.trigger({type:"select2-removed",val:this.id(c),choice:c}),this.triggerChange({removed:c}))}},initSelection:function(){if(this.isPlaceholderOptionSelected())this.updateSelection(null),this.close(),this.setPlaceholder();else{var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.setPlaceholder())})}},isPlaceholderOptionSelected:function(){var a;return this.getPlaceholder()?(a=this.getPlaceholderOption())!==b&&a.prop("selected")||""===this.opts.element.val()||this.opts.element.val()===b||null===this.opts.element.val():!1},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=a.find("option").filter(function(){return this.selected});b(c.optionToData(d))}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=c.val(),f=null;b.query({matcher:function(a,c,d){var g=q(e,b.id(d));return g&&(f=d),g},callback:a.isFunction(d)?function(){d(f)}:a.noop})}),b},getPlaceholder:function(){return this.select&&this.getPlaceholderOption()===b?b:this.parent.getPlaceholder.apply(this,arguments)},setPlaceholder:function(){var a=this.getPlaceholder();if(this.isPlaceholderOptionSelected()&&a!==b){if(this.select&&this.getPlaceholderOption()===b)return;this.selection.find(".select2-chosen").html(this.opts.escapeMarkup(a)),this.selection.addClass("select2-default"),this.container.removeClass("select2-allowclear")}},postprocessResults:function(a,b,c){var d=0,e=this;if(this.findHighlightableChoices().each2(function(a,b){return q(e.id(b.data("select2-data")),e.opts.element.val())?(d=a,!1):void 0}),c!==!1&&(b===!0&&d>=0?this.highlight(d):this.highlight(0)),b===!0){var g=this.opts.minimumResultsForSearch;g>=0&&this.showSearch(L(a.results)>=g)}},showSearch:function(b){this.showSearchInput!==b&&(this.showSearchInput=b,this.dropdown.find(".select2-search").toggleClass("select2-search-hidden",!b),this.dropdown.find(".select2-search").toggleClass("select2-offscreen",!b),a(this.dropdown,this.container).toggleClass("select2-with-searchbox",b))},onSelect:function(a,b){if(this.triggerSelect(a)){var c=this.opts.element.val(),d=this.data();this.opts.element.val(this.id(a)),this.updateSelection(a),this.opts.element.trigger({type:"select2-selected",val:this.id(a),choice:a}),this.nextSearchTerm=this.opts.nextSearchTerm(a,this.search.val()),this.close(),b&&b.noFocus||this.focusser.focus(),q(c,this.id(a))||this.triggerChange({added:a,removed:d})}},updateSelection:function(a){var d,e,c=this.selection.find(".select2-chosen");this.selection.data("select2-data",a),c.empty(),null!==a&&(d=this.opts.formatSelection(a,c,this.opts.escapeMarkup)),d!==b&&c.append(d),e=this.opts.formatSelectionCssClass(a,c),e!==b&&c.addClass(e),this.selection.removeClass("select2-default"),this.opts.allowClear&&this.getPlaceholder()!==b&&this.container.addClass("select2-allowclear")},val:function(){var a,c=!1,d=null,e=this,f=this.data();if(0===arguments.length)return this.opts.element.val();if(a=arguments[0],arguments.length>1&&(c=arguments[1]),this.select)this.select.val(a).find("option").filter(function(){return this.selected}).each2(function(a,b){return d=e.optionToData(b),!1}),this.updateSelection(d),this.setPlaceholder(),c&&this.triggerChange({added:d,removed:f});else{if(!a&&0!==a)return this.clear(c),void 0;if(this.opts.initSelection===b)throw new Error("cannot call val() if initSelection() is not defined");this.opts.element.val(a),this.opts.initSelection(this.opts.element,function(a){e.opts.element.val(a?e.id(a):""),e.updateSelection(a),e.setPlaceholder(),c&&e.triggerChange({added:a,removed:f})})}},clearSearch:function(){this.search.val(""),this.focusser.val("")},data:function(a){var c,d=!1;return 0===arguments.length?(c=this.selection.data("select2-data"),c==b&&(c=null),c):(arguments.length>1&&(d=arguments[1]),a?(c=this.data(),this.opts.element.val(a?this.id(a):""),this.updateSelection(a),d&&this.triggerChange({added:a,removed:c})):this.clear(d),void 0)}}),f=N(d,{createContainer:function(){var b=a(document.createElement("div")).attr({"class":"select2-container select2-container-multi"}).html(["<ul class='select2-choices'>"," <li class='select2-search-field'>"," <input type='text' autocomplete='off' autocorrect='off' autocapitalize='off' spellcheck='false' class='select2-input'>"," </li>","</ul>","<div class='select2-drop select2-drop-multi select2-display-none'>"," <ul class='select2-results'>"," </ul>","</div>"].join(""));return b},prepareOpts:function(){var b=this.parent.prepareOpts.apply(this,arguments),c=this;return"select"===b.element.get(0).tagName.toLowerCase()?b.initSelection=function(a,b){var d=[];a.find("option").filter(function(){return this.selected}).each2(function(a,b){d.push(c.optionToData(b))}),b(d)}:"data"in b&&(b.initSelection=b.initSelection||function(c,d){var e=r(c.val(),b.separator),f=[];b.query({matcher:function(c,d,g){var h=a.grep(e,function(a){return q(a,b.id(g))}).length;return h&&f.push(g),h},callback:a.isFunction(d)?function(){for(var a=[],c=0;c<e.length;c++)for(var g=e[c],h=0;h<f.length;h++){var i=f[h];if(q(g,b.id(i))){a.push(i),f.splice(h,1);break}}d(a)}:a.noop})}),b},selectChoice:function(a){var b=this.container.find(".select2-search-choice-focus");b.length&&a&&a[0]==b[0]||(b.length&&this.opts.element.trigger("choice-deselected",b),b.removeClass("select2-search-choice-focus"),a&&a.length&&(this.close(),a.addClass("select2-search-choice-focus"),this.opts.element.trigger("choice-selected",a)))},destroy:function(){a("label[for='"+this.search.attr("id")+"']").attr("for",this.opts.element.attr("id")),this.parent.destroy.apply(this,arguments)},initContainer:function(){var d,b=".select2-choices";this.searchContainer=this.container.find(".select2-search-field"),this.selection=d=this.container.find(b);var e=this;this.selection.on("click",".select2-search-choice:not(.select2-locked)",function(){e.search[0].focus(),e.selectChoice(a(this))}),this.search.attr("id","s2id_autogen"+g()),a("label[for='"+this.opts.element.attr("id")+"']").attr("for",this.search.attr("id")),this.search.on("input paste",this.bind(function(){this.isInterfaceEnabled()&&(this.opened()||this.open())})),this.search.attr("tabindex",this.elementTabIndex),this.keydowns=0,this.search.on("keydown",this.bind(function(a){if(this.isInterfaceEnabled()){++this.keydowns;var b=d.find(".select2-search-choice-focus"),e=b.prev(".select2-search-choice:not(.select2-locked)"),f=b.next(".select2-search-choice:not(.select2-locked)"),g=z(this.search);if(b.length&&(a.which==c.LEFT||a.which==c.RIGHT||a.which==c.BACKSPACE||a.which==c.DELETE||a.which==c.ENTER)){var h=b;return a.which==c.LEFT&&e.length?h=e:a.which==c.RIGHT?h=f.length?f:null:a.which===c.BACKSPACE?(this.unselect(b.first()),this.search.width(10),h=e.length?e:f):a.which==c.DELETE?(this.unselect(b.first()),this.search.width(10),h=f.length?f:null):a.which==c.ENTER&&(h=null),this.selectChoice(h),A(a),h&&h.length||this.open(),void 0}if((a.which===c.BACKSPACE&&1==this.keydowns||a.which==c.LEFT)&&0==g.offset&&!g.length)return this.selectChoice(d.find(".select2-search-choice:not(.select2-locked)").last()),A(a),void 0;if(this.selectChoice(null),this.opened())switch(a.which){case c.UP:case c.DOWN:return this.moveHighlight(a.which===c.UP?-1:1),A(a),void 0;case c.ENTER:return this.selectHighlighted(),A(a),void 0;case c.TAB:return this.selectHighlighted({noFocus:!0}),this.close(),void 0;case c.ESC:return this.cancel(a),A(a),void 0}if(a.which!==c.TAB&&!c.isControl(a)&&!c.isFunctionKey(a)&&a.which!==c.BACKSPACE&&a.which!==c.ESC){if(a.which===c.ENTER){if(this.opts.openOnEnter===!1)return;if(a.altKey||a.ctrlKey||a.shiftKey||a.metaKey)return}this.open(),(a.which===c.PAGE_UP||a.which===c.PAGE_DOWN)&&A(a),a.which===c.ENTER&&A(a)}}})),this.search.on("keyup",this.bind(function(){this.keydowns=0,this.resizeSearch()})),this.search.on("blur",this.bind(function(b){this.container.removeClass("select2-container-active"),this.search.removeClass("select2-focused"),this.selectChoice(null),this.opened()||this.clearSearch(),b.stopImmediatePropagation(),this.opts.element.trigger(a.Event("select2-blur"))})),this.container.on("click",b,this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").length>0||(this.selectChoice(null),this.clearPlaceholder(),this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.open(),this.focusSearch(),b.preventDefault()))})),this.container.on("focus",b,this.bind(function(){this.isInterfaceEnabled()&&(this.container.hasClass("select2-container-active")||this.opts.element.trigger(a.Event("select2-focus")),this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"),this.clearPlaceholder())})),this.initContainerWidth(),this.opts.element.addClass("select2-offscreen"),this.clearSearch()},enableInterface:function(){this.parent.enableInterface.apply(this,arguments)&&this.search.prop("disabled",!this.isInterfaceEnabled())},initSelection:function(){if(""===this.opts.element.val()&&""===this.opts.element.text()&&(this.updateSelection([]),this.close(),this.clearSearch()),this.select||""!==this.opts.element.val()){var c=this;this.opts.initSelection.call(null,this.opts.element,function(a){a!==b&&null!==a&&(c.updateSelection(a),c.close(),c.clearSearch())})}},clearSearch:function(){var a=this.getPlaceholder(),c=this.getMaxSearchWidth();a!==b&&0===this.getVal().length&&this.search.hasClass("select2-focused")===!1?(this.search.val(a).addClass("select2-default"),this.search.width(c>0?c:this.container.css("width"))):this.search.val("").width(10)},clearPlaceholder:function(){this.search.hasClass("select2-default")&&this.search.val("").removeClass("select2-default")},opening:function(){this.clearPlaceholder(),this.resizeSearch(),this.parent.opening.apply(this,arguments),this.focusSearch(),this.updateResults(!0),this.search.focus(),this.opts.element.trigger(a.Event("select2-open"))},close:function(){this.opened()&&this.parent.close.apply(this,arguments)},focus:function(){this.close(),this.search.focus()},isFocused:function(){return this.search.hasClass("select2-focused")},updateSelection:function(b){var c=[],d=[],e=this;a(b).each(function(){o(e.id(this),c)<0&&(c.push(e.id(this)),d.push(this))}),b=d,this.selection.find(".select2-search-choice").remove(),a(b).each(function(){e.addSelectedChoice(this)}),e.postprocessResults()},tokenize:function(){var a=this.search.val();a=this.opts.tokenizer.call(this,a,this.data(),this.bind(this.onSelect),this.opts),null!=a&&a!=b&&(this.search.val(a),a.length>0&&this.open())},onSelect:function(a,b){this.triggerSelect(a)&&(this.addSelectedChoice(a),this.opts.element.trigger({type:"selected",val:this.id(a),choice:a}),(this.select||!this.opts.closeOnSelect)&&this.postprocessResults(a,!1,this.opts.closeOnSelect===!0),this.opts.closeOnSelect?(this.close(),this.search.width(10)):this.countSelectableResults()>0?(this.search.width(10),this.resizeSearch(),this.getMaximumSelectionSize()>0&&this.val().length>=this.getMaximumSelectionSize()&&this.updateResults(!0),this.positionDropdown()):(this.close(),this.search.width(10)),this.triggerChange({added:a}),b&&b.noFocus||this.focusSearch())},cancel:function(){this.close(),this.focusSearch()},addSelectedChoice:function(c){var j,k,d=!c.locked,e=a("<li class='select2-search-choice'> <div></div> <a href='#' onclick='return false;' class='select2-search-choice-close' tabindex='-1'></a></li>"),f=a("<li class='select2-search-choice select2-locked'><div></div></li>"),g=d?e:f,h=this.id(c),i=this.getVal();j=this.opts.formatSelection(c,g.find("div"),this.opts.escapeMarkup),j!=b&&g.find("div").replaceWith("<div>"+j+"</div>"),k=this.opts.formatSelectionCssClass(c,g.find("div")),k!=b&&g.addClass(k),d&&g.find(".select2-search-choice-close").on("mousedown",A).on("click dblclick",this.bind(function(b){this.isInterfaceEnabled()&&(a(b.target).closest(".select2-search-choice").fadeOut("fast",this.bind(function(){this.unselect(a(b.target)),this.selection.find(".select2-search-choice-focus").removeClass("select2-search-choice-focus"),this.close(),this.focusSearch()})).dequeue(),A(b))})).on("focus",this.bind(function(){this.isInterfaceEnabled()&&(this.container.addClass("select2-container-active"),this.dropdown.addClass("select2-drop-active"))})),g.data("select2-data",c),g.insertBefore(this.searchContainer),i.push(h),this.setVal(i)},unselect:function(b){var d,e,c=this.getVal();if(b=b.closest(".select2-search-choice"),0===b.length)throw"Invalid argument: "+b+". Must be .select2-search-choice";if(d=b.data("select2-data")){for(;(e=o(this.id(d),c))>=0;)c.splice(e,1),this.setVal(c),this.select&&this.postprocessResults();var f=a.Event("select2-removing");f.val=this.id(d),f.choice=d,this.opts.element.trigger(f),f.isDefaultPrevented()||(b.remove(),this.opts.element.trigger({type:"select2-removed",val:this.id(d),choice:d}),this.triggerChange({removed:d}))}},postprocessResults:function(a,b,c){var d=this.getVal(),e=this.results.find(".select2-result"),f=this.results.find(".select2-result-with-children"),g=this;e.each2(function(a,b){var c=g.id(b.data("select2-data"));o(c,d)>=0&&(b.addClass("select2-selected"),b.find(".select2-result-selectable").addClass("select2-selected"))}),f.each2(function(a,b){b.is(".select2-result-selectable")||0!==b.find(".select2-result-selectable:not(.select2-selected)").length||b.addClass("select2-selected")}),-1==this.highlight()&&c!==!1&&g.highlight(0),!this.opts.createSearchChoice&&!e.filter(".select2-result:not(.select2-selected)").length>0&&(!a||a&&!a.more&&0===this.results.find(".select2-no-results").length)&&J(g.opts.formatNoMatches,"formatNoMatches")&&this.results.append("<li class='select2-no-results'>"+g.opts.formatNoMatches(g.search.val())+"</li>")},getMaxSearchWidth:function(){return this.selection.width()-s(this.search)},resizeSearch:function(){var a,b,c,d,e,f=s(this.search);a=C(this.search)+10,b=this.search.offset().left,c=this.selection.width(),d=this.selection.offset().left,e=c-(b-d)-f,a>e&&(e=c-f),40>e&&(e=c-f),0>=e&&(e=a),this.search.width(Math.floor(e))},getVal:function(){var a;return this.select?(a=this.select.val(),null===a?[]:a):(a=this.opts.element.val(),r(a,this.opts.separator))},setVal:function(b){var c;this.select?this.select.val(b):(c=[],a(b).each(function(){o(this,c)<0&&c.push(this)}),this.opts.element.val(0===c.length?"":c.join(this.opts.separator)))},buildChangeDetails:function(a,b){for(var b=b.slice(0),a=a.slice(0),c=0;c<b.length;c++)for(var d=0;d<a.length;d++)q(this.opts.id(b[c]),this.opts.id(a[d]))&&(b.splice(c,1),c>0&&c--,a.splice(d,1),d--);return{added:b,removed:a}},val:function(c,d){var e,f=this;if(0===arguments.length)return this.getVal();if(e=this.data(),e.length||(e=[]),!c&&0!==c)return this.opts.element.val(""),this.updateSelection([]),this.clearSearch(),d&&this.triggerChange({added:this.data(),removed:e}),void 0;if(this.setVal(c),this.select)this.opts.initSelection(this.select,this.bind(this.updateSelection)),d&&this.triggerChange(this.buildChangeDetails(e,this.data()));else{if(this.opts.initSelection===b)throw new Error("val() cannot be called if initSelection() is not defined");this.opts.initSelection(this.opts.element,function(b){var c=a.map(b,f.id);f.setVal(c),f.updateSelection(b),f.clearSearch(),d&&f.triggerChange(f.buildChangeDetails(e,f.data()))})}this.clearSearch()},onSortStart:function(){if(this.select)throw new Error("Sorting of elements is not supported when attached to <select>. Attach to <input type='hidden'/> instead.");this.search.width(0),this.searchContainer.hide()},onSortEnd:function(){var b=[],c=this;this.searchContainer.show(),this.searchContainer.appendTo(this.searchContainer.parent()),this.resizeSearch(),this.selection.find(".select2-search-choice").each(function(){b.push(c.opts.id(a(this).data("select2-data")))}),this.setVal(b),this.triggerChange()},data:function(b,c){var e,f,d=this;return 0===arguments.length?this.selection.find(".select2-search-choice").map(function(){return a(this).data("select2-data")}).get():(f=this.data(),b||(b=[]),e=a.map(b,function(a){return d.opts.id(a)}),this.setVal(e),this.updateSelection(b),this.clearSearch(),c&&this.triggerChange(this.buildChangeDetails(f,this.data())),void 0)}}),a.fn.select2=function(){var d,g,h,i,j,c=Array.prototype.slice.call(arguments,0),k=["val","destroy","opened","open","close","focus","isFocused","container","dropdown","onSortStart","onSortEnd","enable","disable","readonly","positionDropdown","data","search"],l=["opened","isFocused","container","dropdown"],m=["val","data"],n={search:"externalSearch"};return this.each(function(){if(0===c.length||"object"==typeof c[0])d=0===c.length?{}:a.extend({},c[0]),d.element=a(this),"select"===d.element.get(0).tagName.toLowerCase()?j=d.element.prop("multiple"):(j=d.multiple||!1,"tags"in d&&(d.multiple=j=!0)),g=j?new f:new e,g.init(d);else{if("string"!=typeof c[0])throw"Invalid arguments to select2 plugin: "+c;if(o(c[0],k)<0)throw"Unknown method: "+c[0];if(i=b,g=a(this).data("select2"),g===b)return;if(h=c[0],"container"===h?i=g.container:"dropdown"===h?i=g.dropdown:(n[h]&&(h=n[h]),i=g[h].apply(g,c.slice(1))),o(c[0],l)>=0||o(c[0],m)&&1==c.length)return!1}}),i===b?this:i},a.fn.select2.defaults={width:"copy",loadMorePadding:0,closeOnSelect:!0,openOnEnter:!0,containerCss:{},dropdownCss:{},containerCssClass:"",dropdownCssClass:"",formatResult:function(a,b,c,d){var e=[];return E(a.text,c.term,e,d),e.join("")},formatSelection:function(a,c,d){return a?d(a.text):b},sortResults:function(a){return a},formatResultCssClass:function(){return b},formatSelectionCssClass:function(){return b},formatNoMatches:function(){return"No matches found"},formatInputTooShort:function(a,b){var c=b-a.length;return"Please enter "+c+" more character"+(1==c?"":"s")},formatInputTooLong:function(a,b){var c=a.length-b;return"Please delete "+c+" character"+(1==c?"":"s")},formatSelectionTooBig:function(a){return"You can only select "+a+" item"+(1==a?"":"s")},formatLoadMore:function(){return"Loading more results..."},formatSearching:function(){return"Searching..."},minimumResultsForSearch:0,minimumInputLength:0,maximumInputLength:null,maximumSelectionSize:0,id:function(a){return a.id},matcher:function(a,b){return n(""+b).toUpperCase().indexOf(n(""+a).toUpperCase())>=0},separator:",",tokenSeparators:[],tokenizer:M,escapeMarkup:F,blurOnChange:!1,selectOnBlur:!1,adaptContainerCssClass:function(a){return a},adaptDropdownCssClass:function(){return null},nextSearchTerm:function(){return b}},a.fn.select2.ajaxDefaults={transport:a.ajax,params:{type:"GET",cache:!1,dataType:"json"}},window.Select2={query:{ajax:G,local:H,tags:I},util:{debounce:v,markMatch:E,escapeMarkup:F,stripDiacritics:n},"class":{"abstract":d,single:e,multi:f}}}}(jQuery);
static/js/pmxi.js CHANGED
@@ -9,25 +9,6 @@
9
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss', {dismiss: true}, function (data) {
10
 
11
  }, 'html');
12
-
13
- });
14
-
15
- $('#dismiss_manage_top').click(function(){
16
-
17
- $(this).parents('div.updated:first').slideUp();
18
- $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_top', {dismiss: true}, function (data) {
19
-
20
- }, 'html');
21
-
22
  });
23
-
24
- $('#dismiss_manage_bottom').click(function(){
25
-
26
- $(this).parents('div.updated_bottom:first').slideUp();
27
- $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_bottom', {dismiss: true}, function (data) {
28
-
29
- }, 'html');
30
-
31
- });
32
-
33
  });})(jQuery);
9
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss', {dismiss: true}, function (data) {
10
 
11
  }, 'html');
 
 
 
 
 
 
 
 
 
 
12
  });
13
+
 
 
 
 
 
 
 
 
 
14
  });})(jQuery);
views/admin/addons/index.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap" style="max-width:970px;">
2
+
3
+ <h2><?php _e('WP All Import Add-ons', 'pmxi_plugin') ?></h2>
4
+
5
+ <div id="pmxi-add-ons" class="clear">
6
+
7
+ <div class="pmxi-add-on-group clear">
8
+ <?php foreach( $premium as $addon ): ?>
9
+ <div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
10
+ <a target="_blank" href="<?php echo $addon['url']; ?>">
11
+ <img src="<?php echo $addon['thumbnail']; ?>" />
12
+ </a>
13
+ <div class="inner">
14
+ <h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
15
+ <p><?php echo $addon['description']; ?></p>
16
+ </div>
17
+ <div class="footer">
18
+ <?php if ( $addon['active'] ): ?>
19
+ <a class="button button-disabled"><span class="pmxi-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
20
+ <?php elseif ( $addon['free_installed'] ): ?>
21
+ <a class="button button-disabled"><span class="pmxi-sprite-tick"></span><?php _e("Free Version Installed",'acf'); ?></a>
22
+ <?php elseif ($addon['required_plugins']): ?>
23
+ <?php
24
+ $all_required_plugins_installed = true;
25
+ foreach ($addon['required_plugins'] as $name => $active):
26
+ if (!$active){
27
+ ?>
28
+ <p style="margin:3px 0px;"><?php echo $name . __(' required', 'pmxi_plugin'); ?></p>
29
+ <?php
30
+ $all_required_plugins_installed = false;
31
+ }
32
+ endforeach;
33
+ if ($all_required_plugins_installed){
34
+ ?>
35
+ <a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Download",'acf'); ?></a>
36
+ <?php
37
+ }
38
+ ?>
39
+ <?php else: ?>
40
+ <a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Purchase & Install",'acf'); ?></a>
41
+ <?php endif; ?>
42
+ </div>
43
+ </div>
44
+ <?php endforeach; ?>
45
+ </div>
46
+
47
+ <div class="pmxi-add-on-group clear">
48
+ <?php foreach( $free as $addon ): ?>
49
+ <div class="pmxi-add-on wp-box <?php if( $addon['active'] ): ?>pmxi-add-on-active<?php endif; ?>">
50
+ <a target="_blank" href="<?php echo $addon['url']; ?>">
51
+ <img src="<?php echo $addon['thumbnail']; ?>" />
52
+ </a>
53
+ <div class="inner">
54
+ <h3><a target="_blank" href="<?php echo $addon['url']; ?>"><?php echo $addon['title']; ?></a></h3>
55
+ <p><?php echo $addon['description']; ?></p>
56
+ </div>
57
+ <div class="footer">
58
+ <?php if( $addon['active'] ): ?>
59
+ <a class="button button-disabled"><span class="pmxi-sprite-tick"></span><?php _e("Installed",'acf'); ?></a>
60
+ <?php elseif ($addon['paid_installed']): ?>
61
+ <a class="button button-disabled"><span class="pmxi-sprite-tick"></span><?php _e("Paid Version Installed",'acf'); ?></a>
62
+ <?php elseif ($addon['required_plugins']): ?>
63
+ <?php
64
+ $all_required_plugins_installed = true;
65
+ foreach ($addon['required_plugins'] as $name => $active):
66
+ if (!$active){
67
+ ?>
68
+ <p style="margin:3px 0px;"><?php echo $name . __(' required', 'pmxi_plugin'); ?></p>
69
+ <?php
70
+ $all_required_plugins_installed = false;
71
+ }
72
+ endforeach;
73
+ if ($all_required_plugins_installed){
74
+ ?>
75
+ <a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Download",'acf'); ?></a>
76
+ <?php
77
+ }
78
+ ?>
79
+ <?php else: ?>
80
+ <a target="_blank" href="<?php echo $addon['url']; ?>" class="button"><?php _e("Download",'acf'); ?></a>
81
+ <?php endif; ?>
82
+ </div>
83
+ </div>
84
+ <?php endforeach; ?>
85
+ </div>
86
+
87
+
88
+ </div>
89
+
90
+ </div>
91
+ <script type="text/javascript">
92
+ (function($) {
93
+
94
+ $(window).load(function(){
95
+
96
+ $('#pmxi-add-ons .pmxi-add-on-group').each(function(){
97
+
98
+ var $el = $(this),
99
+ h = 0;
100
+
101
+
102
+ $el.find('.pmxi-add-on').each(function(){
103
+
104
+ h = Math.max( $(this).height(), h );
105
+
106
+ });
107
+
108
+ $el.find('.pmxi-add-on').height( h );
109
+
110
+ });
111
+
112
+ });
113
+
114
+ })(jQuery);
115
+ </script>
views/admin/cron/index.php ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <h2><?php _e('WP All Import Scheduled Imports', 'pmxi_plugin') ?></h2>
2
+
views/admin/help/index.php CHANGED
@@ -12,7 +12,7 @@
12
 
13
  <p style='font-size: 1.3em;'>We are able to provide limited technical support to free version users. Support is not guaranteed, and is based on availability</p>
14
 
15
- <p style='font-size: 1.3em;'><b>Please note we are unable to provide technical support via the WordPress.org community forums.</b></p>
16
 
17
  <p style='font-size: 1.3em;'><a href='http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=support&utm_campaign=free+plugin' target='_blank'>For premium support, please upgrade to the professional edition of WP All Import.</a></p>
18
 
12
 
13
  <p style='font-size: 1.3em;'>We are able to provide limited technical support to free version users. Support is not guaranteed, and is based on availability</p>
14
 
15
+ <p style='font-size: 1.3em;'><b>Please note we generally do not provide technical support via the WordPress.org community forums.</b></p>
16
 
17
  <p style='font-size: 1.3em;'><a href='http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=support&utm_campaign=free+plugin' target='_blank'>For premium support, please upgrade to the professional edition of WP All Import.</a></p>
18
 
views/admin/import/element.php CHANGED
@@ -1 +1,107 @@
1
- <?php //stub ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <form class="choose-elements no-enter-submit" method="post">
2
+ <h2><?php _e('Import XML/CSV - Step 2: Select Elements', 'pmxi_plugin') ?></h2>
3
+
4
+ <h3><?php _e('<b>Double-click on an element below to select it and its siblings.</b>', 'pmxi_plugin') ?></h3>
5
+
6
+ <div class="ajax-console">
7
+ <?php if ($this->errors->get_error_codes()): ?>
8
+ <?php $this->error() ?>
9
+ <?php endif ?>
10
+ </div>
11
+ <table class="layout">
12
+ <tr>
13
+ <td class="left" style="width:60%;">
14
+ <fieldset class="widefat">
15
+ <legend><?php _e('Current XML tree', 'pmxi_plugin');?></legend>
16
+ <div class="action_buttons">
17
+ <a href="javascript:void(0);" id="prev_element" class="button button-primary button-hero large_button go_to">&laquo;</a>
18
+ <a href="javascript:void(0);" id="next_element" class="button button-primary button-hero large_button go_to" style="margin-right:15px;">&raquo;</a>
19
+ <div style="float:left;">
20
+ <span style="font-size:20px; padding-top:17px; float:left; margin-right:10px;"><?php _e('Go to:','pmxi_plugin');?> </span><input type="text" id="goto_element" value="1"/>
21
+ </div>
22
+ <?php
23
+ if ($is_csv !== false){
24
+ ?>
25
+ <ul class="set_csv_delimiter">
26
+ <li><?php _e("Set delimiter for CSV fields:",'pmxi_plugin');?> </li>
27
+ <li> <input type="text" value="<?php echo $is_csv;?>" name="delimiter"/> <input type="button" name="apply_delimiter" value="Apply"/></li>
28
+ </ul>
29
+ <?php
30
+ }
31
+ else{
32
+ ?>
33
+ <input type="hidden" value="" name="delimiter"/>
34
+ <?php
35
+ }
36
+ ?>
37
+ </div>
38
+ <div class="xml" style="min-height:400px;">
39
+ <?php //$this->render_xml_element($dom->documentElement) ?>
40
+ </div>
41
+ </fieldset>
42
+ </td>
43
+ <td class="right" style="width:40%;">
44
+ <fieldset class="widefat">
45
+ <legend><?php _e('Fitering Options','pmxi_plugin');?></legend>
46
+ <p><?php _e('Manual XPath:','pmxi_plugin');?></p>
47
+ <div>
48
+ <input type="text" name="xpath" value="<?php echo esc_attr($post['xpath']) ?>" style="max-width:none;" />
49
+ <input type="hidden" id="root_element" name="root_element" value="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>"/>
50
+ <?php
51
+ if (!empty($elements_cloud)){
52
+ ?>
53
+ &nbsp; <br/><label><?php _e('What element are you looking for?','pmxi_plugin');?></label>&nbsp; <br/>
54
+ <?php
55
+ $root_elements = array();
56
+ foreach ($elements_cloud as $tag => $count)
57
+ $root_elements[] = '<a href="javascript:void(0);" rel="'. $tag .'" class="change_root_element">' . $tag . '</a>';
58
+ echo implode(', ', $root_elements);
59
+ }
60
+ ?>
61
+ &nbsp; <br/><br/>or <a href="javascript:void(0);" rel="<?php echo esc_attr($post['xpath']) ?>" root="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>" id="get_default_xpath"><?php _e('get default xPath','pmxi_plugin');?></a>
62
+ </div>
63
+ <p><?php _e('Filters:','pmxi_plugin');?></p>
64
+ <div>
65
+ <select id="pmxi_xml_element">
66
+ <option value=""><?php _e('Select Element', 'pmxi_plugin'); ?></option>
67
+ <?php $this->render_xml_elements_for_filtring($elements->item(0)); ?>
68
+ </select>
69
+ <select id="pmxi_rule">
70
+ <option value=""><?php _e('Select Rule', 'pmxi_plugin'); ?></option>
71
+ <option value="equals"><?php _e('equals', 'pmxi_plugin'); ?></option>
72
+ <option value="greater"><?php _e('greater than', 'pmxi_plugin');?></option>
73
+ <option value="equals_or_greater"><?php _e('equals or greater than', 'pmxi_plugin'); ?></option>
74
+ <option value="less"><?php _e('less than', 'pmxi_plugin'); ?></option>
75
+ <option value="equals_or_less"><?php _e('equals or less than', 'pmxi_plugin'); ?></option>
76
+ <option value="contains"><?php _e('contains', 'pmxi_plugin'); ?></option>
77
+ <option value="is_empty"><?php _e('is empty', 'pmxi_plugin'); ?></option>
78
+ <option value="is_not_empty"><?php _e('is not empty', 'pmxi_plugin'); ?></option>
79
+ </select>
80
+ <input id="pmxi_value" type="text" placeholder="value" value=""/>
81
+ <a id="pmxi_add_rule" href="javascript:void(0);"><?php _e('Add rule', 'pmxi_plugin');?></a>
82
+ </div>
83
+ <div class="clear"></div>
84
+ <div>
85
+ <fieldset id="filtering_rules">
86
+ <legend><?php _e('Rules', 'pmxi_plugin'); ?></legend>
87
+ <p style="margin-top:5px;"><?php _e('No filtering options. Add filtering options to only import records matching some specified criteria.');?></p>
88
+ <ol class="filtering_rules">
89
+
90
+ </ol>
91
+ <a href="javascript:void(0);" id="apply_filters" style="display:none;"><?php _e('Apply Filters', 'pmxi_plugin');?></a>
92
+ </fieldset>
93
+ </div>
94
+ <br><br>
95
+ <a href="http://www.w3schools.com/xpath/default.asp" target='_blank'><?php _e('XPath Tutorial','pmxi_plugin');?></a> - <?php _e('For further help','pmxi_plugin');?>, <a href="http://www.wpallimport.com/support" target='_blank'><?php _e('contact us','pmxi_plugin');?></a>.
96
+ </fieldset>
97
+ <p class="submit-buttons" style="text-align:right;">
98
+ <a href="<?php echo $this->baseUrl ?>" class="back"><?php _e('Back','pmxi_plugin');?></a>
99
+ &nbsp;
100
+ <input type="hidden" name="is_submitted" value="1" />
101
+ <?php wp_nonce_field('choose-elements', '_wpnonce_choose-elements') ?>
102
+ <input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Next', 'pmxi_plugin') ?>" />
103
+ </p>
104
+ </td>
105
+ </tr>
106
+ </table>
107
+ </form>
views/admin/import/element_after.php CHANGED
@@ -10,7 +10,7 @@
10
  </div>
11
  <table class="layout">
12
  <tr>
13
- <td class="left">
14
  <fieldset class="widefat">
15
  <legend><?php _e('Current XML tree', 'pmxi_plugin');?></legend>
16
  <div class="action_buttons">
@@ -23,11 +23,7 @@
23
  if ($is_csv !== false){
24
  ?>
25
  <ul class="set_csv_delimiter">
26
- <li>Set delimiter for CSV fields: </li>
27
- <!--li> <a href="javascript:void(0);" rel="," <?php if ($is_csv == ','):?>class="delimiter_selected"<?php endif;?>><?php _e('comma', 'pmxi_plugin');?></a> </li>
28
- <li> <a href="javascript:void(0);" rel=";" <?php if ($is_csv == ';'):?>class="delimiter_selected"<?php endif;?>><?php _e('semicolon', 'pmxi_plugin');?></a> </li>
29
- <li> <a href="javascript:void(0);" rel="|" <?php if ($is_csv == '|'):?>class="delimiter_selected"<?php endif;?>><?php _e('pipe', 'pmxi_plugin');?></a> </li>
30
- <li> <a href="javascript:void(0);" rel="\t" <?php if ($is_csv == '\t'):?>class="delimiter_selected"<?php endif;?>><?php _e('tabulation', 'pmxi_plugin');?></a> </li-->
31
  <li> <input type="text" value="<?php echo $is_csv;?>" name="delimiter"/> <input type="button" name="apply_delimiter" value="Apply"/></li>
32
  </ul>
33
  <?php
@@ -44,10 +40,10 @@
44
  </div>
45
  </fieldset>
46
  </td>
47
- <td class="right">
48
- <fieldset class="widefat">
49
- <legend><?php _e('Advanced','pmxi_plugin');?></legend>
50
- <p><?php _e('Current XPath:','pmxi_plugin');?></p>
51
  <div>
52
  <input type="text" name="xpath" value="<?php echo esc_attr($post['xpath']) ?>" style="max-width:none;" />
53
  <input type="hidden" id="root_element" name="root_element" value="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>"/>
@@ -63,7 +59,25 @@
63
  }
64
  ?>
65
  &nbsp; <br/><br/>or <a href="javascript:void(0);" rel="<?php echo esc_attr($post['xpath']) ?>" root="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>" id="get_default_xpath"><?php _e('get default xPath','pmxi_plugin');?></a>
66
- </div> <br><br>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  <a href="http://www.w3schools.com/xpath/default.asp" target='_blank'><?php _e('XPath Tutorial','pmxi_plugin');?></a> - <?php _e('For further help','pmxi_plugin');?>, <a href="http://www.wpallimport.com/support" target='_blank'><?php _e('contact us','pmxi_plugin');?></a>.
68
  </fieldset>
69
  <p class="submit-buttons" style="text-align:right;">
10
  </div>
11
  <table class="layout">
12
  <tr>
13
+ <td class="left" style="width:60%;">
14
  <fieldset class="widefat">
15
  <legend><?php _e('Current XML tree', 'pmxi_plugin');?></legend>
16
  <div class="action_buttons">
23
  if ($is_csv !== false){
24
  ?>
25
  <ul class="set_csv_delimiter">
26
+ <li><?php _e("Set delimiter for CSV fields:",'pmxi_plugin');?> </li>
 
 
 
 
27
  <li> <input type="text" value="<?php echo $is_csv;?>" name="delimiter"/> <input type="button" name="apply_delimiter" value="Apply"/></li>
28
  </ul>
29
  <?php
40
  </div>
41
  </fieldset>
42
  </td>
43
+ <td class="right" style="width:40%;">
44
+ <fieldset class="widefat">
45
+ <legend><?php _e('Fitering Options','pmxi_plugin');?></legend>
46
+ <p><?php _e('Manual XPath:','pmxi_plugin');?></p>
47
  <div>
48
  <input type="text" name="xpath" value="<?php echo esc_attr($post['xpath']) ?>" style="max-width:none;" />
49
  <input type="hidden" id="root_element" name="root_element" value="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>"/>
59
  }
60
  ?>
61
  &nbsp; <br/><br/>or <a href="javascript:void(0);" rel="<?php echo esc_attr($post['xpath']) ?>" root="<?php echo PMXI_Plugin::$session->data['pmxi_import']['source']['root_element']; ?>" id="get_default_xpath"><?php _e('get default xPath','pmxi_plugin');?></a>
62
+ </div>
63
+ <p><?php _e('Filters:','pmxi_plugin');?></p>
64
+ <div>
65
+ <select id="pmxi_xml_element">
66
+ <option value=""><?php _e('Select Element', 'pmxi_plugin'); ?></option>
67
+ <?php $this->render_xml_elements_for_filtring($elements->item(0)); ?>
68
+ </select>
69
+ <select id="pmxi_rule">
70
+ <option value=""><?php _e('Select Rule', 'pmxi_plugin'); ?></option>
71
+ <option value="equals"><?php _e('equals', 'pmxi_plugin'); ?></option>
72
+ <option value="greater"><?php _e('greater than', 'pmxi_plugin');?></option>
73
+ <option value="less"><?php _e('less than', 'pmxi_plugin'); ?></option>
74
+ <option value="contains"><?php _e('contains', 'pmxi_plugin'); ?></option>
75
+ </select>
76
+ <input id="pmxi_value" type="text" placeholder="value" value=""/>
77
+ <a id="pmxi_add_rule" href="javascript:void(0);"><?php _e('Add rule', 'pmxi_plugin');?></a>
78
+ </div>
79
+ <div class="clear"></div>
80
+ <br><br>
81
  <a href="http://www.w3schools.com/xpath/default.asp" target='_blank'><?php _e('XPath Tutorial','pmxi_plugin');?></a> - <?php _e('For further help','pmxi_plugin');?>, <a href="http://www.wpallimport.com/support" target='_blank'><?php _e('contact us','pmxi_plugin');?></a>.
82
  </fieldset>
83
  <p class="submit-buttons" style="text-align:right;">
views/admin/import/evaluate.php CHANGED
@@ -5,7 +5,7 @@
5
  <?php endif ?>
6
  </div>
7
  <div id="current_xml">
8
- <?php $this->render_xml_element($elements->item( ($_POST['show_element'] and !PMXI_Plugin::$session->data['pmxi_import']['large_file']) ? $_POST['show_element'] - 1 : 0 ), false, '//'); ?>
9
  </div>
10
  <script type="text/javascript">
11
  (function($){
5
  <?php endif ?>
6
  </div>
7
  <div id="current_xml">
8
+ <?php $this->render_xml_element($elements->item(0), false, '//'); ?>
9
  </div>
10
  <script type="text/javascript">
11
  (function($){
views/admin/import/evaluate_variations.php CHANGED
@@ -11,8 +11,8 @@
11
  <div class="title">
12
  <?php printf(__('Variation Record #<strong>%s</strong> out of <strong>%s</strong>', 'pmxi_plugin'), $tagno + 1, $variation_list_count); ?>
13
  <div class="navigation">
14
- <?php if ($tagno > 0): ?><a href="#variation_prev">&lang;&lang;</a><?php else: ?><span>&lang;&lang;</span><?php endif ?>
15
- <?php if ($tagno < $variation_list_count - 1): ?><a href="#variation_next">&rang;&rang;</a><?php else: ?><span>&rang;&rang;</span><?php endif ?>
16
  </div>
17
  </div>
18
  <div class="clear"></div>
11
  <div class="title">
12
  <?php printf(__('Variation Record #<strong>%s</strong> out of <strong>%s</strong>', 'pmxi_plugin'), $tagno + 1, $variation_list_count); ?>
13
  <div class="navigation">
14
+ <?php if ($tagno > 0): ?><a href="#variation_prev">&laquo;</a><?php else: ?><span>&laquo;</span><?php endif ?>
15
+ <?php if ($tagno < $variation_list_count - 1): ?><a href="#variation_next">&raquo;</a><?php else: ?><span>&raquo;</span><?php endif ?>
16
  </div>
17
  </div>
18
  <div class="clear"></div>
views/admin/import/index.php CHANGED
@@ -46,6 +46,7 @@ $l10n = array(
46
  <?php
47
  endif;
48
  ?>
 
49
  <form method="post" class="choose-file no-enter-submit" enctype="multipart/form-data" autocomplete="off">
50
  <input type="hidden" name="is_submitted" value="1" />
51
  <?php wp_nonce_field('upload-xml', '_wpnonce_upload-xml') ?>
@@ -73,21 +74,10 @@ $l10n = array(
73
  </h3>
74
  <div class="file-type-options">
75
  <input type="text" class="regular-text" name="url" value="" disabled="disabled" />
 
76
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
77
  </div>
78
- </div>
79
- <div class="file-type-container">
80
- <h3>
81
- <input type="radio" id="type_ftp" name="type" value="ftp" />
82
- <label for="type_ftp"><?php _e('Download File(s) From FTP Server', 'pmxi_plugin') ?></label>
83
- </h3>
84
- <div class="file-type-options">
85
- <input type="text" class="regular-text" name="ftp[url]" value="<?php echo esc_attr($post['ftp']['url']) ?>" disabled="disabled" /><br />
86
- <input type="text" name="ftp[user]" title="username" style='width: 150px;' disabled="disabled"/><strong>:</strong><input type="password" name="ftp[pass]" title="passowrd" style='width: 150px;' disabled="disabled"/>
87
- <div class="note"><?php _e('You may use an asterisk to load multiple files. For example, ftp://example.com/datafeeds/*.xml', 'pmxi_plugin') ?></div>
88
- <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
89
- </div>
90
- </div>
91
  <div class="file-type-container">
92
  <h3>
93
  <input type="radio" id="type_file" name="type" value="file" />
@@ -108,6 +98,7 @@ $l10n = array(
108
  __FILE_SOURCE = <?php echo json_encode($local_files) ?>;
109
  </script>
110
  <div class="note"><?php printf(__('Upload files to <strong>%s</strong> and they will appear in this list', 'pmxi_plugin'), PMXI_Plugin::ROOT_DIR . '/upload/') ?></div>
 
111
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
112
  </div>
113
  </div>
46
  <?php
47
  endif;
48
  ?>
49
+ <?php do_action('pmxi_choose_file_header'); ?>
50
  <form method="post" class="choose-file no-enter-submit" enctype="multipart/form-data" autocomplete="off">
51
  <input type="hidden" name="is_submitted" value="1" />
52
  <?php wp_nonce_field('upload-xml', '_wpnonce_upload-xml') ?>
74
  </h3>
75
  <div class="file-type-options">
76
  <input type="text" class="regular-text" name="url" value="" disabled="disabled" />
77
+ <p>To have the option to set up a cron-based recurring import, specify the URL to your file.</p>
78
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
79
  </div>
80
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
81
  <div class="file-type-container">
82
  <h3>
83
  <input type="radio" id="type_file" name="type" value="file" />
98
  __FILE_SOURCE = <?php echo json_encode($local_files) ?>;
99
  </script>
100
  <div class="note"><?php printf(__('Upload files to <strong>%s</strong> and they will appear in this list', 'pmxi_plugin'), PMXI_Plugin::ROOT_DIR . '/upload/') ?></div>
101
+ <p>To have the option to set up a cron-based recurring import, specify the URL to your file.</p>
102
  <a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=step-1&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade to the professional edition of WP All Import to use this feature.</a>
103
  </div>
104
  </div>
views/admin/import/options.php CHANGED
@@ -1,38 +1,15 @@
1
  <?php
2
 
3
- if (!function_exists('reverse_taxonomies_html')) {
4
- function reverse_taxonomies_html($post_taxonomies, $item_id, &$i){
5
- $childs = array();
6
- foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
7
-
8
- if (!empty($childs)){
9
- ?>
10
- <ol>
11
- <?php
12
- foreach ($childs as $child_cat){
13
- $i++;
14
- ?>
15
- <li id="item_<?php echo $i; ?>">
16
- <div class="drag-element">
17
- <input type="checkbox" class="assign_post" <?php if ($child_cat->assign): ?>checked="checked"<?php endif; ?> title="<?php _e('Assign post to the taxonomy.','pmxi_plugin');?>"/>
18
- <input class="widefat" type="text" value="<?php echo esc_attr($child_cat->xpath); ?>"/>
19
- </div>
20
- <a href="javascript:void(0);" class="icon-item remove-ico"></a>
21
- <?php echo reverse_taxonomies_html($post_taxonomies, $child_cat->item_id, $i); ?>
22
- </li>
23
- <?php
24
- }
25
- ?>
26
- </ol>
27
- <?php
28
- }
29
- }
30
- }
31
  ?>
 
32
  <input type="hidden" id="selected_post_type" value="<?php echo (!empty($post['custom_type'])) ? $post['custom_type'] : '';?>">
33
  <input type="hidden" id="selected_type" value="<?php echo (!empty($post['type'])) ? $post['type'] : '';?>">
34
  <h2>
35
- <?php if ($this->isWizard): ?>
36
  <?php _e('Import XML/CSV - Step 4: Options', 'pmxi_plugin') ?>
37
  <?php else: ?>
38
  <?php _e('Edit Import Options', 'pmxi_plugin') ?>
@@ -40,6 +17,8 @@
40
  </h2>
41
  <h3><?php _e('Click the appropriate tab to choose the type of posts to create.', 'pmxi_plugin');?></h3>
42
 
 
 
43
  <div class="ajax-console">
44
  <?php if ($this->errors->get_error_codes()): ?>
45
  <?php $this->error() ?>
@@ -47,153 +26,204 @@
47
  </div>
48
 
49
  <table class="layout">
50
- <tr>
51
- <td class="left" style="width:100%;">
52
- <?php $templates = new PMXI_Template_List() ?>
53
- <form class="load_options options <?php echo ! $this->isWizard ? 'edit' : '' ?>" method="post">
54
- <div class="load-template">
55
- <span><?php _e('Load existing template:','pmxi_plugin');?> </span>
56
- <select name="load_template">
57
- <option value=""><?php _e('Load Template...', 'pmxi_plugin') ?></option>
58
- <?php foreach ($templates->getBy()->convertRecords() as $t): ?>
59
- <option value="<?php echo $t->id ?>"><?php echo $t->name ?></option>
 
 
 
 
 
 
 
 
 
 
 
 
60
  <?php endforeach ?>
61
- <option value="-1"><?php _e('Reset...', 'pmxi_plugin') ?></option>
62
- </select>
63
- </div>
64
- </form>
65
- <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
66
- <a class="nav-tab nav-tab-active" rel="posts" href="javascript:void(0);">Posts</a>
67
- <a class="nav-tab" rel="pages" href="javascript:void(0);">Pages</a>
68
- <?php
69
- if (class_exists('PMWI_Plugin')):
70
- ?>
71
- <a class="nav-tab" rel="product" href="javascript:void(0);">WooCommerce Products</a>
72
- <?php
73
- endif;
74
- ?>
75
- </h2>
76
- <div id="pmxi_tabs">
77
- <div class="left">
78
-
79
- <!-- Post Options -->
80
-
81
- <div id="posts" class="pmxi_tab"> <!-- Basic -->
82
- <form class="options <?php echo ! $this->isWizard ? 'edit' : '' ?>" method="post">
83
- <input type="hidden" name="type" value="post"/>
84
- <input type="hidden" name="custom_type" value=""/>
85
- <div class="post-type-options">
86
- <table class="form-table" style="max-width:none;">
87
- <?php
88
- $post_type = 'post';
89
- $entry = 'post';
90
- include( 'options/_main_options_template.php' );
91
- include( 'options/_taxonomies_template.php' );
92
- include( 'options/_categories_template.php' );
93
- include( 'options/_custom_fields_template.php' );
94
- include( 'options/_featured_template.php' );
95
- include( 'options/_author_template.php' );
96
- include( 'options/_reimport_template.php' );
97
- include( 'options/_settings_template.php' );
98
- ?>
99
- </table>
100
- </div>
101
-
102
- <?php include( 'options/_buttons_template.php' ); ?>
103
-
104
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  </div>
106
-
107
- <!-- Page Options -->
108
-
109
- <div id="pages" class="pmxi_tab">
110
- <form class="options <?php echo ! $this->isWizard ? 'edit' : '' ?>" method="post">
111
- <input type="hidden" name="type" value="page"/>
112
- <input type="hidden" name="custom_type" value=""/>
113
- <div class="post-type-options">
114
- <table class="form-table" style="max-width:none;">
115
-
116
- <?php include( 'options/_main_options_template.php' ); ?>
117
-
118
- <tr>
119
- <td align="center" width="33%">
120
- <label><?php _e('Page Template', 'pmxi_plugin') ?></label> <br>
121
- <select name="page_template" id="page_template">
122
- <option value='default'><?php _e('Default', 'pmxi_plugin') ?></option>
123
- <?php page_template_dropdown($post['page_template']); ?>
124
- </select>
125
- </td>
126
- <td align="center" width="33%">
127
- <label><?php _e('Parent Page', 'pmxi_plugin') ?></label> <br>
128
- <?php wp_dropdown_pages(array('post_type' => 'page', 'selected' => $post['parent'], 'name' => 'parent', 'show_option_none' => __('(no parent)', 'pmxi_plugin'), 'sort_column'=> 'menu_order, post_title',)) ?>
129
- </td>
130
- <td align="center" width="33%">
131
- <label><?php _e('Order', 'pmxi_plugin') ?></label> <br>
132
- <input type="text" class="" name="order" value="<?php echo esc_attr($post['order']) ?>" />
133
- </td>
134
- </tr>
135
- <?php
136
- $post_type = 'post';
137
- $entry = 'page';
138
- include( 'options/_custom_fields_template.php' );
139
- include( 'options/_taxonomies_template.php' );
140
- include( 'options/_featured_template.php' );
141
- include( 'options/_author_template.php' );
142
- include( 'options/_reimport_template.php' );
143
- include( 'options/_settings_template.php' );
144
- ?>
145
- </table>
146
- </div>
147
-
148
- <?php include( 'options/_buttons_template.php' ); ?>
149
-
150
- </form>
151
- </div>
152
-
153
- <!-- WooCommerce Add-On -->
154
- <?php
155
- if (class_exists('PMWI_Plugin')):
156
- ?>
157
- <div id="product" class="pmxi_tab">
158
- <form class="options <?php echo ! $this->isWizard ? 'edit' : '' ?>" method="post">
159
- <input type="hidden" name="custom_type" value="product"/>
160
- <input type="hidden" name="type" value="post"/>
161
- <div class="post-type-options">
162
- <table class="form-table" style="max-width:none;">
163
- <?php
164
-
165
- $post_type = $entry = 'product';
166
-
167
- include( 'options/_main_options_template.php' );
168
-
169
- $woo_controller = new PMWI_Admin_Import();
170
- $woo_controller->index();
171
-
172
- include( 'options/_taxonomies_template.php' );
173
- include( 'options/_custom_fields_template.php' );
174
- include( 'options/_featured_template.php' );
175
- include( 'options/_author_template.php' );
176
- include( 'options/_reimport_template.php' );
177
- include( 'options/_settings_template.php' );
178
-
179
- ?>
180
- </table>
181
- </div>
182
-
183
- <?php include( 'options/_buttons_template.php' ); ?>
184
-
185
- </form>
186
- </div>
187
- <?php
188
- endif;
189
- ?>
190
- </div>
191
- <?php if ($this->isWizard or $this->isTemplateEdit): ?>
192
- <div class="right options">
193
- <?php $this->tag() ?>
194
  </div>
195
- <?php endif ?>
196
- </div>
197
- </td>
198
- </tr>
199
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
 
3
+ $custom_types = get_post_types(array('_builtin' => false), 'objects');
4
+ $isWizard = $this->isWizard;
5
+ $baseUrl = $this->baseUrl;
6
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  ?>
8
+
9
  <input type="hidden" id="selected_post_type" value="<?php echo (!empty($post['custom_type'])) ? $post['custom_type'] : '';?>">
10
  <input type="hidden" id="selected_type" value="<?php echo (!empty($post['type'])) ? $post['type'] : '';?>">
11
  <h2>
12
+ <?php if ($isWizard): ?>
13
  <?php _e('Import XML/CSV - Step 4: Options', 'pmxi_plugin') ?>
14
  <?php else: ?>
15
  <?php _e('Edit Import Options', 'pmxi_plugin') ?>
17
  </h2>
18
  <h3><?php _e('Click the appropriate tab to choose the type of posts to create.', 'pmxi_plugin');?></h3>
19
 
20
+ <?php do_action('pmxi_options_header', $isWizard, $post); ?>
21
+
22
  <div class="ajax-console">
23
  <?php if ($this->errors->get_error_codes()): ?>
24
  <?php $this->error() ?>
26
  </div>
27
 
28
  <table class="layout">
29
+ <tr>
30
+ <td class="left" style="width:100%;">
31
+ <?php $templates = new PMXI_Template_List() ?>
32
+ <form class="load_options options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
33
+ <div class="load-template">
34
+ <span><?php _e('Load existing template:','pmxi_plugin');?> </span>
35
+ <select name="load_template">
36
+ <option value=""><?php _e('Load Template...', 'pmxi_plugin') ?></option>
37
+ <?php foreach ($templates->getBy()->convertRecords() as $t): ?>
38
+ <option value="<?php echo $t->id ?>"><?php echo $t->name ?></option>
39
+ <?php endforeach ?>
40
+ <option value="-1"><?php _e('Reset...', 'pmxi_plugin') ?></option>
41
+ </select>
42
+ </div>
43
+ </form>
44
+ <h2 class="nav-tab-wrapper woo-nav-tab-wrapper">
45
+ <a class="nav-tab nav-tab-active" rel="posts" href="javascript:void(0);"><?php _e('Posts','pmxi_plugin');?></a>
46
+ <a class="nav-tab" rel="pages" href="javascript:void(0);"><?php _e('Pages','pmxi_plugin');?></a>
47
+ <?php $custom_types = apply_filters( 'pmxi_custom_types', $custom_types );?>
48
+ <?php if (count($custom_types)): ?>
49
+ <?php foreach ($custom_types as $key => $ct):?>
50
+ <a class="nav-tab" rel="<?php echo $key; ?>" href="javascript:void(0);"><?php echo $ct->labels->name ?></a>
51
  <?php endforeach ?>
52
+ <?php endif ?>
53
+ <?php do_action('pmxi_custom_menu_item'); ?>
54
+ </h2>
55
+ <div id="pmxi_tabs">
56
+ <div class="left">
57
+
58
+ <!-- Post Options -->
59
+
60
+ <div id="posts" class="pmxi_tab"> <!-- Basic -->
61
+ <form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
62
+ <input type="hidden" name="type" value="post"/>
63
+ <input type="hidden" name="custom_type" value=""/>
64
+ <div class="post-type-options">
65
+ <table class="form-table" style="max-width:none;">
66
+ <?php
67
+ $post_type = 'post';
68
+ $entry = 'post';
69
+
70
+ include( 'options/_main_options_template.php' );
71
+ do_action('pmxi_extend_options_main', $entry);
72
+ include( 'options/_taxonomies_template.php' );
73
+ do_action('pmxi_extend_options_taxonomies', $entry);
74
+ include( 'options/_categories_template.php' );
75
+ do_action('pmxi_extend_options_categories', $entry);
76
+ include( 'options/_custom_fields_template.php' );
77
+ do_action('pmxi_extend_options_custom_fields', $entry);
78
+ include( 'options/_featured_template.php' );
79
+ do_action('pmxi_extend_options_featured', $entry);
80
+ include( 'options/_author_template.php' );
81
+ do_action('pmxi_extend_options_author', $entry);
82
+ include( 'options/_reimport_template.php' );
83
+ include( 'options/_settings_template.php' );
84
+ ?>
85
+ </table>
86
+ </div>
87
+
88
+ <?php include( 'options/_buttons_template.php' ); ?>
89
+
90
+ </form>
91
+ </div>
92
+
93
+ <!-- Page Options -->
94
+
95
+ <div id="pages" class="pmxi_tab">
96
+ <form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
97
+ <input type="hidden" name="type" value="page"/>
98
+ <input type="hidden" name="custom_type" value=""/>
99
+ <div class="post-type-options">
100
+ <table class="form-table" style="max-width:none;">
101
+
102
+ <?php
103
+ $post_type = 'post';
104
+ $entry = 'page';
105
+ include( 'options/_main_options_template.php' );
106
+ ?>
107
+
108
+ <tr>
109
+ <td align="center" width="33%">
110
+ <label><?php _e('Page Template', 'pmxi_plugin') ?></label> <br>
111
+ <select name="page_template" id="page_template">
112
+ <option value='default'><?php _e('Default', 'pmxi_plugin') ?></option>
113
+ <?php page_template_dropdown($post['page_template']); ?>
114
+ </select>
115
+ </td>
116
+ <td align="center" width="33%">
117
+ <label><?php _e('Parent Page', 'pmxi_plugin') ?></label> <br>
118
+ <?php wp_dropdown_pages(array('post_type' => 'page', 'selected' => $post['parent'], 'name' => 'parent', 'show_option_none' => __('(no parent)', 'pmxi_plugin'), 'sort_column'=> 'menu_order, post_title',)) ?>
119
+ </td>
120
+ <td align="center" width="33%">
121
+ <label><?php _e('Order', 'pmxi_plugin') ?></label> <br>
122
+ <input type="text" class="" name="order" value="<?php echo esc_attr($post['order']) ?>" />
123
+ </td>
124
+ </tr>
125
+ <?php
126
+ do_action('pmxi_extend_options_main', $entry);
127
+ include( 'options/_custom_fields_template.php' );
128
+ do_action('pmxi_extend_options_custom_fields', $entry);
129
+ include( 'options/_taxonomies_template.php' );
130
+ do_action('pmxi_extend_options_taxonomies', $entry);
131
+ include( 'options/_featured_template.php' );
132
+ do_action('pmxi_extend_options_featured', $entry);
133
+ include( 'options/_author_template.php' );
134
+ do_action('pmxi_extend_options_author', $entry);
135
+ include( 'options/_reimport_template.php' );
136
+ include( 'options/_settings_template.php' );
137
+ ?>
138
+ </table>
139
+ </div>
140
+
141
+ <?php include( 'options/_buttons_template.php' ); ?>
142
+
143
+ </form>
144
+ </div>
145
+
146
+ <!-- Custom Post Types -->
147
+
148
+ <?php
149
+ if (count($custom_types)): ?>
150
+ <?php foreach ($custom_types as $key => $ct):?>
151
+ <div id="<?php echo $key;?>" class="pmxi_tab">
152
+ <form class="options <?php echo ! $isWizard ? 'edit' : '' ?>" method="post">
153
+ <input type="hidden" name="custom_type" value="<?php echo $key; ?>"/>
154
+ <input type="hidden" name="type" value="post"/>
155
+ <div class="post-type-options">
156
+ <table class="form-table" style="max-width:none;">
157
+ <?php
158
+ $post_type = $entry = $key;
159
+ include( 'options/_main_options_template.php' );
160
+ do_action('pmxi_extend_options_main', $entry);
161
+ include( 'options/_taxonomies_template.php' );
162
+ do_action('pmxi_extend_options_taxonomies', $entry);
163
+ include( 'options/_categories_template.php' );
164
+ do_action('pmxi_extend_options_categories', $entry);
165
+ include( 'options/_custom_fields_template.php' );
166
+ do_action('pmxi_extend_options_custom_fields', $entry);
167
+ include( 'options/_featured_template.php' );
168
+ do_action('pmxi_extend_options_featured', $entry);
169
+ include( 'options/_author_template.php' );
170
+ do_action('pmxi_extend_options_author', $entry);
171
+ include( 'options/_reimport_template.php' );
172
+ include( 'options/_settings_template.php' );
173
+ ?>
174
+ </table>
175
+ </div>
176
+
177
+ <?php include( 'options/_buttons_template.php' ); ?>
178
+
179
+ </form>
180
+ </div>
181
+ <?php endforeach ?>
182
+ <?php endif ?>
183
+
184
+ <?php do_action('pmxi_custom_options_tab', $isWizard, $post);?>
185
+
186
  </div>
187
+ <?php if ($isWizard or $this->isTemplateEdit): ?>
188
+ <div class="right options">
189
+ <?php $this->tag() ?>
190
+ </div>
191
+ <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
192
  </div>
193
+ </td>
194
+ </tr>
195
+ </table>
196
+
197
+ <div id="record_matching_pointer" style="display:none;">
198
+
199
+ <h3><?php _e("Record Matching", "pmxi_plugin");?></h3>
200
+
201
+ <p>
202
+ <b><?php _e("Record Matching is how WP All Import matches records in your file with posts that already exist WordPress.","pmxi_plugin");?></b>
203
+ </p>
204
+
205
+ <p>
206
+ <?php _e("Record Matching is most commonly used to tell WP All Import how to match up records in your file with posts WP All Import has already created on your site, so that if your file is updated with new data, WP All Import can update your posts accordingly.","pmxi_plugin");?>
207
+ </p>
208
+
209
+ <hr />
210
+
211
+ <p><?php _e("AUTOMATIC RECORD MATCHING","pmxi_plugin");?></p>
212
+
213
+ <p>
214
+ <?php _e("Automatic Record Matching allows WP All Import to update records that were imported or updated during the last run of this same import.","pmxi_plugin");?>
215
+ </p>
216
+
217
+ <p>
218
+ <?php _e("Your unique key must be UNIQUE for each record in your feed. Make sure you get it right - you can't change it later. You'll have to re-create your import.","pmxi_plugin");?>
219
+ </p>
220
+
221
+ <hr />
222
+
223
+ <p><?php _e("MANUAL RECORD MATCHING", "pmxi_plugin");?></p>
224
+
225
+ <p>
226
+ <?php _e("Manual record matching allows WP All Import to update any records, even records that were not imported with WP All Import, or are part of a different import.","pmxi_plugin");?>
227
+ </p>
228
+
229
+ </div>
views/admin/import/options/_buttons_template.php CHANGED
@@ -1,20 +1,21 @@
1
  <p class="submit-buttons">
2
  <?php wp_nonce_field('options', '_wpnonce_options') ?>
3
  <input type="hidden" name="is_submitted" value="1" />
 
 
 
4
 
5
- <?php if ($this->isWizard): ?>
6
-
7
- <a href="<?php echo add_query_arg('action', 'template', $this->baseUrl) ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
8
 
9
  <?php if (in_array($source_type, array('url', 'ftp', 'file'))): ?>
10
  <input type="hidden" class="save_only" value="0" name="save_only"/>
11
  <input type="submit" name="btn_save_only" class="button button-primary button-hero large_button" value="<?php _e('Save Only', 'pmxi_plugin') ?>" />
12
  <?php endif ?>
13
 
14
- <input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Finish', 'pmxi_plugin') ?>" />
15
 
16
  <?php else: ?>
17
- <a href="<?php echo remove_query_arg('id', remove_query_arg('action', $this->baseUrl)); ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
18
  <input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Save', 'pmxi_plugin') ?>" />
19
  <?php endif ?>
20
  </p>
1
  <p class="submit-buttons">
2
  <?php wp_nonce_field('options', '_wpnonce_options') ?>
3
  <input type="hidden" name="is_submitted" value="1" />
4
+ <input type="hidden" name="converted_options" value="1"/>
5
+
6
+ <?php if ($isWizard): ?>
7
 
8
+ <a href="<?php echo add_query_arg('action', 'template', $baseUrl) ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
 
 
9
 
10
  <?php if (in_array($source_type, array('url', 'ftp', 'file'))): ?>
11
  <input type="hidden" class="save_only" value="0" name="save_only"/>
12
  <input type="submit" name="btn_save_only" class="button button-primary button-hero large_button" value="<?php _e('Save Only', 'pmxi_plugin') ?>" />
13
  <?php endif ?>
14
 
15
+ <input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Finish', 'pmxi_plugin') ?>" />
16
 
17
  <?php else: ?>
18
+ <a href="<?php echo remove_query_arg('id', remove_query_arg('action', $baseUrl)); ?>" class="back"><?php _e('Back', 'pmxi_plugin') ?></a>
19
  <input type="submit" class="button button-primary button-hero large_button" value="<?php _e('Save', 'pmxi_plugin') ?>" />
20
  <?php endif ?>
21
  </p>
views/admin/import/options/_custom_fields_template.php CHANGED
@@ -1,42 +1,61 @@
1
  <tr>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset" style="text-align:center;">
4
- <legend>Custom Fields</legend>
5
 
6
- <center>
7
 
8
- <h3>Please upgrade to the professional edition of WP All Import to import data to Custom Fields.</h3>
9
 
10
- <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=custom-fields&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
11
 
12
- <hr />
13
 
14
- </center>
15
 
16
 
17
  <table class="form-table custom-params" style="max-width:none; border:none;">
18
  <thead>
19
  <tr>
20
  <td><?php _e('Name', 'pmxi_plugin') ?></td>
21
- <td><?php _e('Value', 'pmxi_plugin') ?></td>
22
- <td></td>
23
  </tr>
24
  </thead>
25
- <tbody>
26
- <tr class="form-field">
27
- <td><input type="text" name="custom_name[]" value="" disabled="disabled" /></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  <td class="action remove">
29
  <textarea name="custom_value[]" disabled="disabled"></textarea>
30
- </td>
31
- </tr>
 
32
  <tr>
33
- <td colspan="3"><a href="#add" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-custom"><?php _e('Add more', 'pmxi_plugin') ?></a></td>
34
  </tr>
35
  </tbody>
36
  </table>
37
  <select class="existing_meta_keys">
38
- <option value="">Existing Custom Fields...</option>
39
- <?php
40
  $hide_fields = array('_wp_page_template', '_edit_lock', '_edit_last', '_wp_trash_meta_status', '_wp_trash_meta_time');
41
  if (!empty($meta_keys) and $meta_keys->count()):
42
  foreach ($meta_keys as $meta_key) { if (in_array($meta_key['meta_key'], $hide_fields) or strpos($meta_key['meta_key'], '_wp') === 0) continue;
@@ -47,8 +66,7 @@
47
  endif;
48
  ?>
49
  </select>
50
-
51
- </fieldset>
52
- <br>
53
  </td>
54
  </tr>
1
  <tr>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset" style="text-align:center;">
4
+ <legend><?php _e('Custom Fields','pmxi_plugin');?></legend>
5
 
6
+ <center>
7
 
8
+ <h3>Please upgrade to the professional edition of WP All Import to import data to Custom Fields.</h3>
9
 
10
+ <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=custom-fields&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
11
 
12
+ <hr />
13
 
14
+ </center>
15
 
16
 
17
  <table class="form-table custom-params" style="max-width:none; border:none;">
18
  <thead>
19
  <tr>
20
  <td><?php _e('Name', 'pmxi_plugin') ?></td>
21
+ <td><?php _e('Value', 'pmxi_plugin') ?></td>
 
22
  </tr>
23
  </thead>
24
+ <tbody>
25
+ <?php if (!empty($post['custom_name'])):?>
26
+ <?php foreach ($post['custom_name'] as $i => $name): ?>
27
+ <tr class="form-field">
28
+ <td><input type="text" name="custom_name[]" value="<?php echo esc_attr($name) ?>" disabled="disabled"/></td>
29
+ <td class="action remove">
30
+ <textarea name="custom_value[]" disabled="disabled"><?php echo esc_html($post['custom_value'][$i]) ?></textarea>
31
+ <a href="#remove"></a>
32
+ </td>
33
+ </tr>
34
+ <?php endforeach ?>
35
+ <?php else: ?>
36
+ <tr class="form-field">
37
+ <td><input type="text" name="custom_name[]" value="" disabled="disabled"/></td>
38
+ <td class="action remove">
39
+ <textarea name="custom_value[]" disabled="disabled"></textarea>
40
+ <a href="#remove"></a>
41
+ </td>
42
+ </tr>
43
+ <?php endif;?>
44
+ <tr class="form-field template">
45
+ <td><input type="text" name="custom_name[]" value="" disabled="disabled"/></td>
46
  <td class="action remove">
47
  <textarea name="custom_value[]" disabled="disabled"></textarea>
48
+ <a href="#remove"></a>
49
+ </td>
50
+ </tr>
51
  <tr>
52
+ <td colspan="2"><a href="#add" title="<?php _e('add', 'pmxi_plugin')?>" class="action add-new-custom"><?php _e('Add more', 'pmxi_plugin') ?></a></td>
53
  </tr>
54
  </tbody>
55
  </table>
56
  <select class="existing_meta_keys">
57
+ <option value=""><?php _e('Existing Custom Fields...','pmxi_plugin');?></option>
58
+ <?php
59
  $hide_fields = array('_wp_page_template', '_edit_lock', '_edit_last', '_wp_trash_meta_status', '_wp_trash_meta_time');
60
  if (!empty($meta_keys) and $meta_keys->count()):
61
  foreach ($meta_keys as $meta_key) { if (in_array($meta_key['meta_key'], $hide_fields) or strpos($meta_key['meta_key'], '_wp') === 0) continue;
66
  endif;
67
  ?>
68
  </select>
69
+ <br/>
70
+ </fieldset>
 
71
  </td>
72
  </tr>
views/admin/import/options/_featured_template.php CHANGED
@@ -2,26 +2,41 @@
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
  <legend><?php _e('Featured Image & Media Gallery', 'pmxi_plugin') ?></legend>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  <div class="input">
6
  <p style="margin-bottom:5px;"><?php _e('<b>Image URLs</b> (one per line)', 'pmxi_plugin');?></p>
7
- <textarea name="featured_image" class="newline" style="width:100%;margin-bottom:5px;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['featured_image']) ?></textarea>
8
  <label for="featured_delim_<?php echo $entry;?>"><?php _e('Place one image URL per line, or separate URLs with a ', 'pmxi_plugin');?></label>
9
- <input type="text" class="small" id="featured_delim_<?php echo $entry;?>" name="featured_delim" value="<?php echo esc_attr($post['featured_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/>
10
  <span style="float:right;">
11
  <input type="hidden" name="create_draft" value="no" />
12
- <input type="checkbox" id="create_draft_<?php echo $entry; ?>" name="create_draft" value="yes" <?php echo 'yes' == $post['create_draft'] ? 'checked="checked"' : '' ?> class="fix_checkbox" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/>
13
  <label for="create_draft_<?php echo $entry; ?>"><?php _e('If no images are downloaded successfully, create entry as Draft.', 'pmxi_plugin') ?></label>
14
  </span>
15
  </div>
16
  <div class="input" style="margin:3px 0px;">
17
  <input type="hidden" name="download_images" value="0" />
18
- <input type="checkbox" id="download_images_<?php echo $entry; ?>" name="download_images" value="1" <?php echo $post['download_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/>
19
  <label for="download_images_<?php echo $entry;?>"><?php _e('Download images','pmxi_plugin');?> </label>
20
  <a href="#help" class="help" title="<?php _e('If this option enabled, then plugin will download images into the Uploads folder. If this option disabled, then plugin will search files in Uploads <strong>/wp-content/uploads/'.date("Y/m").'</strong> folder.', 'pmxi_plugin') ?>">?</a>
21
  </div>
22
  <div class="input switcher-target-download_images_<?php echo $entry; ?>" style="margin:3px 0px;">
23
  <input type="hidden" name="auto_rename_images" value="0" />
24
- <input type="checkbox" id="auto_rename_images_<?php echo $entry; ?>" name="auto_rename_images" value="1" <?php echo $post['auto_rename_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/>
25
  <label for="auto_rename_images_<?php echo $entry;?>"><?php _e('Instead of using original image file name, set file name(s) to','pmxi_plugin');?> </label>
26
  <input type="text" id="auto_rename_images_suffix_<?php echo $entry;?>" class="switcher-target-auto_rename_images_<?php echo $entry; ?>" name="auto_rename_images_suffix" value="<?php echo esc_attr($post['auto_rename_images_suffix']) ?>" /> <a href="#help" class="help" title="<?php _e('Instead of using original image file name, set file name(s) suffix', 'pmxi_plugin') ?>">?</a>
27
  </div>
@@ -33,40 +48,30 @@
33
  <div class="switcher-target-set_image_meta_data_<?php echo $entry; ?>" style="padding-left:17px;">
34
  <div class="input">
35
  <p style="margin-bottom:5px;"><?php _e('Title', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Title', 'pmxi_plugin') ?>">?</a></p>
36
- <textarea name="image_meta_title" class="newline" style="width:100%; margin-bottom:5px;" placeholder="<?php _e('Default will be image filename. The first title will be associated with the first image URL, the second title will be associated with second image URL, etc.','pmxi_plugin');?>" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_title']) ?></textarea>
37
  <label for="image_meta_title_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
38
- <input type="text" class="small" id="image_meta_title_delim_<?php echo $entry;?>" name="image_meta_title_delim" value="<?php echo esc_attr($post['image_meta_title_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
39
  </div>
40
  <div class="input">
41
  <p style="margin-bottom:5px;"><?php _e('Caption', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Capltion', 'pmxi_plugin') ?>">?</a></p>
42
- <textarea name="image_meta_caption" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first caption will be associated with the first image URL, the second caption will be associated with the second image URL, etc." <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_caption']) ?></textarea>
43
  <label for="image_meta_caption_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
44
- <input type="text" class="small" id="image_meta_caption_delim_<?php echo $entry;?>" name="image_meta_caption_delim" value="<?php echo esc_attr($post['image_meta_caption_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
45
  </div>
46
  <div class="input">
47
  <p style="margin-bottom:5px;"><?php _e('Alt text', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Alt Text', 'pmxi_plugin') ?>">?</a></p>
48
- <textarea name="image_meta_alt" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first alt text will be associated with the first image URL, the second alt text will be associted with the second image URL, etc." <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_alt']) ?></textarea>
49
  <label for="image_meta_alt_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
50
- <input type="text" class="small" id="image_meta_alt_delim_<?php echo $entry;?>" name="image_meta_alt_delim" value="<?php echo esc_attr($post['image_meta_alt_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
51
  </div>
52
  <div class="input">
53
  <p style="margin-bottom:5px;"><?php _e('Description', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Description', 'pmxi_plugin') ?>">?</a></p>
54
- <textarea name="image_meta_description" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first description will be associated with the first URL, the second descrition will be associated with the second URL, etc." <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_description']) ?></textarea>
55
  <label for="image_meta_description_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
56
- <input type="text" class="small" id="image_meta_description_delim_<?php echo $entry;?>" name="image_meta_description_delim" value="<?php echo esc_attr($post['image_meta_description_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product"):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
57
  </div>
58
  </div>
59
- <?php if ($post_type != "product"):?>
60
- <center>
61
-
62
- <hr />
63
-
64
- <b>Please upgrade to the professional edition of WP All Import to download and import images to the post media gallery.</b>
65
-
66
- <p style='font-size: 1.1em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=featured-images&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
67
 
68
- </center>
69
- <?php endif; ?>
70
  </fieldset>
71
  </td>
72
  </tr>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
  <legend><?php _e('Featured Image & Media Gallery', 'pmxi_plugin') ?></legend>
5
+
6
+ <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>
7
+
8
+ <center>
9
+
10
+ <h3>Please upgrade to the professional edition of WP All Import to download and import images to the post media gallery.</h3>
11
+
12
+ <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=custom-fields&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
13
+
14
+ <hr />
15
+
16
+ </center>
17
+
18
+ <?php endif; ?>
19
+
20
  <div class="input">
21
  <p style="margin-bottom:5px;"><?php _e('<b>Image URLs</b> (one per line)', 'pmxi_plugin');?></p>
22
+ <textarea name="featured_image" class="newline" style="width:100%;margin-bottom:5px;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['featured_image']) ?></textarea>
23
  <label for="featured_delim_<?php echo $entry;?>"><?php _e('Place one image URL per line, or separate URLs with a ', 'pmxi_plugin');?></label>
24
+ <input type="text" class="small" id="featured_delim_<?php echo $entry;?>" name="featured_delim" value="<?php echo esc_attr($post['featured_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
25
  <span style="float:right;">
26
  <input type="hidden" name="create_draft" value="no" />
27
+ <input type="checkbox" id="create_draft_<?php echo $entry; ?>" name="create_draft" value="yes" <?php echo 'yes' == $post['create_draft'] ? 'checked="checked"' : '' ?> class="fix_checkbox" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
28
  <label for="create_draft_<?php echo $entry; ?>"><?php _e('If no images are downloaded successfully, create entry as Draft.', 'pmxi_plugin') ?></label>
29
  </span>
30
  </div>
31
  <div class="input" style="margin:3px 0px;">
32
  <input type="hidden" name="download_images" value="0" />
33
+ <input type="checkbox" id="download_images_<?php echo $entry; ?>" name="download_images" value="1" <?php echo $post['download_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
34
  <label for="download_images_<?php echo $entry;?>"><?php _e('Download images','pmxi_plugin');?> </label>
35
  <a href="#help" class="help" title="<?php _e('If this option enabled, then plugin will download images into the Uploads folder. If this option disabled, then plugin will search files in Uploads <strong>/wp-content/uploads/'.date("Y/m").'</strong> folder.', 'pmxi_plugin') ?>">?</a>
36
  </div>
37
  <div class="input switcher-target-download_images_<?php echo $entry; ?>" style="margin:3px 0px;">
38
  <input type="hidden" name="auto_rename_images" value="0" />
39
+ <input type="checkbox" id="auto_rename_images_<?php echo $entry; ?>" name="auto_rename_images" value="1" <?php echo $post['auto_rename_images'] ? 'checked="checked"' : '' ?> class="switcher fix_checkbox" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/>
40
  <label for="auto_rename_images_<?php echo $entry;?>"><?php _e('Instead of using original image file name, set file name(s) to','pmxi_plugin');?> </label>
41
  <input type="text" id="auto_rename_images_suffix_<?php echo $entry;?>" class="switcher-target-auto_rename_images_<?php echo $entry; ?>" name="auto_rename_images_suffix" value="<?php echo esc_attr($post['auto_rename_images_suffix']) ?>" /> <a href="#help" class="help" title="<?php _e('Instead of using original image file name, set file name(s) suffix', 'pmxi_plugin') ?>">?</a>
42
  </div>
48
  <div class="switcher-target-set_image_meta_data_<?php echo $entry; ?>" style="padding-left:17px;">
49
  <div class="input">
50
  <p style="margin-bottom:5px;"><?php _e('Title', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Title', 'pmxi_plugin') ?>">?</a></p>
51
+ <textarea name="image_meta_title" class="newline" style="width:100%; margin-bottom:5px;" placeholder="<?php _e('Default will be image filename. The first title will be associated with the first image URL, the second title will be associated with second image URL, etc.','pmxi_plugin');?>" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_title']) ?></textarea>
52
  <label for="image_meta_title_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
53
+ <input type="text" class="small" id="image_meta_title_delim_<?php echo $entry;?>" name="image_meta_title_delim" value="<?php echo esc_attr($post['image_meta_title_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
54
  </div>
55
  <div class="input">
56
  <p style="margin-bottom:5px;"><?php _e('Caption', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Capltion', 'pmxi_plugin') ?>">?</a></p>
57
+ <textarea name="image_meta_caption" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first caption will be associated with the first image URL, the second caption will be associated with the second image URL, etc." <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_caption']) ?></textarea>
58
  <label for="image_meta_caption_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
59
+ <input type="text" class="small" id="image_meta_caption_delim_<?php echo $entry;?>" name="image_meta_caption_delim" value="<?php echo esc_attr($post['image_meta_caption_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
60
  </div>
61
  <div class="input">
62
  <p style="margin-bottom:5px;"><?php _e('Alt text', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Alt Text', 'pmxi_plugin') ?>">?</a></p>
63
+ <textarea name="image_meta_alt" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first alt text will be associated with the first image URL, the second alt text will be associted with the second image URL, etc." <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_alt']) ?></textarea>
64
  <label for="image_meta_alt_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
65
+ <input type="text" class="small" id="image_meta_alt_delim_<?php echo $entry;?>" name="image_meta_alt_delim" value="<?php echo esc_attr($post['image_meta_alt_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
66
  </div>
67
  <div class="input">
68
  <p style="margin-bottom:5px;"><?php _e('Description', 'pmxi_plugin');?> <a href="#help" class="help" title="<?php _e('Image Description', 'pmxi_plugin') ?>">?</a></p>
69
+ <textarea name="image_meta_description" class="newline" style="width:100%; margin-bottom:5px;" placeholder="The first description will be associated with the first URL, the second descrition will be associated with the second URL, etc." <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>><?php echo esc_attr($post['image_meta_description']) ?></textarea>
70
  <label for="image_meta_description_delim_<?php echo $entry;?>"><?php _e('Separated by', 'pmxi_plugin');?></label>
71
+ <input type="text" class="small" id="image_meta_description_delim_<?php echo $entry;?>" name="image_meta_description_delim" value="<?php echo esc_attr($post['image_meta_description_delim']) ?>" style="width:5%; text-align:center;" <?php if ($post_type != "product" or ! class_exists('PMWI_Plugin')):?>disabled="disabled"<?php endif; ?>/> <span>(<?php _e('or newline','pmxi_plugin');?>)</span>
72
  </div>
73
  </div>
 
 
 
 
 
 
 
 
74
 
 
 
75
  </fieldset>
76
  </td>
77
  </tr>
views/admin/import/options/_main_options_template.php CHANGED
@@ -1,8 +1,37 @@
1
  <tr>
2
  <td style="border-bottom:1px solid #ccc;" colspan="3">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
- <input type="hidden" name="encoding" value="<?php echo ($this->isWizard) ? PMXI_Plugin::$session->data['pmxi_import']['encoding'] : $post['encoding']; ?>"/>
5
- <input type="hidden" name="delimiter" value="<?php echo ($this->isWizard) ? PMXI_Plugin::$session->data['pmxi_import']['is_csv'] : $post['delimiter']; ?>"/>
6
 
7
  <?php $is_support_post_format = ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) ? true : false; ?>
8
 
@@ -27,7 +56,7 @@
27
  </div>
28
  </div>
29
  </div>
30
- <div class="clear"></div>
31
  <div class="input">
32
  <input type="hidden" name="comment_status" value="closed" />
33
  <input type="checkbox" id="comment_status_<?php echo $entry; ?>" name="comment_status" value="open" <?php echo 'open' == $post['comment_status'] ? 'checked="checked"' : '' ?> />
@@ -39,17 +68,19 @@
39
  <label for="ping_status_<?php echo $entry; ?>"><?php _e('Allow Trackbacks and Pingbacks', 'pmxi_plugin') ?></label>
40
  </div>
41
  </div>
42
- </div>
43
  <?php if ($is_support_post_format):?>
44
  <div class="col3">
45
  <h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
46
  <div>
 
 
47
  <div class="input">
48
- <input type="radio" id="post_format_<?php echo "standart_" . $entry; ?>" name="post_format" value="0" <?php echo (empty($post['post_format'])) ? 'checked="checked"' : '' ?> />
49
- <label for="post_format_<?php echo "standart_" . $entry; ?>"><?php _e( "Standart", 'pmxi_plugin') ?></label>
50
  </div>
51
- <?php
52
- $post_formats = get_terms( 'post_format' , array('hide_empty' => false));
53
  if ( ! empty($post_formats) ){
54
  foreach ($post_formats as $post_format) {
55
  ?>
1
  <tr>
2
  <td style="border-bottom:1px solid #ccc;" colspan="3">
3
+
4
+ <?php if ($post_type != "post"):?>
5
+
6
+ <center>
7
+
8
+ <?php if ($post_type == "product" and class_exists('PMWI_Plugin')):?>
9
+
10
+ <?php if (PMWI_EDITION == 'free'):?>
11
+ <h3>Get our WooCommerce add-on to import to Simple, Variable, Grouped, and Affiliate/External products</h3>
12
+ <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=custom-fields&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
13
+ <?php endif; ?>
14
+
15
+ <input type="hidden" class="is_disabled" value="0"/>
16
+
17
+ <?php else: ?>
18
+ <h3>Please upgrade to the professional version of WP All Import to import to Custom Post Types.</h3>
19
+ <input type="hidden" class="is_disabled" value="1"/>
20
+ <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=custom-fields&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
21
+ <?php endif; ?>
22
+
23
+ <hr />
24
+
25
+ </center>
26
+
27
+ <?php else: ?>
28
+
29
+ <input type="hidden" class="is_disabled" value="0"/>
30
+
31
+ <?php endif; ?>
32
 
33
+ <input type="hidden" name="encoding" value="<?php echo ($isWizard) ? PMXI_Plugin::$session->data['pmxi_import']['encoding'] : $post['encoding']; ?>"/>
34
+ <input type="hidden" name="delimiter" value="<?php echo ($isWizard) ? PMXI_Plugin::$session->data['pmxi_import']['is_csv'] : $post['delimiter']; ?>"/>
35
 
36
  <?php $is_support_post_format = ( current_theme_supports( 'post-formats' ) && post_type_supports( $post_type, 'post-formats' ) ) ? true : false; ?>
37
 
56
  </div>
57
  </div>
58
  </div>
59
+ <div class="clear"></div>
60
  <div class="input">
61
  <input type="hidden" name="comment_status" value="closed" />
62
  <input type="checkbox" id="comment_status_<?php echo $entry; ?>" name="comment_status" value="open" <?php echo 'open' == $post['comment_status'] ? 'checked="checked"' : '' ?> />
68
  <label for="ping_status_<?php echo $entry; ?>"><?php _e('Allow Trackbacks and Pingbacks', 'pmxi_plugin') ?></label>
69
  </div>
70
  </div>
71
+ </div>
72
  <?php if ($is_support_post_format):?>
73
  <div class="col3">
74
  <h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
75
  <div>
76
+ <?php $post_formats = get_terms( 'post_format' , array('hide_empty' => false)); ?>
77
+
78
  <div class="input">
79
+ <input type="radio" id="post_format_<?php echo "standart_" . $entry; ?>" name="post_format" value="0" <?php echo (empty($post['post_format']) or ( empty($post_formats) )) ? 'checked="checked"' : '' ?> />
80
+ <label for="post_format_<?php echo "standart_" . $entry; ?>"><?php _e( "Standard", 'pmxi_plugin') ?></label>
81
  </div>
82
+
83
+ <?php
84
  if ( ! empty($post_formats) ){
85
  foreach ($post_formats as $post_format) {
86
  ?>
views/admin/import/options/_reimport_template.php CHANGED
@@ -2,28 +2,28 @@
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
  <legend><?php _e('Record Matching','pmxi_plugin');?></legend>
5
- <div class="input" style="margin-bottom:15px;">
 
6
  <input type="radio" id="auto_matching_<?php echo $entry; ?>" class="switcher" name="duplicate_matching" value="auto" <?php echo 'manual' != $post['duplicate_matching'] ? 'checked="checked"': '' ?>/>
7
  <label for="auto_matching_<?php echo $entry; ?>"><?php _e('Automatic Record Matching', 'pmxi_plugin' )?></label><br>
8
  <div class="switcher-target-auto_matching_<?php echo $entry; ?>" style="padding-left:17px;">
9
  <div class="input">
10
  <label><?php _e("Unique key"); ?></label>
11
- <input type="text" class="smaller-text" name="unique_key" style="width:300px;" value="<?php echo esc_attr($post['unique_key']) ?>" <?php echo ! ($this->isWizard && $update_previous->isEmpty()) ? 'disabled="disabled"' : '' ?>/>
12
- <a href="#help" class="help" title="<?php _e('Specify something that is unique for all records. If posts are being updated and not just created during a brand new import, the problem is that the value of the unique key is not unique.', 'pmxi_plugin') ?>">?</a>
 
13
  </div>
14
  </div>
15
  <input type="radio" id="manual_matching_<?php echo $entry; ?>" class="switcher" name="duplicate_matching" value="manual" <?php echo 'manual' == $post['duplicate_matching'] ? 'checked="checked"': '' ?>/>
16
  <label for="manual_matching_<?php echo $entry; ?>"><?php _e('Manual Record Matching', 'pmxi_plugin' )?></label>
17
- <a href="#help" class="help" title="<?php _e('This allows you to match records by something other than Unique Key.', 'pmxi_plugin') ?>">?</a>
18
  <div class="switcher-target-manual_matching_<?php echo $entry; ?>" style="padding-left:17px;">
19
- <div class="input">
20
- <span style="vertical-align:middle"><?php _e('Match records based on...', 'pmxi_plugin') ?></span><br>
21
  <input type="radio" id="duplicate_indicator_title_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="title" <?php echo 'title' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
22
- <label for="duplicate_indicator_title_<?php echo $entry; ?>"><?php _e('title', 'pmxi_plugin' )?></label><br>
23
  <input type="radio" id="duplicate_indicator_content_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="content" <?php echo 'content' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
24
- <label for="duplicate_indicator_content_<?php echo $entry; ?>"><?php _e('content', 'pmxi_plugin' )?></label><br>
25
  <input type="radio" id="duplicate_indicator_custom_field_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="custom field" <?php echo 'custom field' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
26
- <label for="duplicate_indicator_custom_field_<?php echo $entry; ?>"><?php _e('custom field', 'pmxi_plugin' )?></label><br>
27
  <span class="switcher-target-duplicate_indicator_custom_field_<?php echo $entry; ?>" style="vertical-align:middle; padding-left:17px;">
28
  <?php _e('Name', 'pmxi_plugin') ?>
29
  <input type="text" name="custom_duplicate_name" value="<?php echo esc_attr($post['custom_duplicate_name']) ?>" />
@@ -35,127 +35,215 @@
35
  </div>
36
  <hr>
37
  <div class="input">
38
- <input type="hidden" name="not_create_records" value="0" />
39
- <input type="checkbox" id="not_create_records_<?php echo $entry; ?>" name="not_create_records" value="1" <?php echo $post['not_create_records'] ? 'checked="checked"' : '' ?> />
40
- <label for="not_create_records_<?php echo $entry; ?>"><?php _e('Do Not Add New Records', 'pmxi_plugin') ?></label>
41
  </div>
42
  <div class="input">
43
  <input type="hidden" name="is_delete_missing" value="0" />
44
  <input type="checkbox" id="is_delete_missing_<?php echo $entry; ?>" name="is_delete_missing" value="1" <?php echo $post['is_delete_missing'] ? 'checked="checked"': '' ?> class="switcher"/>
45
- <label for="is_delete_missing_<?php echo $entry; ?>"><?php _e('Delete missing records', 'pmxi_plugin') ?></label>
46
  <a href="#help" class="help" title="<?php _e('Check this option if you want to delete posts from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
47
  </div>
48
  <div class="switcher-target-is_delete_missing_<?php echo $entry; ?>" style="padding-left:17px;">
49
  <div class="input">
50
  <input type="hidden" name="is_keep_attachments" value="0" />
51
  <input type="checkbox" id="is_keep_attachments_<?php echo $entry; ?>" name="is_keep_attachments" value="1" <?php echo $post['is_keep_attachments'] ? 'checked="checked"': '' ?> />
52
- <label for="is_keep_attachments_<?php echo $entry; ?>"><?php _e('Keep attachments when records removed', 'pmxi_plugin') ?></label>
53
- <a href="#help" class="help" title="<?php _e('Check this option if you want attachments like featured image to be kept in media library after parent post or page is removed or replaced during reimport operation.', 'pmxi_plugin') ?>">?</a>
54
  </div>
55
- </div>
56
- <div class="input">
57
- <input type="hidden" name="is_update_missing_cf" value="0" />
58
- <input type="checkbox" id="is_update_missing_cf_<?php echo $entry; ?>" name="is_update_missing_cf" value="1" <?php echo $post['is_update_missing_cf'] ? 'checked="checked"': '' ?> class="switcher"/>
59
- <label for="is_update_missing_cf_<?php echo $entry; ?>"><?php _e('Instead of Deleting Missing Records, Set Custom Field', 'pmxi_plugin') ?></label>
60
- <a href="#help" class="help" title="<?php _e('Check this option if you want to update posts custom fields from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
61
- </div>
62
- <div class="switcher-target-is_update_missing_cf_<?php echo $entry; ?>" style="padding-left:17px;">
63
  <div class="input">
64
- <?php _e('Name', 'pmxi_plugin') ?>
65
- <input type="text" name="update_missing_cf_name" value="<?php echo esc_attr($post['update_missing_cf_name']) ?>" /><br>
66
- <?php _e('Value', 'pmxi_plugin') ?>
67
- <input type="text" name="update_missing_cf_value" value="<?php echo esc_attr($post['update_missing_cf_value']) ?>" />
68
  </div>
69
- </div>
70
- <div class="input">
71
- <input type="radio" id="is_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="yes" <?php echo "yes" == $post['is_keep_former_posts'] ? 'checked="checked"': '' ?> class="switcher" />
72
- <label for="is_keep_former_posts_<?php echo $entry; ?>"><?php _e('Do not update already existing records', 'pmxi_plugin') ?></label> <br>
73
- <input type="radio" id="is_not_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="no" <?php echo "yes" != $post['is_keep_former_posts'] ? 'checked="checked"': '' ?> class="switcher" />
74
- <label for="is_not_keep_former_posts_<?php echo $entry; ?>"><?php _e('Update existing records', 'pmxi_plugin') ?></label>
75
- <div class="switcher-target-is_not_keep_former_posts_<?php echo $entry; ?>" style="padding-left:17px;">
76
- <div class="input">
77
- <input type="hidden" name="is_keep_status" value="0" />
78
- <input type="checkbox" id="is_keep_status_<?php echo $entry; ?>" name="is_keep_status" value="1" <?php echo $post['is_keep_status'] ? 'checked="checked"': '' ?> />
79
- <label for="is_keep_status_<?php echo $entry; ?>"><?php _e('Keep status', 'pmxi_plugin') ?></label>
80
- <a href="#help" class="help" title="<?php _e('Check this option if you do not want previously imported posts to change their publish status or being restored from Trash.', 'pmxi_plugin') ?>">?</a>
81
  </div>
82
- <div class="input">
83
- <input type="hidden" name="is_keep_title" value="0" />
84
- <input type="checkbox" id="is_keep_title_<?php echo $entry; ?>" name="is_keep_title" value="1" <?php echo $post['is_keep_title'] ? 'checked="checked"': '' ?> />
85
- <label for="is_keep_title_<?php echo $entry; ?>"><?php _e('Keep title', 'pmxi_plugin') ?></label>
 
 
 
 
 
 
 
86
 
87
- </div>
88
- <div class="input">
89
- <input type="hidden" name="is_keep_excerpt" value="0" />
90
- <input type="checkbox" id="is_keep_excerpt_<?php echo $entry; ?>" name="is_keep_excerpt" value="1" <?php echo $post['is_keep_excerpt'] ? 'checked="checked"': '' ?> />
91
- <label for="is_keep_excerpt_<?php echo $entry; ?>"><?php _e('Keep excerpt', 'pmxi_plugin') ?></label>
92
- </div>
93
- <div class="input">
94
- <input type="hidden" name="is_keep_dates" value="0" />
95
- <input type="checkbox" id="is_keep_dates_<?php echo $entry; ?>" name="is_keep_dates" value="1" <?php echo $post['is_keep_dates'] ? 'checked="checked"': '' ?> />
96
- <label for="is_keep_dates_<?php echo $entry; ?>"><?php _e('Keep dates', 'pmxi_plugin') ?></label>
97
- </div>
98
- <div class="input">
99
- <input type="hidden" name="is_keep_menu_order" value="0" />
100
- <input type="checkbox" id="is_keep_menu_order_<?php echo $entry; ?>" name="is_keep_menu_order" value="1" <?php echo $post['is_keep_menu_order'] ? 'checked="checked"': '' ?> />
101
- <label for="is_keep_menu_order_<?php echo $entry; ?>"><?php _e('Keep menu order', 'pmxi_plugin') ?></label>
102
- </div>
103
- <div class="input">
104
- <input type="hidden" name="is_keep_parent" value="0" />
105
- <input type="checkbox" id="is_keep_parent_<?php echo $entry; ?>" name="is_keep_parent" value="1" <?php echo $post['is_keep_parent'] ? 'checked="checked"': '' ?> />
106
- <label for="is_keep_parent_<?php echo $entry; ?>"><?php _e('Keep parent post', 'pmxi_plugin') ?></label>
107
- </div>
108
- <div class="input">
109
- <input type="hidden" name="is_keep_content" value="0" />
110
- <input type="checkbox" id="is_keep_content_<?php echo $entry; ?>" name="is_keep_content" value="1" <?php echo $post['is_keep_content'] ? 'checked="checked"': '' ?> />
111
- <label for="is_keep_content_<?php echo $entry; ?>"><?php _e('Keep content', 'pmxi_plugin') ?></label>
112
- </div>
113
- <div class="input">
114
- <input type="hidden" name="is_keep_categories" value="0" />
115
- <input type="checkbox" id="is_keep_categories_<?php echo $entry; ?>" name="is_keep_categories" value="1" class="switcher" <?php echo $post['is_keep_categories'] ? 'checked="checked"': '' ?> />
116
- <label for="is_keep_categories_<?php echo $entry; ?>"><?php _e('Keep categories, tags and taxonomies', 'pmxi_plugin') ?></label>
117
- <div class="switcher-target-is_keep_categories_<?php echo $entry; ?>" style="padding-left:17px;">
118
- <div class="input" style="margin-bottom:3px;">
119
- <input type="hidden" name="is_add_newest_categories" value="0" />
120
- <input type="checkbox" id="is_add_newest_categories_<?php echo $entry; ?>" name="is_add_newest_categories" value="1" <?php echo $post['is_add_newest_categories'] ? 'checked="checked"': '' ?> />
121
- <label for="is_add_newest_categories_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Add new categories and taxonomies', 'pmxi_plugin') ?></label>
122
- </div>
123
  </div>
124
- </div>
125
- <div class="input">
126
- <input type="hidden" name="is_keep_attachments_on_update" value="0" />
127
- <input type="checkbox" id="is_keep_attachments_on_update_<?php echo $entry; ?>" name="is_keep_attachments_on_update" value="1" <?php echo $post['is_keep_attachments_on_update'] ? 'checked="checked"': '' ?> />
128
- <label for="is_keep_attachments_on_update_<?php echo $entry; ?>"><?php _e('Keep attachments', 'pmxi_plugin') ?></label>
129
- </div>
130
- <div class="input">
131
- <input type="hidden" name="is_keep_images" value="0" />
132
- <input type="checkbox" id="is_keep_images_<?php echo $entry; ?>" name="is_keep_images" value="1" <?php echo $post['is_keep_images'] ? 'checked="checked"': '' ?> />
133
- <label for="is_keep_images_<?php echo $entry; ?>"><?php _e('Do not import images', 'pmxi_plugin') ?></label>
134
- <a href="#help" class="help" title="<?php _e('This will keep the featured image if it exists, so you could modify the post image manually, and then do a reimport, and it would not overwrite the manually modified post image.', 'pmxi_plugin') ?>">?</a>
135
- </div>
136
- <div class="input">
137
- <input type="hidden" name="no_create_featured_image" value="0" />
138
- <input type="checkbox" id="no_create_featured_image_<?php echo $entry; ?>" name="no_create_featured_image" value="1" <?php echo $post['no_create_featured_image'] ? 'checked="checked"': '' ?> />
139
- <label for="no_create_featured_image_<?php echo $entry; ?>"><?php _e('Only keep images for posts that already have images.', 'pmxi_plugin') ?></label>
140
- <a href="#help" class="help" title="<?php _e('This option will keep images for posts that already have images, and import images for posts that do not already have images.', 'pmxi_plugin') ?>">?</a>
141
- </div>
142
- <div class="input">
143
- <input type="hidden" name="keep_custom_fields" value="0" />
144
- <input type="checkbox" id="keep_custom_fields_<?php echo $entry; ?>" name="keep_custom_fields" value="1" <?php echo $post['keep_custom_fields'] ? 'checked="checked"': '' ?> class="switcher switcher-reversed"/>
145
- <label for="keep_custom_fields_<?php echo $entry; ?>"><?php _e('Keep custom fields', 'pmxi_plugin') ?></label>
146
- <a href="#help" class="help" title="<?php _e('If Keep Custom Fields box is checked, it will keep all Custom Fields, and add any new Custom Fields specified in Custom Fields section, as long as they do not overwrite existing fields. If \'Only keep this Custom Fields\' is specified, it will only keep the specified fields.', 'pmxi_plugin') ?>">?</a>
147
- <div class="keep_except" style="padding-left:17px; <?php if (!$post['keep_custom_fields'] ):?>display:none;<?php endif;?>" >
148
- <div class="input">
149
- <label for="keep_custom_fields_except"><?php _e('Keep all Custom Fields, except for the fields specified for update <small>(separate field names with commas)</small>', 'pmxi_plugin') ?></label>
150
- <input type="text" id="keep_custom_fields_except" name="keep_custom_fields_except" style="width:100%;" value="<?php echo esc_attr($post['keep_custom_fields_except']) ?>" />
151
- </div>
152
  </div>
153
- </div>
154
- <div class="switcher-target-keep_custom_fields_<?php echo $entry; ?>" style="padding-left:17px;">
155
  <div class="input">
156
- <label for="keep_custom_fields_specific"><?php _e('Only Keep These Custom Fields <small>(separate field names with commas)</small>', 'pmxi_plugin') ?></label>
157
- <input type="text" id="keep_custom_fields_specific" name="keep_custom_fields_specific" style="width:100%;" value="<?php echo esc_attr($post['keep_custom_fields_specific']) ?>" />
 
158
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
159
  </div>
160
  </div>
161
  </div>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
  <legend><?php _e('Record Matching','pmxi_plugin');?></legend>
5
+ <div class="input" style="margin-bottom:15px; position:relative;">
6
+ <input type="button" value="<?php _e('Click to see hints', 'pmxi_plugin');?>" class="button-primary pmxi_tips_pointer">
7
  <input type="radio" id="auto_matching_<?php echo $entry; ?>" class="switcher" name="duplicate_matching" value="auto" <?php echo 'manual' != $post['duplicate_matching'] ? 'checked="checked"': '' ?>/>
8
  <label for="auto_matching_<?php echo $entry; ?>"><?php _e('Automatic Record Matching', 'pmxi_plugin' )?></label><br>
9
  <div class="switcher-target-auto_matching_<?php echo $entry; ?>" style="padding-left:17px;">
10
  <div class="input">
11
  <label><?php _e("Unique key"); ?></label>
12
+
13
+ <input type="text" class="smaller-text" name="unique_key" style="width:300px;" value="<?php echo esc_attr($post['unique_key']) ?>" <?php echo ( ! $isWizard ) ? 'disabled="disabled"' : '' ?>/>
14
+ <a href="#help" class="help" title="<?php _e('If posts are being updated and not just created during a brand new import, the problem is that the value of the unique key is not unique for each record.', 'pmxi_plugin') ?>">?</a>
15
  </div>
16
  </div>
17
  <input type="radio" id="manual_matching_<?php echo $entry; ?>" class="switcher" name="duplicate_matching" value="manual" <?php echo 'manual' == $post['duplicate_matching'] ? 'checked="checked"': '' ?>/>
18
  <label for="manual_matching_<?php echo $entry; ?>"><?php _e('Manual Record Matching', 'pmxi_plugin' )?></label>
 
19
  <div class="switcher-target-manual_matching_<?php echo $entry; ?>" style="padding-left:17px;">
20
+ <div class="input">
 
21
  <input type="radio" id="duplicate_indicator_title_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="title" <?php echo 'title' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
22
+ <label for="duplicate_indicator_title_<?php echo $entry; ?>"><?php _e('match by Title', 'pmxi_plugin' )?></label><br>
23
  <input type="radio" id="duplicate_indicator_content_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="content" <?php echo 'content' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
24
+ <label for="duplicate_indicator_content_<?php echo $entry; ?>"><?php _e('match by Content', 'pmxi_plugin' )?></label><br>
25
  <input type="radio" id="duplicate_indicator_custom_field_<?php echo $entry; ?>" class="switcher" name="duplicate_indicator" value="custom field" <?php echo 'custom field' == $post['duplicate_indicator'] ? 'checked="checked"': '' ?>/>
26
+ <label for="duplicate_indicator_custom_field_<?php echo $entry; ?>"><?php _e('match by Custom field', 'pmxi_plugin' )?></label><br>
27
  <span class="switcher-target-duplicate_indicator_custom_field_<?php echo $entry; ?>" style="vertical-align:middle; padding-left:17px;">
28
  <?php _e('Name', 'pmxi_plugin') ?>
29
  <input type="text" name="custom_duplicate_name" value="<?php echo esc_attr($post['custom_duplicate_name']) ?>" />
35
  </div>
36
  <hr>
37
  <div class="input">
38
+ <input type="hidden" name="create_new_records" value="0" />
39
+ <input type="checkbox" id="create_new_records_<?php echo $entry; ?>" name="create_new_records" value="1" <?php echo $post['create_new_records'] ? 'checked="checked"' : '' ?> />
40
+ <label for="create_new_records_<?php echo $entry; ?>"><?php _e('Create new posts from records newly present in your file', 'pmxi_plugin') ?></label>
41
  </div>
42
  <div class="input">
43
  <input type="hidden" name="is_delete_missing" value="0" />
44
  <input type="checkbox" id="is_delete_missing_<?php echo $entry; ?>" name="is_delete_missing" value="1" <?php echo $post['is_delete_missing'] ? 'checked="checked"': '' ?> class="switcher"/>
45
+ <label for="is_delete_missing_<?php echo $entry; ?>"><?php _e('Delete posts that are no longer present in your file', 'pmxi_plugin') ?></label>
46
  <a href="#help" class="help" title="<?php _e('Check this option if you want to delete posts from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
47
  </div>
48
  <div class="switcher-target-is_delete_missing_<?php echo $entry; ?>" style="padding-left:17px;">
49
  <div class="input">
50
  <input type="hidden" name="is_keep_attachments" value="0" />
51
  <input type="checkbox" id="is_keep_attachments_<?php echo $entry; ?>" name="is_keep_attachments" value="1" <?php echo $post['is_keep_attachments'] ? 'checked="checked"': '' ?> />
52
+ <label for="is_keep_attachments_<?php echo $entry; ?>"><?php _e('Do not remove attachments', 'pmxi_plugin') ?></label>
53
+ <a href="#help" class="help" title="<?php _e('Check this option if you want attachments like *.pdf or *.doc files to be kept in media library after parent post or page is removed or replaced during reimport operation.', 'pmxi_plugin') ?>">?</a>
54
  </div>
 
 
 
 
 
 
 
 
55
  <div class="input">
56
+ <input type="hidden" name="is_keep_imgs" value="0" />
57
+ <input type="checkbox" id="is_keep_imgs_<?php echo $entry; ?>" name="is_keep_imgs" value="1" <?php echo $post['is_keep_imgs'] ? 'checked="checked"': '' ?> />
58
+ <label for="is_keep_imgs_<?php echo $entry; ?>"><?php _e('Do not remove images', 'pmxi_plugin') ?></label>
59
+ <a href="#help" class="help" title="<?php _e('Check this option if you want images like featured image to be kept in media library after parent post or page is removed or replaced during reimport operation.', 'pmxi_plugin') ?>">?</a>
60
  </div>
61
+ <div class="input">
62
+ <input type="hidden" name="is_update_missing_cf" value="0" />
63
+ <input type="checkbox" id="is_update_missing_cf_<?php echo $entry; ?>" name="is_update_missing_cf" value="1" <?php echo $post['is_update_missing_cf'] ? 'checked="checked"': '' ?> class="switcher"/>
64
+ <label for="is_update_missing_cf_<?php echo $entry; ?>"><?php _e('Instead of deletion, set Custom Field', 'pmxi_plugin') ?></label>
65
+ <a href="#help" class="help" title="<?php _e('Check this option if you want to update posts custom fields from the previous import operation which are not found among newly imported set.', 'pmxi_plugin') ?>">?</a>
66
+ <div class="switcher-target-is_update_missing_cf_<?php echo $entry; ?>" style="padding-left:17px;">
67
+ <div class="input">
68
+ <?php _e('Name', 'pmxi_plugin') ?>
69
+ <input type="text" name="update_missing_cf_name" value="<?php echo esc_attr($post['update_missing_cf_name']) ?>" />
70
+ <?php _e('Value', 'pmxi_plugin') ?>
71
+ <input type="text" name="update_missing_cf_value" value="<?php echo esc_attr($post['update_missing_cf_value']) ?>" />
72
+ </div>
73
  </div>
74
+ </div>
75
+ <div class="input">
76
+ <input type="hidden" name="set_missing_to_draft" value="0" />
77
+ <input type="checkbox" id="set_missing_to_draft_<?php echo $entry; ?>" name="set_missing_to_draft" value="1" <?php echo $post['set_missing_to_draft'] ? 'checked="checked"': '' ?> />
78
+ <label for="set_missing_to_draft_<?php echo $entry; ?>"><?php _e('Instead of deletion, change post status to Draft', 'pmxi_plugin') ?></label>
79
+ </div>
80
+ </div>
81
+ <div class="input">
82
+ <input type="hidden" id="is_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="yes" />
83
+ <input type="checkbox" id="is_not_keep_former_posts_<?php echo $entry; ?>" name="is_keep_former_posts" value="no" <?php echo "yes" != $post['is_keep_former_posts'] ? 'checked="checked"': '' ?> class="switcher" />
84
+ <label for="is_not_keep_former_posts_<?php echo $entry; ?>"><?php _e('Update existing posts with changed data in your file', 'pmxi_plugin') ?></label>
85
 
86
+ <div class="switcher-target-is_not_keep_former_posts_<?php echo $entry; ?>" style="padding-left:17px;">
87
+ <input type="radio" id="update_all_data_<?php echo $entry; ?>" class="switcher" name="update_all_data" value="yes" <?php echo 'no' != $post['update_all_data'] ? 'checked="checked"': '' ?>/>
88
+ <label for="update_all_data_<?php echo $entry; ?>"><?php _e('Update all data', 'pmxi_plugin' )?></label><br>
89
+
90
+ <input type="radio" id="update_choosen_data_<?php echo $entry; ?>" class="switcher" name="update_all_data" value="no" <?php echo 'no' == $post['update_all_data'] ? 'checked="checked"': '' ?>/>
91
+ <label for="update_choosen_data_<?php echo $entry; ?>"><?php _e('Choose which data to update', 'pmxi_plugin' )?></label><br>
92
+ <div class="switcher-target-update_choosen_data_<?php echo $entry; ?>" style="padding-left:17px;">
93
+ <div class="input">
94
+ <input type="hidden" name="is_update_status" value="0" />
95
+ <input type="checkbox" id="is_update_status_<?php echo $entry; ?>" name="is_update_status" value="1" <?php echo $post['is_update_status'] ? 'checked="checked"': '' ?> />
96
+ <label for="is_update_status_<?php echo $entry; ?>"><?php _e('Post status', 'pmxi_plugin') ?></label>
97
+ <a href="#help" class="help" title="<?php _e('Check this option if you want previously imported posts to change their publish status or being restored from Trash.', 'pmxi_plugin') ?>">?</a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
98
  </div>
99
+ <div class="input">
100
+ <input type="hidden" name="is_update_title" value="0" />
101
+ <input type="checkbox" id="is_update_title_<?php echo $entry; ?>" name="is_update_title" value="1" <?php echo $post['is_update_title'] ? 'checked="checked"': '' ?> />
102
+ <label for="is_update_title_<?php echo $entry; ?>"><?php _e('Title', 'pmxi_plugin') ?></label>
103
+ </div>
104
+ <div class="input">
105
+ <input type="hidden" name="is_update_slug" value="0" />
106
+ <input type="checkbox" id="is_update_slug_<?php echo $entry; ?>" name="is_update_slug" value="1" <?php echo $post['is_update_slug'] ? 'checked="checked"': '' ?> />
107
+ <label for="is_update_slug_<?php echo $entry; ?>"><?php _e('Slug', 'pmxi_plugin') ?></label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  </div>
 
 
109
  <div class="input">
110
+ <input type="hidden" name="is_update_content" value="0" />
111
+ <input type="checkbox" id="is_update_content_<?php echo $entry; ?>" name="is_update_content" value="1" <?php echo $post['is_update_content'] ? 'checked="checked"': '' ?> />
112
+ <label for="is_update_content_<?php echo $entry; ?>"><?php _e('Content', 'pmxi_plugin') ?></label>
113
  </div>
114
+ <div class="input">
115
+ <input type="hidden" name="is_update_excerpt" value="0" />
116
+ <input type="checkbox" id="is_update_excerpt_<?php echo $entry; ?>" name="is_update_excerpt" value="1" <?php echo $post['is_update_excerpt'] ? 'checked="checked"': '' ?> />
117
+ <label for="is_update_excerpt_<?php echo $entry; ?>"><?php _e('Excerpt/Short Description', 'pmxi_plugin') ?></label>
118
+ </div>
119
+ <div class="input">
120
+ <input type="hidden" name="is_update_dates" value="0" />
121
+ <input type="checkbox" id="is_update_dates_<?php echo $entry; ?>" name="is_update_dates" value="1" <?php echo $post['is_update_dates'] ? 'checked="checked"': '' ?> />
122
+ <label for="is_update_dates_<?php echo $entry; ?>"><?php _e('Dates', 'pmxi_plugin') ?></label>
123
+ </div>
124
+ <div class="input">
125
+ <input type="hidden" name="is_update_menu_order" value="0" />
126
+ <input type="checkbox" id="is_update_menu_order_<?php echo $entry; ?>" name="is_update_menu_order" value="1" <?php echo $post['is_update_menu_order'] ? 'checked="checked"': '' ?> />
127
+ <label for="is_update_menu_order_<?php echo $entry; ?>"><?php _e('Menu order', 'pmxi_plugin') ?></label>
128
+ </div>
129
+ <div class="input">
130
+ <input type="hidden" name="is_update_parent" value="0" />
131
+ <input type="checkbox" id="is_update_parent_<?php echo $entry; ?>" name="is_update_parent" value="1" <?php echo $post['is_update_parent'] ? 'checked="checked"': '' ?> />
132
+ <label for="is_update_parent_<?php echo $entry; ?>"><?php _e('Parent post', 'pmxi_plugin') ?></label>
133
+ </div>
134
+ <div class="input">
135
+ <input type="hidden" name="is_update_attachments" value="0" />
136
+ <input type="checkbox" id="is_update_attachments_<?php echo $entry; ?>" name="is_update_attachments" value="1" <?php echo $post['is_update_attachments'] ? 'checked="checked"': '' ?> />
137
+ <label for="is_update_attachments_<?php echo $entry; ?>"><?php _e('Attachments', 'pmxi_plugin') ?></label>
138
+ </div>
139
+
140
+ <?php
141
+
142
+ // add-ons re-import options
143
+ do_action('pmxi_reimport', $entry, $post);
144
+
145
+ ?>
146
+
147
+ <div class="input">
148
+ <input type="hidden" name="is_update_images" value="0" />
149
+ <input type="checkbox" id="is_update_images_<?php echo $entry; ?>" name="is_update_images" value="1" <?php echo $post['is_update_images'] ? 'checked="checked"': '' ?> class="switcher" />
150
+ <label for="is_update_images_<?php echo $entry; ?>"><?php _e('Images', 'pmxi_plugin') ?></label>
151
+ <!--a href="#help" class="help" title="<?php _e('This will keep the featured image if it exists, so you could modify the post image manually, and then do a reimport, and it would not overwrite the manually modified post image.', 'pmxi_plugin') ?>">?</a-->
152
+ <div class="switcher-target-is_update_images_<?php echo $entry; ?>" style="padding-left:17px;">
153
+ <div class="input" style="margin-bottom:3px;">
154
+ <input type="radio" id="update_images_logic_full_update_<?php echo $entry; ?>" name="update_images_logic" value="full_update" <?php echo ( "full_update" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
155
+ <label for="update_images_logic_full_update_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Update all images', 'pmxi_plugin') ?></label>
156
+ </div>
157
+ <div class="input" style="margin-bottom:3px;">
158
+ <input type="radio" id="update_images_logic_add_new_<?php echo $entry; ?>" name="update_images_logic" value="add_new" <?php echo ( "add_new" == $post['update_images_logic'] ) ? 'checked="checked"': '' ?> />
159
+ <label for="update_images_logic_add_new_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Don\'t touch existing images, append new images', 'pmxi_plugin') ?></label>
160
+ </div>
161
+ </div>
162
+ </div>
163
+ <div class="input">
164
+ <input type="hidden" name="custom_fields_list" value="0" />
165
+ <input type="hidden" name="is_update_custom_fields" value="0" />
166
+ <input type="checkbox" id="is_update_custom_fields_<?php echo $entry; ?>" name="is_update_custom_fields" value="1" <?php echo $post['is_update_custom_fields'] ? 'checked="checked"': '' ?> class="switcher"/>
167
+ <label for="is_update_custom_fields_<?php echo $entry; ?>"><?php _e('Custom Fields', 'pmxi_plugin') ?></label>
168
+ <!--a href="#help" class="help" title="<?php _e('If Keep Custom Fields box is checked, it will keep all Custom Fields, and add any new Custom Fields specified in Custom Fields section, as long as they do not overwrite existing fields. If \'Only keep this Custom Fields\' is specified, it will only keep the specified fields.', 'pmxi_plugin') ?>">?</a-->
169
+ <div class="switcher-target-is_update_custom_fields_<?php echo $entry; ?>" style="padding-left:17px;">
170
+ <div class="input">
171
+ <input type="radio" id="update_custom_fields_logic_full_update_<?php echo $entry; ?>" name="update_custom_fields_logic" value="full_update" <?php echo ( "full_update" == $post['update_custom_fields_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
172
+ <label for="update_custom_fields_logic_full_update_<?php echo $entry; ?>"><?php _e('Update all Custom Fields', 'pmxi_plugin') ?></label>
173
+ </div>
174
+ <?php
175
+ $existing_meta_keys = array();
176
+ $hide_fields = array('_wp_page_template', '_edit_lock', '_edit_last', '_wp_trash_meta_status', '_wp_trash_meta_time');
177
+ if (!empty($meta_keys) and $meta_keys->count()):
178
+ foreach ($meta_keys as $meta_key) { if (in_array($meta_key['meta_key'], $hide_fields) or strpos($meta_key['meta_key'], '_wp') === 0) continue;
179
+ $existing_meta_keys[] = $meta_key['meta_key'];
180
+ }
181
+ endif;
182
+ ?>
183
+ <div class="input">
184
+ <input type="radio" id="update_custom_fields_logic_only_<?php echo $entry; ?>" name="update_custom_fields_logic" value="only" <?php echo ( "only" == $post['update_custom_fields_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
185
+ <label for="update_custom_fields_logic_only_<?php echo $entry; ?>"><?php _e('Update only these Custom Fields, leave the rest alone', 'pmxi_plugin') ?></label>
186
+ <div class="switcher-target-update_custom_fields_logic_only_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
187
+
188
+ <span class="hidden choosen_values"><?php if (!empty($existing_meta_keys)) echo implode(',', $existing_meta_keys);?></span>
189
+ <input class="choosen_input" value="<?php if (!empty($post['custom_fields_list']) and "only" == $post['update_custom_fields_logic']) echo implode(',', $post['custom_fields_list']); ?>" type="hidden" name="custom_fields_only_list"/>
190
+ </div>
191
+ </div>
192
+ <div class="input">
193
+ <input type="radio" id="update_custom_fields_logic_all_except_<?php echo $entry; ?>" name="update_custom_fields_logic" value="all_except" <?php echo ( "all_except" == $post['update_custom_fields_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
194
+ <label for="update_custom_fields_logic_all_except_<?php echo $entry; ?>"><?php _e('Leave these fields alone, update all other Custom Fields', 'pmxi_plugin') ?></label>
195
+ <div class="switcher-target-update_custom_fields_logic_all_except_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
196
+
197
+ <span class="hidden choosen_values"><?php if (!empty($existing_meta_keys)) echo implode(',', $existing_meta_keys);?></span>
198
+ <input class="choosen_input" value="<?php if (!empty($post['custom_fields_list']) and "all_except" == $post['update_custom_fields_logic']) echo implode(',', $post['custom_fields_list']); ?>" type="hidden" name="custom_fields_except_list"/>
199
+ </div>
200
+ </div>
201
+ </div>
202
+ </div>
203
+ <div class="input">
204
+ <input type="hidden" name="taxonomies_list" value="0" />
205
+ <input type="hidden" name="is_update_categories" value="0" />
206
+ <input type="checkbox" id="is_update_categories_<?php echo $entry; ?>" name="is_update_categories" value="1" class="switcher" <?php echo $post['is_update_categories'] ? 'checked="checked"': '' ?> />
207
+ <label for="is_update_categories_<?php echo $entry; ?>"><?php _e('Taxonomies (incl. Categories and Tags)', 'pmxi_plugin') ?></label>
208
+ <div class="switcher-target-is_update_categories_<?php echo $entry; ?>" style="padding-left:17px;">
209
+ <?php
210
+ $existing_taxonomies = array();
211
+ $hide_taxonomies = (class_exists('PMWI_Plugin')) ? array('product_type') : array();
212
+ $post_taxonomies = array_diff_key(get_taxonomies_by_object_type(array($post_type), 'object'), array_flip($hide_taxonomies));
213
+ if (!empty($post_taxonomies)):
214
+ foreach ($post_taxonomies as $ctx): if ("" == $ctx->labels->name or (class_exists('PMWI_Plugin') and $post_type == "product" and strpos($ctx->name, "pa_") === 0)) continue;
215
+ $existing_taxonomies[] = $ctx->name;
216
+ endforeach;
217
+ endif;
218
+ ?>
219
+ <div class="input" style="margin-bottom:3px;">
220
+ <input type="radio" id="update_categories_logic_all_except_<?php echo $entry; ?>" name="update_categories_logic" value="all_except" <?php echo ( "all_except" == $post['update_categories_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
221
+ <label for="update_categories_logic_all_except_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Leave these taxonomies alone, update all others', 'pmxi_plugin') ?></label>
222
+ <div class="switcher-target-update_categories_logic_all_except_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
223
+
224
+ <span class="hidden choosen_values"><?php if (!empty($existing_taxonomies)) echo implode(',', $existing_taxonomies);?></span>
225
+ <input class="choosen_input" value="<?php if (!empty($post['taxonomies_list']) and "all_except" == $post['update_categories_logic']) echo implode(',', $post['taxonomies_list']); ?>" type="hidden" name="taxonomies_except_list"/>
226
+ </div>
227
+ </div>
228
+ <div class="input" style="margin-bottom:3px;">
229
+ <input type="radio" id="update_categories_logic_only_<?php echo $entry; ?>" name="update_categories_logic" value="only" <?php echo ( "only" == $post['update_categories_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
230
+ <label for="update_categories_logic_only_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Update only these taxonomies, leave the rest alone', 'pmxi_plugin') ?></label>
231
+ <div class="switcher-target-update_categories_logic_only_<?php echo $entry; ?> pmxi_choosen" style="padding-left:17px;">
232
+
233
+ <span class="hidden choosen_values"><?php if (!empty($existing_taxonomies)) echo implode(',', $existing_taxonomies);?></span>
234
+ <input class="choosen_input" value="<?php if (!empty($post['taxonomies_list']) and "only" == $post['update_categories_logic']) echo implode(',', $post['taxonomies_list']); ?>" type="hidden" name="taxonomies_only_list"/>
235
+ </div>
236
+ </div>
237
+ <div class="input" style="margin-bottom:3px;">
238
+ <input type="radio" id="update_categories_logic_full_update_<?php echo $entry; ?>" name="update_categories_logic" value="full_update" <?php echo ( "full_update" == $post['update_categories_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
239
+ <label for="update_categories_logic_full_update_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Remove existing taxonomies, add new taxonomies', 'pmxi_plugin') ?></label>
240
+ </div>
241
+ <div class="input" style="margin-bottom:3px;">
242
+ <input type="radio" id="update_categories_logic_add_new_<?php echo $entry; ?>" name="update_categories_logic" value="add_new" <?php echo ( "add_new" == $post['update_categories_logic'] ) ? 'checked="checked"': '' ?> class="switcher"/>
243
+ <label for="update_categories_logic_add_new_<?php echo $entry; ?>" style="position:relative; top:1px;"><?php _e('Only add new', 'pmxi_plugin') ?></label>
244
+ </div>
245
+ </div>
246
+ </div>
247
  </div>
248
  </div>
249
  </div>
views/admin/import/options/_scheduling_template.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php if (in_array($source_type, array('url', 'ftp'))): ?>
2
  <tr>
3
- <td colspan="3">
4
  <fieldset class="optionsset">
5
- <legend><?php _e('Scheduling','pmxi_plugin');?></legend>
6
  <div class="input">
7
  <input type="hidden" name="is_scheduled" value="0" />
8
- <input type="checkbox" id="is_scheduled_<?php echo $entry; ?>" class="switcher" name="is_scheduled" value="1" <?php echo $scheduled['is_scheduled'] ? 'checked="checked"': '' ?>/>
9
  <label for="is_scheduled_<?php echo $entry; ?>"><?php _e('Schedule import using WordPress Scheduling Logic', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Using this is not recommended. Unless you are importing a very small file, use cron jobs instead.', 'pmxi_plugin') ?>">?</a></label>
10
  <span class="switcher-target-is_scheduled_<?php echo $entry; ?>" style="vertical-align:middle">
11
  <select name="scheduled_period">
@@ -32,7 +32,7 @@
32
  <?php _e('<b>This import can be also be scheduled using cron jobs.</b> Save the import, visit the <i>Manage Imports</i> page, and click the <i>Cron Scheduling</i> link to set up cron scheduling. Using WordPress scheduling logic is not recommended for large files.','pmxi_plugin');?>
33
  </p>
34
 
35
- </div>
36
  </fieldset>
37
  </td>
38
  </tr>
1
  <?php if (in_array($source_type, array('url', 'ftp'))): ?>
2
  <tr>
3
+ <td colspan="3" style="padding-top:20px;">
4
  <fieldset class="optionsset">
5
+ <legend><?php _e('Scheduling','pmxi_plugin');?></legend>
6
  <div class="input">
7
  <input type="hidden" name="is_scheduled" value="0" />
8
+ <input type="checkbox" id="is_scheduled_<?php echo $entry; ?>" class="switcher fix_checkbox" name="is_scheduled" value="1" <?php echo $scheduled['is_scheduled'] ? 'checked="checked"': '' ?>/>
9
  <label for="is_scheduled_<?php echo $entry; ?>"><?php _e('Schedule import using WordPress Scheduling Logic', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Using this is not recommended. Unless you are importing a very small file, use cron jobs instead.', 'pmxi_plugin') ?>">?</a></label>
10
  <span class="switcher-target-is_scheduled_<?php echo $entry; ?>" style="vertical-align:middle">
11
  <select name="scheduled_period">
32
  <?php _e('<b>This import can be also be scheduled using cron jobs.</b> Save the import, visit the <i>Manage Imports</i> page, and click the <i>Cron Scheduling</i> link to set up cron scheduling. Using WordPress scheduling logic is not recommended for large files.','pmxi_plugin');?>
33
  </p>
34
 
35
+ </div>
36
  </fieldset>
37
  </td>
38
  </tr>
views/admin/import/options/_settings_template.php CHANGED
@@ -1,42 +1,50 @@
1
  <tr>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
- <legend><?php _e('Import Settings','pmxi_plugin');?></legend>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  <p>
6
  <div class="input">
7
- <label for="save_import_as"><?php _e('Friendly Name','pmxi_plugin');?></label> <input type="text" name="friendly_name" title="<?php _e('Save friendly name...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:11px; background:#fff !important;" value="<?php echo esc_attr($post['friendly_name']) ?>" />
 
 
8
  </div>
9
- </p>
10
- <?php if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']['large_file']) or (!empty($import) and $import->large_import == 'Yes')):?>
11
- <p>
12
- <div class="input">
13
- <label for="records_per_request"><?php _e('Records Per Iteration', 'pmxi_plugin');?></label> <input type="text" name="records_per_request" style="vertical-align:middle; font-size:11px; background:#fff !important; width: 40px;" value="<?php echo esc_attr($post['records_per_request']) ?>" />
14
- <a href="#help" class="help" title="<?php _e('Your feed was detected as a &quot;large&quot; file. The import process will be executed via AJAX requests. To make import process faster you can increase the number of records imported per iteration. Higher numbers put more strain on your server but make the import process take less time. 10 is a very safe number. To speed up the process, try 100 or more, especially if your import settings are simple and you are not downloading images.', 'pmxi_plugin') ?>">?</a>
15
- </div>
16
- </p>
17
- <!--p>
18
- <div class="input">
19
- <input type="hidden" name="create_chunks" value="0" />
20
- <input type="checkbox" id="create_chunks_<?php echo $entry; ?>" name="create_chunks" value="1" class="fix_checkbox" <?php echo $post['create_chunks'] ? 'checked="checked"': '' ?>/>
21
- <label for="create_chunks_<?php echo $entry; ?>"><?php _e('create chunks', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Check this to split up the file into pieces before import. Will speed up the import of large files.', 'pmxi_plugin') ?>">?</a></label>
22
- </div>
23
- </p-->
24
- <?php endif; ?>
25
- <div class="input">
26
- <input type="hidden" name="is_import_specified" value="0" />
27
- <input type="checkbox" id="is_import_specified_<?php echo $entry; ?>" class="switcher fix_checkbox" name="is_import_specified" value="1" <?php echo $post['is_import_specified'] ? 'checked="checked"': '' ?>/>
28
- <label for="is_import_specified_<?php echo $entry; ?>"><?php _e('Import only specified records', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Enter records or record ranges separated by commas, e.g. <b>1,5,7-10</b> would import the first, the fifth, and the seventh to tenth.', 'pmxi_plugin') ?>">?</a></label>
29
- <span class="switcher-target-is_import_specified_<?php echo $entry; ?>" style="vertical-align:middle">
30
- <div class="input" style="display:inline;">
31
- <input type="text" name="import_specified" value="<?php echo esc_attr($post['import_specified']) ?>" style="width:50%;"/>
32
- </div>
33
- </span>
34
- </div>
35
  <p>
36
  <div class="input">
37
- <input type="checkbox" id="save_template_as_<?php echo $entry; ?>" name="save_template_as" class="fix_checkbox" value="1" <?php echo ( ! empty($post['save_template_as'])) ? 'checked="checked"' : '' ?>/> <label for="save_template_as_<?php echo $entry; ?>"><?php _e('Save template as:','pmxi_plugin');?></label> &nbsp;<input type="text" name="name" title="<?php _e('Save Template As...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:13px;" value="<?php echo (!empty($post['name'])) ? esc_attr($post['name']) : ''; ?>" />
 
 
 
 
 
 
 
38
  </div>
39
- </p>
40
  <?php if (in_array($source_type, array('ftp', 'file'))): ?>
41
  <p>
42
  <div class="input">
@@ -54,7 +62,18 @@
54
  <label for="is_cloak_<?php echo $entry; ?>"><?php _e('Auto-Cloak Links', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php printf(__('Automatically process all links present in body of created post or page with <b>%s</b> plugin', 'pmxi_plugin'), PMLC_Plugin::getInstance()->getName()) ?>">?</a></label>
55
  </div>
56
  </p>
57
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
58
  </fieldset>
59
  </td>
60
  </tr>
1
  <tr>
2
  <td colspan="3" style="padding-top:20px;">
3
  <fieldset class="optionsset">
4
+ <legend><?php _e('Import Processing','pmxi_plugin');?></legend>
5
+ <p>
6
+ <div class="input">
7
+ <div class="input" style="margin-bottom:5px;">
8
+ <input type="radio" id="import_default_processing_<?php echo $entry; ?>" class="switcher" name="import_processing" value="default" <?php echo ('ajax' != $post['import_processing']) ? 'checked="checked"': '' ?>/>
9
+ <label for="import_default_processing_<?php echo $entry; ?>"><?php _e('High Speed Small File Processing', 'pmxi_plugin' )?> <a href="#help" class="help" title="<?php printf( __('Your server\'s max_execution_time setting is %s seconds. If the import takes longer than this, it will fail.', 'pmxi_plugin'), ini_get('max_execution_time'));?>">?</a></label>
10
+ </div>
11
+
12
+ <input type="radio" id="import_ajax_processing_<?php echo $entry; ?>" class="switcher" name="import_processing" value="ajax" <?php echo 'ajax' == $post['import_processing'] ? 'checked="checked"': '' ?>/>
13
+ <label for="import_ajax_processing_<?php echo $entry; ?>"><?php _e('Iterative, Piece-by-Piece Processing', 'pmxi_plugin' )?></label>
14
+
15
+ <span class="switcher-target-import_ajax_processing_<?php echo $entry; ?> pl17">
16
+ <div class="input pl17" style="margin:5px 0px;">
17
+ <label for="records_per_request"><?php _e('In each iteration, process', 'pmxi_plugin');?></label> <input type="text" name="records_per_request" style="vertical-align:middle; font-size:11px; background:#fff !important; width: 40px; text-align:center;" value="<?php echo esc_attr($post['records_per_request']) ?>" /> <?php _e('records', 'pmxi_plugin'); ?>
18
+ <a href="#help" class="help" title="<?php printf(__('WP All Import must be able to process this many records in less than your server\'s max_execution_time, which is %s seconds. If your import fails before finishing (you will see \'Import XML - Error\' in the progress bar), to troubleshoot you should lower this number. If you are importing images, especially high resolution images, high numbers here are probably a bad idea, since downloading the images can take lots of time. 20 posts with 5 images each = 100 images, at 500Kb per image that\'s 50Mb. Can your server download that in less than your max_execution_time? Maybe, maybe not.', 'pmxi_plugin'), ini_get('max_execution_time')); ?>">?</a>
19
+ </div>
20
+ <div class="input pl17" style="margin:5px 0px;">
21
+ <input type="hidden" name="chuncking" value="0" />
22
+ <input type="checkbox" id="chuncking_<?php echo $entry; ?>" name="chuncking" value="1" class="fix_checkbox" <?php echo $post['chuncking'] ? 'checked="checked"': '' ?>/>
23
+ <label for="chuncking_<?php echo $entry; ?>"><?php _e('Split file up into <strong>' . PMXI_Plugin::getInstance()->getOption('large_feed_limit') . '</strong> record chunks.', 'pmxi_plugin');?></label>
24
+ <a href="#help" class="help" title="<?php _e('This option will decrease the amount of slowdown experienced at the end of large imports. The slowdown is partially caused by the need for WP All Import to read deeper and deeper into the file on each successive iteration. Splitting the file into pieces means that, for example, instead of having to read 19000 records into a 20000 record file when importing the last 1000 records, WP All Import will just split it into 20 chunks, and then read the last chunk from the beginning.','pmxi_plugin'); ?>">?</a>
25
+ </div>
26
+ </span>
27
+ </div>
28
+ </p>
29
  <p>
30
  <div class="input">
31
+ <input type="hidden" name="is_fast_mode" value="0" />
32
+ <input type="checkbox" id="is_fast_mode_<?php echo $entry; ?>" name="is_fast_mode" value="1" class="fix_checkbox" <?php echo $post['is_fast_mode'] ? 'checked="checked"': '' ?>/>
33
+ <label for="is_fast_mode_<?php echo $entry; ?>"><?php _e('Increase speed by disabling do_action calls in wp_insert_post during import.', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('This option is for advanced users with knowledge of WordPress development. Your theme or plugins may require these calls when posts are created. Verify your created posts work properly if you check this box.', 'pmxi_plugin') ?>">?</a></label>
34
  </div>
35
+ </p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  <p>
37
  <div class="input">
38
+ <input type="hidden" name="is_import_specified" value="0" />
39
+ <input type="checkbox" id="is_import_specified_<?php echo $entry; ?>" class="switcher fix_checkbox" name="is_import_specified" value="1" <?php echo $post['is_import_specified'] ? 'checked="checked"': '' ?>/>
40
+ <label for="is_import_specified_<?php echo $entry; ?>"><?php _e('Import only specified records', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php _e('Enter records or record ranges separated by commas, e.g. <b>1,5,7-10</b> would import the first, the fifth, and the seventh to tenth.', 'pmxi_plugin') ?>">?</a></label>
41
+ <span class="switcher-target-is_import_specified_<?php echo $entry; ?>" style="vertical-align:middle">
42
+ <div class="input" style="display:inline;">
43
+ <input type="text" name="import_specified" value="<?php echo esc_attr($post['import_specified']) ?>" style="width:50%;"/>
44
+ </div>
45
+ </span>
46
  </div>
47
+ </p>
48
  <?php if (in_array($source_type, array('ftp', 'file'))): ?>
49
  <p>
50
  <div class="input">
62
  <label for="is_cloak_<?php echo $entry; ?>"><?php _e('Auto-Cloak Links', 'pmxi_plugin') ?> <a href="#help" class="help" title="<?php printf(__('Automatically process all links present in body of created post or page with <b>%s</b> plugin', 'pmxi_plugin'), PMLC_Plugin::getInstance()->getName()) ?>">?</a></label>
63
  </div>
64
  </p>
65
+ <?php endif; ?>
66
+ <hr>
67
+ <p>
68
+ <div class="input pl17">
69
+ <label for="save_import_as" style="margin-right:17px; width: 103px;"><?php _e('Friendly Name:','pmxi_plugin');?></label> <input type="text" name="friendly_name" title="<?php _e('Save friendly name...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:11px; background:#fff !important;" value="<?php echo esc_attr($post['friendly_name']) ?>" />
70
+ </div>
71
+ </p>
72
+ <p>
73
+ <div class="input">
74
+ <input type="checkbox" id="save_template_as_<?php echo $entry; ?>" name="save_template_as" class="fix_checkbox" value="1" <?php echo ( ! empty($post['save_template_as'])) ? 'checked="checked"' : '' ?>/> <label for="save_template_as_<?php echo $entry; ?>"><?php _e('Save template as:','pmxi_plugin');?></label> &nbsp;<input type="text" name="name" title="<?php _e('Save Template As...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:11px;" value="<?php echo (!empty($post['name'])) ? esc_attr($post['name']) : ''; ?>" />
75
+ </div>
76
+ </p>
77
  </fieldset>
78
  </td>
79
  </tr>
views/admin/import/options/_taxonomies_template.php CHANGED
@@ -8,7 +8,7 @@
8
  <td colspan="3" style="padding-bottom:20px;">
9
  <fieldset class="optionsset">
10
  <legend><?php _e('Custom Taxonomies','pmxi_plugin');?></legend>
11
- <?php foreach ($post_taxonomies as $ctx): if ("" == $ctx->labels->name) continue;?>
12
  <table style="width:100%;">
13
  <tr>
14
  <td>
8
  <td colspan="3" style="padding-bottom:20px;">
9
  <fieldset class="optionsset">
10
  <legend><?php _e('Custom Taxonomies','pmxi_plugin');?></legend>
11
+ <?php foreach ($post_taxonomies as $ctx): if ("" == $ctx->labels->name or (class_exists('PMWI_Plugin') and strpos($ctx->name, "pa_") === 0 and $post_type == "product")) continue;?>
12
  <table style="width:100%;">
13
  <tr>
14
  <td>
views/admin/import/preview.php CHANGED
@@ -1,8 +1,17 @@
1
  <div id="post-preview">
 
 
 
 
 
 
 
 
 
2
  <?php if ($this->errors->get_error_codes()): ?>
3
  <?php $this->error() ?>
4
  <?php endif ?>
5
-
6
  <?php if (isset($title)): ?>
7
  <h2 class="title"><?php echo $title ?></h2>
8
  <?php endif ?>
1
  <div id="post-preview">
2
+
3
+ <div class="title">
4
+ <?php printf(__('Record #<strong><input type="text" value="%s" name="tagno" class="tagno"/></strong> out of <strong class="pmxi_count">%s</strong>', 'pmxi_plugin'), $tagno, PMXI_Plugin::$session->data['pmxi_import']['count']); ?>
5
+ <div class="navigation" style="float:right; margin-left:10px; margin-top:2px; font-size:16px;">
6
+ <?php if ($tagno > 1): ?><a href="#prev">&laquo;</a><?php else: ?><span>&laquo;</span><?php endif ?>
7
+ <?php if ($tagno < PMXI_Plugin::$session->data['pmxi_import']['count']): ?><a href="#next">&raquo;</a><?php else: ?><span>&raquo;</span><?php endif ?>
8
+ </div>
9
+ </div>
10
+
11
  <?php if ($this->errors->get_error_codes()): ?>
12
  <?php $this->error() ?>
13
  <?php endif ?>
14
+
15
  <?php if (isset($title)): ?>
16
  <h2 class="title"><?php echo $title ?></h2>
17
  <?php endif ?>
views/admin/import/process.php CHANGED
@@ -2,12 +2,17 @@
2
  <h2><?php _e('Import XML - <span id="status">Processing...</span>', 'pmxi_plugin') ?></h2>
3
  <hr />
4
  <p id="process_notice"><?php _e('Importing may take some time. Please do not close your browser or refresh the page until the process is complete.', 'pmxi_plugin') ?></p>
5
- <?php _e('<div id="processbar"><div></div><span id="import_progress"><span id="left_progress">Time Elapsed <span id="then">00:00:00</span></span><span id="center_progress"> Created 0 / Updated 0 </span><span id="right_progress">0%</span></span></div>', 'pmxi_plugin'); ?>
 
 
 
 
 
6
  <div id="logbar">
7
- <a href="javascript:void(0);" id="view_log"><?php _e('View Log','pmxi_plugin');?></a><span id="download_log_separator"> | </span> <a href="javascript:void(0);" id="download_log"><?php _e('Download Log','pmxi_plugin');?></a>
8
  <p><?php _e('Warnings','pmxi_plugin');?> (<span id="warnings">0</span>), <?php _e('Errors','pmxi_plugin');?> (<span id="errors">0</span>)</p>
9
  </div>
10
- <fieldset id="logwrapper" <?php if (PMXI_Plugin::$session->data['pmxi_import']['large_file']): ?> style="display:none;" <?php endif; ?>>
11
  <legend><?php _e('Log','pmxi_plugin');?></legend>
12
  <div id="loglist">
13
 
@@ -19,6 +24,9 @@
19
  <script type="text/javascript">
20
  //<![CDATA[
21
  (function($){
 
 
 
22
  $('#status').each(function () {
23
 
24
  var then = $('#then');
@@ -27,7 +35,7 @@
27
  var duration = moment.duration({'seconds' : 1});
28
  start_date.add(duration);
29
 
30
- if ( ! $('#download_pmxi_log').length) then.html(start_date.format('HH:mm:ss'));
31
  };
32
  update();
33
  setInterval(update, 1000);
@@ -36,53 +44,53 @@
36
  if ($this.html().match(/\.{3}$/)) {
37
  var dots = 0;
38
  var status = $this.html().replace(/\.{3}$/, '');
39
- var interval ;
40
- var odd = false;
41
- interval = setInterval(function () {
42
- var percents = $('.import_percent:last').html();
43
- if ($this.html().match(new RegExp(status + '\\.{1,3}$', ''))) {
44
- if (percents != null && percents != ''){
45
- $this.html(status + '...'.substr(0, dots++ % 3 + 1));
46
- var msg = $('.import_process_bar:last').html();
47
- if (msg != undefined) $('#center_progress').html(msg);
48
- $('#warnings').html($('.warnings_count:last').html());
49
- $('#errors').html($('.errors_count:last').html());
50
- $('#right_progress').html(((parseInt(percents) > 100 || percents == undefined) ? 100 : percents) + '%');
51
- $('#processbar div').css({'width': ((parseInt(percents) > 100 || percents == undefined) ? 100 : percents) + '%'});
52
- }
53
- } else {
54
- var msg = $('.import_process_bar:last').html();
55
- if (msg != undefined) $('#center_progress').html(msg);
56
- $('#right_progress').html(((parseInt(percents) > 100 || percents == undefined) ? 100 : percents) + '%');
57
- $('#warnings').html($('.warnings_count:last').html());
58
- $('#errors').html($('.errors_count:last').html());
59
- $('#processbar div').css({'width': ((parseInt(percents) > 100 || percents == undefined) ? 100 : percents) + '%'});
60
- $('#process_notice').hide();
61
- $('#import_finished').show();
62
  clearInterval(update);
63
  clearInterval(interval);
64
- }
65
- if ($('#download_pmxi_log').length){
66
- $('#download_log').attr('href', $('#download_pmxi_log').attr('href')).show();
67
- $('#download_log_separator').show();
68
- }
69
  // fill log bar
70
- $('.progress-msg').each(function(i){
71
- if ( ! $(this).find('.import_process_bar').length){
72
- <?php if (PMXI_Plugin::$session->data['pmxi_import']['large_file']): ?>
73
- if ($('#loglist').find('p').length > 100) $('#loglist').html('');
74
- <?php endif; ?>
75
- $('#loglist').append('<p ' + ((odd) ? 'class="odd"' : 'class="even"') + '>' + $(this).html() + '</p>');
76
- $('#loglist').animate({ scrollTop: $('#loglist').get(0).scrollHeight }, 0);
77
- $(this).remove();
78
- odd = !odd;
79
- }
80
- });
81
 
82
  }, 1000);
83
  $('#processbar').css({'visibility':'visible'});
84
  }
85
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  window.onbeforeunload = function () {
87
  return 'WARNING:\nImport process in under way, leaving the page will interrupt\nthe operation and most likely to cause leftovers in posts.';
88
  };
@@ -91,22 +99,54 @@
91
  //]]>
92
  </script>
93
 
94
- <?php if (PMXI_Plugin::$session->data['pmxi_import']['large_file']): ?>
95
-
96
- <script type="text/javascript">
97
- //<![CDATA[
98
- (function($){
99
- function parse_element(){
100
- $.post('admin.php?page=pmxi-admin-import&action=process', {}, function (data) {
101
- $('#loglist').append(data);
102
- if ( ! $('#download_pmxi_log').length) parse_element();
103
- }, 'html').fail(function() {
104
- if ( ! $('#download_pmxi_log').length) parse_element();
105
- });
106
- }
107
- parse_element();
108
- })(jQuery);
109
- //]]>
110
- </script>
 
 
111
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
  <?php endif; ?>
2
  <h2><?php _e('Import XML - <span id="status">Processing...</span>', 'pmxi_plugin') ?></h2>
3
  <hr />
4
  <p id="process_notice"><?php _e('Importing may take some time. Please do not close your browser or refresh the page until the process is complete.', 'pmxi_plugin') ?></p>
5
+ <div id="processbar">
6
+ <div></div>
7
+ <span id="import_progress">
8
+ <span id="left_progress"><?php _e('Time Elapsed', 'pmxi_plugin');?> <span id="then">00:00:00</span></span><span id="center_progress"> <?php _e('Created','pmxi_plugin');?> <span id="created_count"><?php echo $update_previous->created; ?></span> / <?php _e('Updated','pmxi_plugin');?> <span id="updated_count"><?php echo $update_previous->updated; ?></span> <?php _e('of', 'pmxi_plugin');?> <span id="of"><?php echo $update_previous->count; ?></span> <?php _e('records', 'pmxi_plugin'); ?> </span><span id="right_progress"><span id="percents_count">0</span>%</span>
9
+ </span>
10
+ </div>
11
  <div id="logbar">
12
+ <a href="javascript:void(0);" id="view_log"><?php _e('View Log','pmxi_plugin');?></a><span id="download_log_separator"> | </span> <a href="<?php echo add_query_arg(array('id' => $update_previous->id, 'action' => 'log', 'page' => 'pmxi-admin-manage'), $this->baseUrl); ?>" id="download_log"><?php _e('Download Log','pmxi_plugin');?></a>
13
  <p><?php _e('Warnings','pmxi_plugin');?> (<span id="warnings">0</span>), <?php _e('Errors','pmxi_plugin');?> (<span id="errors">0</span>)</p>
14
  </div>
15
+ <fieldset id="logwrapper" <?php if ( "default" == $update_previous->options['import_processing'] ): ?>style="display:block;"<?php else: ?>style="display:none;"<?php endif; ?>>
16
  <legend><?php _e('Log','pmxi_plugin');?></legend>
17
  <div id="loglist">
18
 
24
  <script type="text/javascript">
25
  //<![CDATA[
26
  (function($){
27
+
28
+ var odd = false;
29
+
30
  $('#status').each(function () {
31
 
32
  var then = $('#then');
35
  var duration = moment.duration({'seconds' : 1});
36
  start_date.add(duration);
37
 
38
+ if ( ! $('#download_log').is(':visible')) then.html(start_date.format('HH:mm:ss'));
39
  };
40
  update();
41
  setInterval(update, 1000);
44
  if ($this.html().match(/\.{3}$/)) {
45
  var dots = 0;
46
  var status = $this.html().replace(/\.{3}$/, '');
47
+ var interval ;
48
+ interval = setInterval(function () {
49
+ if ($this.html().match(new RegExp(status + '\\.{1,3}$', ''))) {
50
+ $this.html(status + '...'.substr(0, dots++ % 3 + 1));
51
+ } else {
52
+ $('#download_log').show();
53
+ $('#download_log_separator').show();
54
+ $('#process_notice').hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  clearInterval(update);
56
  clearInterval(interval);
57
+ }
 
 
 
 
58
  // fill log bar
59
+
60
+ write_log();
61
+
62
+ var percents = $('#percents_count').html();
63
+ $('#processbar div').css({'width': ((parseInt(percents) > 100 || percents == undefined) ? 100 : percents) + '%'});
64
+
 
 
 
 
 
65
 
66
  }, 1000);
67
  $('#processbar').css({'visibility':'visible'});
68
  }
69
  });
70
+
71
+ function write_log(){
72
+
73
+ $('.progress-msg').each(function(i){
74
+
75
+ if ($('#loglist').find('p').length > 100) $('#loglist').html('');
76
+
77
+ <?php if ( "default" == $update_previous->options['import_processing'] ): ?>
78
+ if ($(this).find('.processing_info').length) {
79
+ $('#created_count').html($(this).find('.created_count').html());
80
+ $('#updated_count').html($(this).find('.updated_count').html());
81
+ $('#percents_count').html($(this).find('.percents_count').html());
82
+ }
83
+ <?php endif; ?>
84
+
85
+ if ( ! $(this).find('.processing_info').length ){
86
+ $('#loglist').append('<p ' + ((odd) ? 'class="odd"' : 'class="even"') + '>' + $(this).html() + '</p>');
87
+ odd = !odd;
88
+ }
89
+ $('#loglist').animate({ scrollTop: $('#loglist').get(0).scrollHeight }, 0);
90
+ $(this).remove();
91
+ });
92
+ }
93
+
94
  window.onbeforeunload = function () {
95
  return 'WARNING:\nImport process in under way, leaving the page will interrupt\nthe operation and most likely to cause leftovers in posts.';
96
  };
99
  //]]>
100
  </script>
101
 
102
+ <?php if ( "ajax" == $update_previous->options['import_processing'] ): ?>
103
+ <script type="text/javascript">
104
+ //<![CDATA[
105
+ (function($){
106
+ function parse_element(){
107
+ $.post('admin.php?page=pmxi-admin-import&action=process', {}, function (data) {
108
+
109
+ // responce with error
110
+ if (data === null){
111
+ $('#process_notice').hide();
112
+ $('#import_finished').show();
113
+ $('#download_log').show();
114
+ $('#download_log_separator').show();
115
+ $('#status').html('Error');
116
+ window.onbeforeunload = false;
117
+ return;
118
+ }
119
+
120
+ $('#loglist').append(data.log);
121
 
122
+ $('#created_count').html(data.created);
123
+ $('#updated_count').html(data.updated);
124
+ $('#warnings').html(data.warnings);
125
+ $('#errors').html(data.errors);
126
+ $('#percents_count').html(data.percentage);
127
+ $('#processbar div').css({'width': data.percentage + '%'});
128
+
129
+ if ( data.done ){
130
+ $('#process_notice').hide();
131
+ $('#download_log').attr('href', data.log_link).show();
132
+ $('#download_log_separator').show();
133
+ }
134
+ else parse_element();
135
+
136
+ }, 'json').fail(function() {
137
+
138
+ $('#process_notice').hide();
139
+ $('#download_log').show();
140
+ $('#download_log_separator').show();
141
+ $('#status').html('Error');
142
+ window.onbeforeunload = false;
143
+
144
+ });
145
+ }
146
+
147
+ parse_element();
148
+
149
+ })(jQuery);
150
+ //]]>
151
+ </script>
152
  <?php endif; ?>
views/admin/import/tag.php CHANGED
@@ -23,16 +23,16 @@
23
  </div>
24
  </div>
25
  <?php if (!empty($elements->length)):?>
26
- <input type="hidden" name="tagno" value="<?php echo $tagno ?>" />
27
  <div class="title">
28
- <?php printf(__('Record #<strong>%s</strong> out of <strong>%s</strong>', 'pmxi_plugin'), $tagno, ( ! PMXI_Plugin::$session->data['pmxi_import']['large_file']) ? $elements->length : PMXI_Plugin::$session->data['pmxi_import']['count']); ?>
29
  <div class="navigation">
30
- <?php if ($tagno > 1): ?><a href="#prev">&lang;&lang;</a><?php else: ?><span>&lang;&lang;</span><?php endif ?>
31
- <?php if ($tagno < $elements->length or (PMXI_Plugin::$session->data['pmxi_import']['large_file'] and $tagno < PMXI_Plugin::$session->data['pmxi_import']['count'])): ?><a href="#next">&rang;&rang;</a><?php else: ?><span>&rang;&rang;</span><?php endif ?>
32
  </div>
33
  </div>
34
  <div class="clear"></div>
35
- <div class="xml resetable"> <?php if (!empty($elements->length)) $this->render_xml_element(( ! PMXI_Plugin::$session->data['pmxi_import']['large_file']) ? $elements->item($tagno - 1) : $elements->item(0), true); ?></div>
36
  <p class="xpath_help">
37
  <?php _e('Operate on elements using your own PHP functions, use FOREACH loops, and more.<br />Read the <a href="http://www.wpallimport.com/portal/" target="_blank">documentation</a> to learn how.', 'pmxi_plugin') ?>
38
  </p>
23
  </div>
24
  </div>
25
  <?php if (!empty($elements->length)):?>
26
+ <!--input type="hidden" name="tagno" value="<?php echo $tagno ?>" /-->
27
  <div class="title">
28
+ <?php printf(__('Record #<strong><input type="text" value="%s" name="tagno" class="tagno"/></strong> out of <strong class="pmxi_count">%s</strong>', 'pmxi_plugin'), $tagno, PMXI_Plugin::$session->data['pmxi_import']['count']); ?>
29
  <div class="navigation">
30
+ <?php if ($tagno > 1): ?><a href="#prev">&laquo;</a><?php else: ?><span>&laquo;</span><?php endif ?>
31
+ <?php if ($tagno < PMXI_Plugin::$session->data['pmxi_import']['count']): ?><a href="#next">&raquo;</a><?php else: ?><span>&raquo;</span><?php endif ?>
32
  </div>
33
  </div>
34
  <div class="clear"></div>
35
+ <div class="xml resetable"> <?php if (!empty($elements->length)) $this->render_xml_element($elements->item( 0 ), true); ?></div>
36
  <p class="xpath_help">
37
  <?php _e('Operate on elements using your own PHP functions, use FOREACH loops, and more.<br />Read the <a href="http://www.wpallimport.com/portal/" target="_blank">documentation</a> to learn how.', 'pmxi_plugin') ?>
38
  </p>
views/admin/import/template.php CHANGED
@@ -13,6 +13,8 @@
13
 
14
  <h3><?php _e('Drag-and-drop an element from the right to the left to build your template','pmxi_plugin');?></h3>
15
 
 
 
16
  <table class="layout">
17
  <tr>
18
  <td class="left">
@@ -30,7 +32,7 @@
30
  <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
31
 
32
  <?php wp_editor($post['content'], 'content', array(
33
- 'dfw' => true,
34
  'editor_height' => 360));
35
  ?>
36
  <table id="post-status-info" cellspacing="0">
@@ -49,7 +51,7 @@
49
  <p style="margin-bottom:0px;">
50
  <span class="header-option">
51
  <input type="hidden" name="is_keep_linebreaks" value="0" />
52
- <input type="checkbox" id="is_keep_linebreaks" name="is_keep_linebreaks" value="1" <?php echo $post['is_keep_linebreaks'] ? 'checked="checked"' : '' ?> />
53
  <label for="is_keep_linebreaks"><?php _e('Keep line breaks from XML', 'pmxi_plugin') ?></label>
54
  </span>
55
  </p>
@@ -58,7 +60,7 @@
58
  <p style="margin-bottom:0px; margin-top:2px;">
59
  <span class="header-option">
60
  <input type="hidden" name="is_leave_html" value="0" />
61
- <input type="checkbox" id="is_leave_html" name="is_leave_html" value="1" <?php echo $post['is_leave_html'] ? 'checked="checked"' : '' ?> style="position:relative;"/>
62
  <label for="is_leave_html"><?php _e('Decode HTML entities with <b>html_entity_decode</b>', 'pmxi_plugin') ?></label>
63
  <a class="help" href="#help" original-title="If HTML code is showing up in your posts, use this option. You can also use <br /><br /><i>[html_entity_decode({my/xpath})]</i><br /><br /> or <br /><br /><i>[htmlentities({my/xpath})]</i><br /><br /> to decode or encode HTML in your file.">?</a>
64
  </span>
@@ -70,7 +72,7 @@
70
 
71
  <div class="input">
72
  <p style="margin-top:0px;">
73
- <input type="checkbox" id="save_template_as" name="save_template_as" value="1" <?php echo ( ! empty($post['save_template_as'])) ? 'checked="checked"' : '' ?> />
74
  <label for="save_template_as"><?php _e('Save template as:','pmxi_plugin');?></label> &nbsp;
75
  <input type="text" name="name" title="<?php _e('Save Template As...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:13px;" value="<?php echo esc_attr($post['name']) ?>" />
76
  </p>
13
 
14
  <h3><?php _e('Drag-and-drop an element from the right to the left to build your template','pmxi_plugin');?></h3>
15
 
16
+ <?php do_action('pmxi_template_header', $this->isWizard, $post); ?>
17
+
18
  <table class="layout">
19
  <tr>
20
  <td class="left">
32
  <div id="<?php echo user_can_richedit() ? 'postdivrich' : 'postdiv'; ?>" class="postarea">
33
 
34
  <?php wp_editor($post['content'], 'content', array(
35
+ 'teeny' => true,
36
  'editor_height' => 360));
37
  ?>
38
  <table id="post-status-info" cellspacing="0">
51
  <p style="margin-bottom:0px;">
52
  <span class="header-option">
53
  <input type="hidden" name="is_keep_linebreaks" value="0" />
54
+ <input type="checkbox" id="is_keep_linebreaks" name="is_keep_linebreaks" class="fix_checkbox" value="1" <?php echo $post['is_keep_linebreaks'] ? 'checked="checked"' : '' ?> />
55
  <label for="is_keep_linebreaks"><?php _e('Keep line breaks from XML', 'pmxi_plugin') ?></label>
56
  </span>
57
  </p>
60
  <p style="margin-bottom:0px; margin-top:2px;">
61
  <span class="header-option">
62
  <input type="hidden" name="is_leave_html" value="0" />
63
+ <input type="checkbox" id="is_leave_html" name="is_leave_html" class="fix_checkbox" value="1" <?php echo $post['is_leave_html'] ? 'checked="checked"' : '' ?> style="position:relative;"/>
64
  <label for="is_leave_html"><?php _e('Decode HTML entities with <b>html_entity_decode</b>', 'pmxi_plugin') ?></label>
65
  <a class="help" href="#help" original-title="If HTML code is showing up in your posts, use this option. You can also use <br /><br /><i>[html_entity_decode({my/xpath})]</i><br /><br /> or <br /><br /><i>[htmlentities({my/xpath})]</i><br /><br /> to decode or encode HTML in your file.">?</a>
66
  </span>
72
 
73
  <div class="input">
74
  <p style="margin-top:0px;">
75
+ <input type="checkbox" id="save_template_as" name="save_template_as" class="fix_checkbox" value="1" <?php echo ( ! empty($post['save_template_as'])) ? 'checked="checked"' : '' ?> />
76
  <label for="save_template_as"><?php _e('Save template as:','pmxi_plugin');?></label> &nbsp;
77
  <input type="text" name="name" title="<?php _e('Save Template As...', 'pmxi_plugin') ?>" style="vertical-align:middle; font-size:13px;" value="<?php echo esc_attr($post['name']) ?>" />
78
  </p>
views/admin/manage/index.php CHANGED
@@ -39,9 +39,12 @@ $columns = array(
39
  'post_count' => __('Records', 'pmxi_plugin'),
40
  'first_import' => __('First Import', 'pmxi_plugin'),
41
  'registered_on' => __('Last Import', 'pmxi_plugin'),
42
- /*'scheduled' => __('Reimport Schedule', 'pmxi_plugin'),
43
  'next_import' => __('Next Import', 'pmxi_plugin'),*/
44
  );
 
 
 
45
  ?>
46
  <form method="post" id="import-list" action="<?php echo remove_query_arg('pmxi_nt') ?>">
47
  <input type="hidden" name="action" value="bulk" />
@@ -106,7 +109,21 @@ $columns = array(
106
  <td colspan="<?php echo count($columns) + 1 ?>"><?php _e('No previous imports found.', 'pmxi_plugin') ?></td>
107
  </tr>
108
  <?php else: ?>
109
- <?php $class = ''; foreach ($list as $item): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  <?php $class = ('alternate' == $class) ? '' : 'alternate'; ?>
111
  <tr class="<?php echo $class; ?>" valign="middle">
112
  <th scope="row" class="check-column">
@@ -122,6 +139,13 @@ $columns = array(
122
  </th>
123
  <?php
124
  break;
 
 
 
 
 
 
 
125
  case 'first_import':
126
  ?>
127
  <td>
@@ -162,19 +186,26 @@ $columns = array(
162
  case 'name':
163
  ?>
164
  <td>
165
- <strong><?php echo (!empty($item['friendly_name'])) ? $item['friendly_name'] : $item['name']; ?></strong> <br>
166
  <?php if ($item['path']): ?>
167
  <em><?php echo str_replace("\\", '/', preg_replace('%^(\w+://[^:]+:)[^@]+@%', '$1*****@', $item['path'])); ?></em>
168
  <?php endif ?>
169
  <div class="row-actions">
170
 
 
 
171
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'edit'), $this->baseUrl)) ?>"><?php _e('Edit Template', 'pmxi_plugin') ?></a></span> |
172
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"><?php _e('Edit Options', 'pmxi_plugin') ?></a></span> |
173
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl)) ?>"><?php _e('Re-Run Import', 'pmxi_plugin') ?></a></span> |
 
 
 
 
 
174
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['id']), admin_url('admin.php'))) ?>"><?php _e('Re-Run With New File', 'pmxi_plugin') ?></a></span> |
175
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'log'), $this->baseUrl)) ?>"><?php _e('Download Log', 'pmxi_plugin') ?></a></span> |
176
  <span class="delete"><a class="delete" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'delete'), $this->baseUrl)) ?>"><?php _e('Delete', 'pmxi_plugin') ?></a></span>
177
- <?php if ( "Yes" == $item['large_import'] and (($item['imported'] + $item['skipped']) != $item['count'] and ! $item['options']['is_import_specified']) ):?>
178
  | <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update', 'type' => 'continue'), $this->baseUrl)) ?>"><?php _e('Continue import', 'pmxi_plugin') ?></a></span>
179
  <?php endif; ?>
180
  </div>
@@ -198,7 +229,7 @@ $columns = array(
198
  default:
199
  ?>
200
  <td>
201
- <?php echo $item[$column_id] ?>
202
  </td>
203
  <?php
204
  break;
@@ -206,6 +237,7 @@ $columns = array(
206
  ?>
207
  <?php endforeach; ?>
208
  </tr>
 
209
  <?php endforeach; ?>
210
  <?php endif ?>
211
  </tbody>
@@ -217,7 +249,7 @@ $columns = array(
217
  <div class="alignleft actions">
218
  <select name="bulk-action2">
219
  <option value="" selected="selected"><?php _e('Bulk Actions', 'pmxi_plugin') ?></option>
220
- <?php if ('trash' != $type): ?>
221
  <option value="delete"><?php _e('Delete', 'pmxi_plugin') ?></option>
222
  <?php else: ?>
223
  <option value="restore"><?php _e('Restore', 'pmxi_plugin')?></option>
@@ -242,5 +274,5 @@ $columns = array(
242
  ?>
243
 
244
  <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=manage&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Find out more about the professional edition of WP All Import.</a></p>
245
-
246
  </form>
39
  'post_count' => __('Records', 'pmxi_plugin'),
40
  'first_import' => __('First Import', 'pmxi_plugin'),
41
  'registered_on' => __('Last Import', 'pmxi_plugin'),
42
+ /*'scheduled' => __('Reimport Schedule', 'pmxi_plugin'),
43
  'next_import' => __('Next Import', 'pmxi_plugin'),*/
44
  );
45
+
46
+ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
47
+
48
  ?>
49
  <form method="post" id="import-list" action="<?php echo remove_query_arg('pmxi_nt') ?>">
50
  <input type="hidden" name="action" value="bulk" />
109
  <td colspan="<?php echo count($columns) + 1 ?>"><?php _e('No previous imports found.', 'pmxi_plugin') ?></td>
110
  </tr>
111
  <?php else: ?>
112
+ <?php
113
+ $periods = array( // scheduling periods
114
+ '*/5 * * * *' => __('every 5 min'),
115
+ '*/10 * * * *' => __('every 10 min'),
116
+ '*/30 * * * *' => __('half-hourly'),
117
+ '0 * * * *' => __('hourly'),
118
+ '0 */4 * * *' => __('every 4 hours'),
119
+ '0 */12 * * *' => __('half-daily'),
120
+ '0 0 * * *' => __('daily'),
121
+ '0 0 * * 1' => __('weekly'),
122
+ '0 0 1 * 1' => __('monthly'),
123
+ );
124
+ $class = '';
125
+ ?>
126
+ <?php foreach ($list as $item): ?>
127
  <?php $class = ('alternate' == $class) ? '' : 'alternate'; ?>
128
  <tr class="<?php echo $class; ?>" valign="middle">
129
  <th scope="row" class="check-column">
139
  </th>
140
  <?php
141
  break;
142
+ case 'scheduled':
143
+ ?>
144
+ <td>
145
+ <?php echo $item['scheduled'] ? $periods[$item['scheduled']] : '' ?>
146
+ </td>
147
+ <?php
148
+ break;
149
  case 'first_import':
150
  ?>
151
  <td>
186
  case 'name':
187
  ?>
188
  <td>
189
+ <strong><?php echo apply_filters("pmxi_import_name", (!empty($item['friendly_name'])) ? $item['friendly_name'] : $item['name'], $item['id']); ?></strong> <?php if ( (int) $item['triggered']) _e("<i> -> Import triggered...</i>"); if ( (int) $item['processing']) _e("<i> -> Import currently in progress....</i>"); ?><br>
190
  <?php if ($item['path']): ?>
191
  <em><?php echo str_replace("\\", '/', preg_replace('%^(\w+://[^:]+:)[^@]+@%', '$1*****@', $item['path'])); ?></em>
192
  <?php endif ?>
193
  <div class="row-actions">
194
 
195
+ <?php do_action('pmxi_import_menu', $item['id'], $this->baseUrl); ?>
196
+
197
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'edit'), $this->baseUrl)) ?>"><?php _e('Edit Template', 'pmxi_plugin') ?></a></span> |
198
  <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'options'), $this->baseUrl)) ?>"><?php _e('Edit Options', 'pmxi_plugin') ?></a></span> |
199
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update'), $this->baseUrl)) ?>"><?php _e('Re-Run Import', 'pmxi_plugin') ?></a></span> |
200
+
201
+ <?php if ( in_array($item['type'], array('url', 'ftp', 'file'))): ?>
202
+ <!--span class="edit get_cron_url"><a class="edit" href="javascript:void(0);" rel='<?php echo "wget -q -O /dev/null \"".home_url()."?import_key=".PMXI_Plugin::getInstance()->getOption('cron_job_key')."&import_id=".$item['id']."&action=processing\"\n" . "wget -q -O /dev/null "."\"".home_url()."?import_key=".PMXI_Plugin::getInstance()->getOption('cron_job_key')."&import_id=".$item['id']."&action=trigger"."\"";?>'><?php _e('Get Cron URL', 'pmxi_plugin') ?></a></span> |-->
203
+ <span class="edit"><a class="edit" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'scheduling'), $this->baseUrl)) ?>"><?php _e('Cron Scheduling', 'pmxi_plugin') ?></a></span> |
204
+ <?php endif; ?>
205
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('page' => 'pmxi-admin-import', 'id' => $item['id']), admin_url('admin.php'))) ?>"><?php _e('Re-Run With New File', 'pmxi_plugin') ?></a></span> |
206
  <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'log'), $this->baseUrl)) ?>"><?php _e('Download Log', 'pmxi_plugin') ?></a></span> |
207
  <span class="delete"><a class="delete" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'delete'), $this->baseUrl)) ?>"><?php _e('Delete', 'pmxi_plugin') ?></a></span>
208
+ <?php if ( ($item['imported'] + $item['skipped']) < $item['count'] and ! $item['options']['is_import_specified'] and ! (int) $item['triggered'] ):?>
209
  | <span class="update"><a class="update" href="<?php echo esc_url(add_query_arg(array('id' => $item['id'], 'action' => 'update', 'type' => 'continue'), $this->baseUrl)) ?>"><?php _e('Continue import', 'pmxi_plugin') ?></a></span>
210
  <?php endif; ?>
211
  </div>
229
  default:
230
  ?>
231
  <td>
232
+ <?php do_action('pmxi_manage_imports_column', $column_id, $item); ?>
233
  </td>
234
  <?php
235
  break;
237
  ?>
238
  <?php endforeach; ?>
239
  </tr>
240
+ <?php do_action('pmxi_manage_imports', $item, $class); ?>
241
  <?php endforeach; ?>
242
  <?php endif ?>
243
  </tbody>
249
  <div class="alignleft actions">
250
  <select name="bulk-action2">
251
  <option value="" selected="selected"><?php _e('Bulk Actions', 'pmxi_plugin') ?></option>
252
+ <?php if ( empty($type) or 'trash' != $type): ?>
253
  <option value="delete"><?php _e('Delete', 'pmxi_plugin') ?></option>
254
  <?php else: ?>
255
  <option value="restore"><?php _e('Restore', 'pmxi_plugin')?></option>
274
  ?>
275
 
276
  <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=manage&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Find out more about the professional edition of WP All Import.</a></p>
277
+
278
  </form>
views/admin/manage/scheduling.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <h2>
2
+ <?php _e('Cron Scheduling', 'pmxi_plugin') ?>
3
+ </h2>
4
+
5
+ <p>
6
+ To schedule an import, you must create two cron jobs in your web hosting control panel. One cron job will be used to run the Trigger script, the other to run the Execution script.
7
+ </p>
8
+
9
+ <p>
10
+ Trigger Script URL<br /><small>Run the trigger script when you want to update your import. Once per 24 hours is recommended.</small><br /><input style='width: 700px;' type='text' value='<?php echo home_url() . '/wp-cron.php?import_key=' . $cron_job_key . '&import_id=' . $id . '&action=trigger'; ?>' />
11
+ <br /><br />
12
+
13
+ Execution Script URL<br /><small>Run the execution script frequently. Once per two minutes is recommended.</small><br /><input style='width: 700px;' type='text' value='<?php echo home_url() . '/wp-cron.php?import_key=' . $cron_job_key . '&import_id=' . $id . '&action=processing'; ?>' /><br /><br />
14
+ </p>
15
+
16
+
17
+ <p><strong>Trigger Script</strong></p>
18
+
19
+ <p>Every time you want to schedule the import, run the trigger script.</p>
20
+
21
+ <p>To schedule the import to run once every 24 hours, run the trigger script every 24 hours. Most hosts require you to use “wget” to access a URL. Ask your host for details.</p>
22
+
23
+ <p><i>Example:</i></p>
24
+
25
+ <p>wget -q -O /dev/null "<?php echo home_url() . '/wp-cron.php?import_key=' . $cron_job_key . '&import_id=' . $id . '&action=trigger'; ?>"</p>
26
+
27
+ <p><strong>Execution Script</strong></p>
28
+
29
+ <p>The Execution script actually executes the import, once it has been triggered with the Trigger script.</p>
30
+
31
+ <p>It processes in iteration (only importing a few records each time it runs) to optimize server load. It is recommended you run the execution script every 2 minutes.</p>
32
+
33
+ <p>It also operates this way in case of unexpected crashes by your web host. If it crashes before the import is finished, the next run of the cron job two minutes later will continue it where it left off, ensuring reliability.</p>
34
+
35
+ <p><i>Example:</i></p>
36
+
37
+ <p>wget -q -O /dev/null "<?php echo home_url() . '/wp-cron.php?import_key=' . $cron_job_key . '&import_id=' . $id . '&action=processing'; ?>"</p>
38
+
39
+ <p><strong>Notes</strong></p>
40
+
41
+ <p>
42
+ Your web host may require you to use a command other than wget, although wget is most common. In this case, you must asking your web hosting provider for help.
43
+ </p>
44
+
45
+ <p>
46
+ See the <a href='http://www.wpallimport.com/documentation/common-use-cases/setting-up-a-recurring-import-using-cron-jobs/'>documentation</a> for more details.
47
+ </p>
48
+
views/admin/settings/index.php CHANGED
@@ -45,32 +45,18 @@
45
  <div><?php printf(__('max_input_time %s', 'pmxi_plugin'), ini_get('max_input_time')) ?></div>
46
 
47
  <h3><?php _e('Recurring & Scheduled Imports', 'pmxi_plugin') ?></h3>
48
-
49
- <hr />
50
-
51
- <h3>Please upgrade to the professional edition of WP All Import to perform recurring and scheduled imports.</h3>
52
-
53
- <p>WP All Import can periodically check your XML/CSV for updates on the schedule you define, and overwrite your existing import with new data. New posts will be made for new entries in the XML/CSV. Entries that haven't changed will be left alone. WP All Import can even delete "expired" posts (if their data is no longer in the updated XML/CSV).</p>
54
-
55
- <p>You can configure recurring imports from within WP All Import, or by setting up a cron job in your web hosting control panel.</p>
56
-
57
- <p>WP All Import can perform recurring imports with a file online at an http:// URL, or a file on an FTP server.</p>
58
-
59
- <p style='font-size: 1.3em; font-weight: bold;'><a href="http://www.wpallimport.com/upgrade-to-pro?utm_source=wordpress.org&utm_medium=recurring&utm_campaign=free+plugin" target="_blank" class="upgrade_link">Upgrade Now</a></p>
60
-
61
- <hr />
62
-
63
  <h3><?php _e('Import Settings', 'pmxi_plugin') ?></h3>
64
- <div><?php printf(__('Chunk maximum size %s (Kb)', 'pmxi_plugin'), '<input type="text" name="chunk_size" value="' . esc_attr($post['chunk_size']) . '"/>') ?></div>
 
65
  <p>
66
  <input type="hidden" name="legacy_special_character_handling" value="0"/>
67
  <?php printf(__('%s <label for="legacy_special_character_handling">My CSV files contain HTML code</label>', 'pmxi_plugin'), '<input type="checkbox" name="legacy_special_character_handling" id="legacy_special_character_handling" value="1" style="position:relative; top:-2px;" '. (($post['legacy_special_character_handling']) ? 'checked="checked"' : '') .'/>') ?>
68
- <a href="#help" class="help" title="<?php _e('By default wpallimport do not encode html tags in csv feeds. If this option is enabled that wpallimport will use htmlspecialchars() function.', 'pmxi_plugin') ?>">?</a>
69
  </p>
70
  <p>
71
  <input type="hidden" name="case_sensitive" value="0"/>
72
  <?php printf(__('%s <label for="case_sensitive">Enable case-sensitivity mode</label>', 'pmxi_plugin'), '<input type="checkbox" name="case_sensitive" id="case_sensitive" value="1" style="position:relative; top:-2px;" '. (($post['case_sensitive']) ? 'checked="checked"' : '') .'/>') ?>
73
- <a href="#help" class="help" title="<?php _e('', 'pmxi_plugin') ?>">?</a>
74
  </p>
75
  <p>
76
  <input type="hidden" name="pingbacks" value="0"/>
45
  <div><?php printf(__('max_input_time %s', 'pmxi_plugin'), ini_get('max_input_time')) ?></div>
46
 
47
  <h3><?php _e('Recurring & Scheduled Imports', 'pmxi_plugin') ?></h3>
48
+ <div><?php printf(__('Cron Job Secret Key %s', 'pmxi_plugin'), '<input type="text" name="cron_job_key" value="' . esc_attr($post['cron_job_key']) . '"/>') ?></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  <h3><?php _e('Import Settings', 'pmxi_plugin') ?></h3>
50
+ <p>
51
+ <?php printf(__('Create XML chunks, when feed contains more than %s (records)', 'pmxi_plugin'), '<input type="text" name="large_feed_limit" value="' . esc_attr($post['large_feed_limit']) . '"/>') ?></p>
52
  <p>
53
  <input type="hidden" name="legacy_special_character_handling" value="0"/>
54
  <?php printf(__('%s <label for="legacy_special_character_handling">My CSV files contain HTML code</label>', 'pmxi_plugin'), '<input type="checkbox" name="legacy_special_character_handling" id="legacy_special_character_handling" value="1" style="position:relative; top:-2px;" '. (($post['legacy_special_character_handling']) ? 'checked="checked"' : '') .'/>') ?>
55
+ <a href="#help" class="help" title="<?php _e('By default WP All Import does not encode the content of a CSV feed using htmlspecialchars(). Enable this option, and WP All Import will use htmlspecialchars() on the CSV content. Try this option if you get errors when importing CSV files in Step 1.', 'pmxi_plugin') ?>">?</a>
56
  </p>
57
  <p>
58
  <input type="hidden" name="case_sensitive" value="0"/>
59
  <?php printf(__('%s <label for="case_sensitive">Enable case-sensitivity mode</label>', 'pmxi_plugin'), '<input type="checkbox" name="case_sensitive" id="case_sensitive" value="1" style="position:relative; top:-2px;" '. (($post['case_sensitive']) ? 'checked="checked"' : '') .'/>') ?>
 
60
  </p>
61
  <p>
62
  <input type="hidden" name="pingbacks" value="0"/>