Import any XML or CSV File to WordPress - Version 3.1.5

Version Description

  • fixed pmxi_delete_post action
  • fixed import menu order & post parent for pages
  • fixed import log for continue import feature
  • added is update author option
  • fixed post formats
  • fixed UTC dates on manage imports page
Download this release

Release Info

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

Code changes from version 3.1.4 to 3.1.5

actions/admin_init.php CHANGED
@@ -1,5 +1,9 @@
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
+
6
+ @ini_set('mysql.connect_timeout', 300);
7
+ @ini_set('default_socket_timeout', 300);
8
+
9
  }
actions/admin_menu.php CHANGED
@@ -12,7 +12,7 @@ function pmxi_admin_menu() {
12
  array('pmxi-admin-import', __('New Import', 'pmxi_plugin')),
13
  array('pmxi-admin-manage' , __('Manage Imports', 'pmxi_plugin')),
14
  array('pmxi-admin-settings', __('Settings', 'pmxi_plugin')),
15
- array('pmxi-admin-help', __('Support', 'pmxi_plugin'))
16
  );
17
 
18
  $wpai_menu = apply_filters('pmxi_admin_menu', $wpai_menu);
12
  array('pmxi-admin-import', __('New Import', 'pmxi_plugin')),
13
  array('pmxi-admin-manage' , __('Manage Imports', 'pmxi_plugin')),
14
  array('pmxi-admin-settings', __('Settings', 'pmxi_plugin')),
15
+ array('pmxi-admin-help', __('Support', 'pmxi_plugin'))
16
  );
17
 
18
  $wpai_menu = apply_filters('pmxi_admin_menu', $wpai_menu);
actions/admin_notices.php CHANGED
@@ -58,5 +58,5 @@ function pmxi_admin_notices() {
58
  <div class="<?php echo $type ?>"><p><?php echo $m ?></p></div>
59
  <?php
60
  }
61
- }
62
  }
58
  <div class="<?php echo $type ?>"><p><?php echo $m ?></p></div>
59
  <?php
60
  }
61
+ }
62
  }
classes/chunk.php CHANGED
@@ -171,7 +171,7 @@ class PMXI_Chunk {
171
  // trim it
172
  $element = trim($this->options['element']);
173
 
174
- $xml = '';
175
 
176
  try {
177
  while ( @$this->reader->read() ) {
171
  // trim it
172
  $element = trim($this->options['element']);
173
 
174
+ $xml = '';
175
 
176
  try {
177
  while ( @$this->reader->read() ) {
classes/session.php CHANGED
@@ -98,6 +98,7 @@ final class PMXI_Session extends PMXI_ArrayAccess implements Iterator, Countable
98
  }
99
  elseif ($this->session_mode == 'files'){
100
  @file_put_contents(PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", $this->expires);
 
101
  }
102
  }
103
 
@@ -213,10 +214,12 @@ final class PMXI_Session extends PMXI_ArrayAccess implements Iterator, Countable
213
  }
214
  elseif ($this->session_mode == 'files'){
215
  if ( @file_exists( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt") ){
216
- @file_put_contents( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", (string) serialize($this->container) );
 
217
  }
218
  else{
219
  @file_put_contents( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", (string) serialize($this->container) );
 
220
  @file_put_contents( PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", $this->expires );
221
  }
222
  }
98
  }
99
  elseif ($this->session_mode == 'files'){
100
  @file_put_contents(PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", $this->expires);
101
+ @chmod(PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", 0600);
102
  }
103
  }
104
 
214
  }
215
  elseif ($this->session_mode == 'files'){
216
  if ( @file_exists( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt") ){
217
+ @file_put_contents( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", (string) serialize($this->container) );
218
+ @chmod(PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", 0600);
219
  }
220
  else{
221
  @file_put_contents( PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", (string) serialize($this->container) );
222
+ @chmod(PMXI_ROOT_DIR . "/sessions/" . $option_key . ".txt", 0600);
223
  @file_put_contents( PMXI_ROOT_DIR . "/sessions/_pmxi_session_expires_{$this->session_id}.txt", $this->expires );
224
  }
225
  }
controllers/admin/cron.php DELETED
@@ -1,12 +0,0 @@
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
@@ -26,7 +26,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
26
  $this->isWizard = false;
27
 
28
  } else {
29
- $action = PMXI_Plugin::getInstance()->getAdminCurrentScreen()->action;
30
  $this->_step_ready($action);
31
  $this->isInline = 'process' == $action;
32
  }
@@ -98,7 +98,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
98
  if ('template' == $action or 'preview' == $action or 'tag' == $action) return true;
99
 
100
  // step #4: options
101
- if (empty(PMXI_Plugin::$session->data['pmxi_import']['template']) or empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title']) or empty(PMXI_Plugin::$session->data['pmxi_import']['template']['content'])) {
102
  wp_redirect_or_javascript(add_query_arg('action', 'template', $this->baseUrl)); die();
103
  }
104
  if ('options' == $action) return true;
@@ -358,10 +358,10 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
358
  {
359
  $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@wpallimport.com">support@wpallimport.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
360
  }
361
- else{
362
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
363
  }
364
-
365
  } else {
366
  $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@wpallimport.com">support@wpallimport.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
367
  }
@@ -619,6 +619,9 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
619
  }
620
  }
621
  }
 
 
 
622
  if ( ! $this->errors->get_error_codes()) {
623
 
624
  $paths = array(); $this->data['paths'] =& $paths;
@@ -634,6 +637,8 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
634
  } else {
635
  $this->error();
636
  }
 
 
637
  }
638
 
639
  /**
@@ -686,10 +691,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
686
  $this->_validate_template($post['title'], 'Post title');
687
  }
688
 
689
- if (empty($post['content'])) {
690
- $post['content'] = '&nbsp;';
691
- $this->_validate_template($post['content'], 'Post content');
692
- } else {
693
  $this->_validate_template($post['content'], 'Post content');
694
  }
695
 
@@ -743,7 +745,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
743
  /**
744
  * Preview selected xml tag (called with ajax from `template` step)
745
  */
746
- public function tag()
747
  {
748
 
749
  $wp_uploads = wp_upload_dir();
@@ -820,7 +822,18 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
820
  }
821
  }
822
 
823
- $this->render();
 
 
 
 
 
 
 
 
 
 
 
824
  }
825
 
826
  /**
@@ -917,7 +930,13 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
917
  $this->errors->add('form-validation', sprintf(__('Error parsing content: %s', 'pmxi_plugin'), $e->getMessage()));
918
  }
919
 
 
 
920
  $this->render();
 
 
 
 
921
  }
922
 
923
  /**
@@ -1202,10 +1221,9 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1202
 
1203
  $wp_uploads = wp_upload_dir();
1204
 
1205
- $import = $this->data['update_previous'];
1206
- $logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; if ( "" != strip_tags(pmxi_strip_tags_content($m)) and !empty(PMXI_Plugin::$session[\'pmxi_import\'][\'log\'])) { PMXI_Plugin::$session[\'pmxi_import\'][\'log\'] .= "<p>".strip_tags(pmxi_strip_tags_content($m))."</p>"; flush(); }');
1207
 
1208
- if ( ! PMXI_Plugin::is_ajax() ) {
1209
 
1210
  $import->set(
1211
  (empty(PMXI_Plugin::$session->data['pmxi_import']['source']) ? array() : PMXI_Plugin::$session->data['pmxi_import']['source'])
@@ -1323,6 +1341,11 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1323
 
1324
  pmxi_session_commit();
1325
 
 
 
 
 
 
1326
  $this->render();
1327
  wp_ob_end_flush_all(); flush();
1328
  @set_time_limit(0);
@@ -1336,11 +1359,22 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1336
 
1337
  $ajax_processing = ("ajax" == $import->options['import_processing']) ? true : false;
1338
 
 
 
 
 
 
 
 
 
 
1339
  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'];
1340
 
1341
  wp_cache_flush();
1342
 
1343
- if ( PMXI_Plugin::is_ajax() or ! $ajax_processing ) {
 
 
1344
 
1345
  if ( "ajax" == $import->options['import_processing'] ) {
1346
  // HTTP headers for no cache etc
@@ -1420,7 +1454,7 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1420
 
1421
  $feed .= "</pmxi_records>";
1422
  $import->process($feed, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number'], false, '/pmxi_records');
1423
- unset($dom, $xpath);
1424
 
1425
  if ( ! $ajax_processing ){
1426
  $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
@@ -1429,13 +1463,19 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1429
  unset($file);
1430
  PMXI_Plugin::$session['pmxi_import']['pointer'] = PMXI_Plugin::$session->data['pmxi_import']['pointer'] + $pointer;
1431
  pmxi_session_commit();
 
 
 
 
 
 
1432
  wp_send_json(array(
1433
  'created' => $import->created,
1434
  'updated' => $import->updated,
1435
  'percentage' => ceil(($processed_records/$import->count) * 100),
1436
  'warnings' => PMXI_Plugin::$session->data['pmxi_import']['warnings'],
1437
  'errors' => PMXI_Plugin::$session->data['pmxi_import']['errors'],
1438
- 'log' => ob_get_clean(),
1439
  'done' => false
1440
  ));
1441
  }
@@ -1461,14 +1501,21 @@ class PMXI_Admin_Import extends PMXI_Controller_Admin {
1461
  }
1462
 
1463
  if ( ( PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths']) ) or ! $ajax_processing ){
1464
-
1465
- // Save import process log
1466
- $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
1467
- if (file_exists($log_file)) unlink($log_file);
1468
- @file_put_contents($log_file, PMXI_Plugin::$session->data['pmxi_import']['log']);
1469
-
1470
  if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']) ) do_action( 'pmxi_after_xml_import', $import->id );
1471
 
 
 
 
 
 
 
 
 
 
 
 
 
1472
  wp_cache_flush();
1473
  foreach ( get_taxonomies() as $tax ) {
1474
  delete_option( "{$tax}_children" );
@@ -1588,12 +1635,12 @@ COMPLETE;
1588
  $this->render_xml_text(trim($el->childNodes->item(0)->wholeText), $shorten, $is_render_collapsed);
1589
  } else {
1590
  echo '<div class="xml-content' . ($is_render_collapsed ? ' collapsed' : '') . '">';
1591
- $indexes = array();
1592
  foreach ($el->childNodes as $child) {
1593
  if ($child instanceof DOMElement) {
1594
  empty($indexes[$child->nodeName]) and $indexes[$child->nodeName] = 0; $indexes[$child->nodeName]++;
1595
  $this->render_xml_element($child, $shorten, $path . '/', $indexes[$child->nodeName], $lvl + 1);
1596
- } elseif ($child instanceof DOMText) {
1597
  $this->render_xml_text(trim($child->wholeText), $shorten);
1598
  } elseif ($child instanceof DOMComment) {
1599
  if (preg_match('%\[pmxi_more:(\d+)\]%', $child->nodeValue, $mtch)) {
26
  $this->isWizard = false;
27
 
28
  } else {
29
+ $action = PMXI_Plugin::getInstance()->getAdminCurrentScreen()->action;
30
  $this->_step_ready($action);
31
  $this->isInline = 'process' == $action;
32
  }
98
  if ('template' == $action or 'preview' == $action or 'tag' == $action) return true;
99
 
100
  // step #4: options
101
+ if (empty(PMXI_Plugin::$session->data['pmxi_import']['template']) or empty(PMXI_Plugin::$session->data['pmxi_import']['template']['title'])) {
102
  wp_redirect_or_javascript(add_query_arg('action', 'template', $this->baseUrl)); die();
103
  }
104
  if ('options' == $action) return true;
358
  {
359
  $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@wpallimport.com">support@wpallimport.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
360
  }
361
+ else{
362
  wp_redirect(add_query_arg('action', 'element', $this->baseUrl)); die();
363
  }
364
+
365
  } else {
366
  $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@wpallimport.com">support@wpallimport.com</a> – with your XML/CSV file. We will identify the problem and release a bug fix if necessary.', 'pmxi_plugin'));
367
  }
619
  }
620
  }
621
  }
622
+
623
+ ob_start();
624
+
625
  if ( ! $this->errors->get_error_codes()) {
626
 
627
  $paths = array(); $this->data['paths'] =& $paths;
637
  } else {
638
  $this->error();
639
  }
640
+
641
+ exit( json_encode(array('html' => ob_get_clean())) );
642
  }
643
 
644
  /**
691
  $this->_validate_template($post['title'], 'Post title');
692
  }
693
 
694
+ if (!empty($post['content'])) {
 
 
 
695
  $this->_validate_template($post['content'], 'Post content');
696
  }
697
 
745
  /**
746
  * Preview selected xml tag (called with ajax from `template` step)
747
  */
748
+ public function tag( $is_json = true )
749
  {
750
 
751
  $wp_uploads = wp_upload_dir();
822
  }
823
  }
824
 
825
+ if ( $is_json ){
826
+
827
+ ob_start();
828
+
829
+ $this->render();
830
+
831
+ $html = ob_get_clean();
832
+
833
+ exit( json_encode(array('html' => $html)) );
834
+
835
+ }
836
+ else $this->render();
837
  }
838
 
839
  /**
930
  $this->errors->add('form-validation', sprintf(__('Error parsing content: %s', 'pmxi_plugin'), $e->getMessage()));
931
  }
932
 
933
+ ob_start();
934
+
935
  $this->render();
936
+
937
+ $html = ob_get_clean();
938
+
939
+ exit( json_encode(array('html' => $html)) );
940
  }
941
 
942
  /**
1221
 
1222
  $wp_uploads = wp_upload_dir();
1223
 
1224
+ $import = $this->data['update_previous'];
 
1225
 
1226
+ if ( ! PMXI_Plugin::is_ajax() ) {
1227
 
1228
  $import->set(
1229
  (empty(PMXI_Plugin::$session->data['pmxi_import']['source']) ? array() : PMXI_Plugin::$session->data['pmxi_import']['source'])
1341
 
1342
  pmxi_session_commit();
1343
 
1344
+ $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
1345
+ if ( PMXI_Plugin::$session->data['pmxi_import']['action'] != 'continue' and file_exists($log_file)){
1346
+ @unlink($log_file);
1347
+ }
1348
+
1349
  $this->render();
1350
  wp_ob_end_flush_all(); flush();
1351
  @set_time_limit(0);
1359
 
1360
  $ajax_processing = ("ajax" == $import->options['import_processing']) ? true : false;
1361
 
1362
+ if ("ajax" == $import->options['import_processing'])
1363
+ {
1364
+ $logger = create_function('$m', 'echo "<div class=\\"progress-msg\\">$m</div>\\n"; flush();');
1365
+ }
1366
+ else
1367
+ {
1368
+ $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(); }');
1369
+ }
1370
+
1371
  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'];
1372
 
1373
  wp_cache_flush();
1374
 
1375
+ if ( PMXI_Plugin::is_ajax() or ! $ajax_processing ) {
1376
+
1377
+ $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
1378
 
1379
  if ( "ajax" == $import->options['import_processing'] ) {
1380
  // HTTP headers for no cache etc
1454
 
1455
  $feed .= "</pmxi_records>";
1456
  $import->process($feed, $logger, PMXI_Plugin::$session->data['pmxi_import']['chunk_number'], false, '/pmxi_records');
1457
+ unset($dom, $xpath);
1458
 
1459
  if ( ! $ajax_processing ){
1460
  $feed = "<?xml version=\"1.0\" encoding=\"". $import->options['encoding'] ."\"?>" . "\n" . "<pmxi_records>";
1463
  unset($file);
1464
  PMXI_Plugin::$session['pmxi_import']['pointer'] = PMXI_Plugin::$session->data['pmxi_import']['pointer'] + $pointer;
1465
  pmxi_session_commit();
1466
+
1467
+ $log_data = ob_get_clean();
1468
+ $log = @fopen($log_file, 'a+');
1469
+ @fwrite($log, $log_data);
1470
+ @fclose($log);
1471
+
1472
  wp_send_json(array(
1473
  'created' => $import->created,
1474
  'updated' => $import->updated,
1475
  'percentage' => ceil(($processed_records/$import->count) * 100),
1476
  'warnings' => PMXI_Plugin::$session->data['pmxi_import']['warnings'],
1477
  'errors' => PMXI_Plugin::$session->data['pmxi_import']['errors'],
1478
+ 'log' => $log_data,
1479
  'done' => false
1480
  ));
1481
  }
1501
  }
1502
 
1503
  if ( ( PMXI_Plugin::is_ajax() and empty(PMXI_Plugin::$session->data['pmxi_import']['local_paths']) ) or ! $ajax_processing ){
1504
+
 
 
 
 
 
1505
  if ( ! empty(PMXI_Plugin::$session->data['pmxi_import']) ) do_action( 'pmxi_after_xml_import', $import->id );
1506
 
1507
+ if ("ajax" != $import->options['import_processing']){
1508
+ $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' . $import->id . '.html';
1509
+ if (PMXI_Plugin::$session->data['pmxi_import']['action'] != 'continue'){
1510
+ @file_put_contents($log_file, PMXI_Plugin::$session->data['pmxi_import']['log']);
1511
+ }
1512
+ else{
1513
+ $log = @fopen($log_file, 'a+');
1514
+ @fwrite($log, PMXI_Plugin::$session->data['pmxi_import']['log']);
1515
+ @fclose($log);
1516
+ }
1517
+ }
1518
+
1519
  wp_cache_flush();
1520
  foreach ( get_taxonomies() as $tax ) {
1521
  delete_option( "{$tax}_children" );
1635
  $this->render_xml_text(trim($el->childNodes->item(0)->wholeText), $shorten, $is_render_collapsed);
1636
  } else {
1637
  echo '<div class="xml-content' . ($is_render_collapsed ? ' collapsed' : '') . '">';
1638
+ $indexes = array();
1639
  foreach ($el->childNodes as $child) {
1640
  if ($child instanceof DOMElement) {
1641
  empty($indexes[$child->nodeName]) and $indexes[$child->nodeName] = 0; $indexes[$child->nodeName]++;
1642
  $this->render_xml_element($child, $shorten, $path . '/', $indexes[$child->nodeName], $lvl + 1);
1643
+ } elseif ($child instanceof DOMText) {
1644
  $this->render_xml_text(trim($child->wholeText), $shorten);
1645
  } elseif ($child instanceof DOMComment) {
1646
  if (preg_match('%\[pmxi_more:(\d+)\]%', $child->nodeValue, $mtch)) {
controllers/admin/manage.php CHANGED
@@ -109,14 +109,14 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
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
  $chunks = 0;
117
 
118
  if ($this->input->post('is_confirmed')) {
119
 
 
 
120
  check_admin_referer('update-import', '_wpnonce_update-import');
121
 
122
  $uploads = wp_upload_dir();
@@ -353,8 +353,15 @@ class PMXI_Admin_Manage extends PMXI_Controller_Admin {
353
  $id = $this->input->get('id');
354
 
355
  $wp_uploads = wp_upload_dir();
 
356
 
357
- PMXI_download::csv($wp_uploads['basedir'] . '/wpallimport_logs/' .$id.'.html');
358
-
 
 
 
 
 
 
359
  }
360
  }
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
  $chunks = 0;
115
 
116
  if ($this->input->post('is_confirmed')) {
117
 
118
+ pmxi_session_unset();
119
+
120
  check_admin_referer('update-import', '_wpnonce_update-import');
121
 
122
  $uploads = wp_upload_dir();
353
  $id = $this->input->get('id');
354
 
355
  $wp_uploads = wp_upload_dir();
356
+ $log_file = $wp_uploads['basedir'] . '/wpallimport_logs/' .$id.'.html';
357
 
358
+ if (file_exists($log_file))
359
+ {
360
+ PMXI_download::xml($log_file);
361
+ }
362
+ else
363
+ {
364
+ wp_redirect(add_query_arg('pmxi_nt', urlencode(__('Log file does not exists.', 'pmxi_plugin')), $this->baseUrl)); die();
365
+ }
366
  }
367
  }
controllers/admin/settings.php CHANGED
@@ -111,23 +111,24 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
111
 
112
  PMXI_Plugin::getInstance()->updateOption("dismiss", 1);
113
 
114
- exit('OK');
115
  }
116
 
117
  public function dismiss_manage_top(){
118
 
119
  PMXI_Plugin::getInstance()->updateOption("dismiss_manage_top", 1);
120
 
121
- exit('OK');
122
  }
123
 
124
  public function dismiss_manage_bottom(){
125
 
126
  PMXI_Plugin::getInstance()->updateOption("dismiss_manage_bottom", 1);
127
 
128
- exit('OK');
129
  }
130
 
 
131
  public function meta_values(){
132
 
133
  global $wpdb;
@@ -153,7 +154,7 @@ class PMXI_Admin_Settings extends PMXI_Controller_Admin {
153
 
154
  $html .= '</div>';
155
 
156
- echo $html;
157
  }
158
 
159
  /**
111
 
112
  PMXI_Plugin::getInstance()->updateOption("dismiss", 1);
113
 
114
+ exit( json_encode(array('result' => 'OK')) );
115
  }
116
 
117
  public function dismiss_manage_top(){
118
 
119
  PMXI_Plugin::getInstance()->updateOption("dismiss_manage_top", 1);
120
 
121
+ exit( json_encode(array('result' => 'OK')) );
122
  }
123
 
124
  public function dismiss_manage_bottom(){
125
 
126
  PMXI_Plugin::getInstance()->updateOption("dismiss_manage_bottom", 1);
127
 
128
+ exit( json_encode(array('result' => 'OK')) );
129
  }
130
 
131
+
132
  public function meta_values(){
133
 
134
  global $wpdb;
154
 
155
  $html .= '</div>';
156
 
157
+ exit( json_encode(array('html' => $html)) );
158
  }
159
 
160
  /**
controllers/controller/admin.php CHANGED
@@ -25,10 +25,15 @@ abstract class PMXI_Controller_Admin extends PMXI_Controller {
25
  */
26
  public function __construct() {
27
  $remove = array_diff(array_keys($_GET), $this->baseUrlParamNames);
 
 
 
 
 
28
  if ($remove) {
29
- $this->baseUrl = remove_query_arg($remove);
30
  } else {
31
- $this->baseUrl = $_SERVER['REQUEST_URI'];
32
  }
33
  parent::__construct();
34
 
25
  */
26
  public function __construct() {
27
  $remove = array_diff(array_keys($_GET), $this->baseUrlParamNames);
28
+
29
+ $p_url = parse_url( home_url() );
30
+
31
+ $url = $p_url['scheme'] . '://' . $p_url['host'];
32
+
33
  if ($remove) {
34
+ $this->baseUrl = $url . remove_query_arg($remove);
35
  } else {
36
+ $this->baseUrl = $url . $_SERVER['REQUEST_URI'];
37
  }
38
  parent::__construct();
39
 
helpers/pmxi_findDuplicates.php CHANGED
@@ -8,24 +8,41 @@ function pmxi_findDuplicates($articleData, $custom_duplicate_name = '', $custom_
8
  global $wpdb;
9
 
10
  if ('custom field' == $duplicate_indicator){
 
11
  $duplicate_ids = array();
 
 
 
12
  $args = array(
13
- 'post_type' => ((class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? array('product', 'product_variation') : $articleData['post_type']),
14
  'post_status' => array('draft', 'publish', 'trash', 'pending', 'future', 'private'),
15
  'meta_query' => array(
16
  array(
17
- 'key' => $custom_duplicate_name,
18
- 'value' => $custom_duplicate_value,
19
  )
20
- )
 
 
21
  );
22
  $query = new WP_Query( $args );
23
 
24
  if ( $query->have_posts() ) $duplicate_ids[] = $query->post->ID;
25
 
26
- wp_reset_postdata();
 
 
 
 
 
 
 
 
 
 
27
 
28
  return $duplicate_ids;
 
29
  }
30
  elseif('parent' == $duplicate_indicator){
31
 
8
  global $wpdb;
9
 
10
  if ('custom field' == $duplicate_indicator){
11
+
12
  $duplicate_ids = array();
13
+
14
+ $post_types = (class_exists('PMWI_Plugin') and $articleData['post_type'] == 'product') ? array('product', 'product_variation') : array($articleData['post_type']);
15
+
16
  $args = array(
17
+ 'post_type' => $post_types,
18
  'post_status' => array('draft', 'publish', 'trash', 'pending', 'future', 'private'),
19
  'meta_query' => array(
20
  array(
21
+ 'key' => trim($custom_duplicate_name),
22
+ 'value' => htmlspecialchars(trim($custom_duplicate_value)),
23
  )
24
+ ),
25
+ 'order' => 'ASC',
26
+ 'orderby' => 'ID'
27
  );
28
  $query = new WP_Query( $args );
29
 
30
  if ( $query->have_posts() ) $duplicate_ids[] = $query->post->ID;
31
 
32
+ wp_reset_postdata();
33
+
34
+ if (empty($duplicate_ids)){
35
+
36
+ $query = $wpdb->get_results( $wpdb->prepare("SELECT SQL_CALC_FOUND_ROWS ".$wpdb->posts.".ID FROM ".$wpdb->posts." INNER JOIN ".$wpdb->postmeta." ON (".$wpdb->posts.".ID = ".$wpdb->postmeta.".post_id) WHERE 1=1 AND ".$wpdb->posts.".post_type IN ('". implode("','", $post_types) ."') AND (".$wpdb->posts.".post_status = 'publish' OR ".$wpdb->posts.".post_status = 'future' OR ".$wpdb->posts.".post_status = 'draft' OR ".$wpdb->posts.".post_status = 'pending' OR ".$wpdb->posts.".post_status = 'trash' OR ".$wpdb->posts.".post_status = 'private') AND ( (".$wpdb->postmeta.".meta_key = '%s' AND CAST(".$wpdb->postmeta.".meta_value AS CHAR) = '%s') ) GROUP BY ".$wpdb->posts.".ID ORDER BY ".$wpdb->posts.".ID ASC LIMIT 0, 20", trim($custom_duplicate_name), htmlspecialchars(trim($custom_duplicate_value))));
37
+
38
+ if ( ! empty($query) )
39
+ foreach ($query as $p)
40
+ $duplicate_ids[] = $p->ID;
41
+
42
+ }
43
 
44
  return $duplicate_ids;
45
+
46
  }
47
  elseif('parent' == $duplicate_indicator){
48
 
helpers/pmxi_functions.php CHANGED
@@ -182,10 +182,17 @@
182
  function pmxi_get_remote_image_ext($filePath){
183
 
184
  $response = wp_remote_get($filePath);
185
- $headers = wp_remote_retrieve_headers( $response );
186
  $content_type = (!empty($headers['content-type'])) ? explode('/', $headers['content-type']) : false;
 
 
 
 
 
 
 
187
 
188
- return ( ! empty($content_type[1]) ) ? $content_type[1] : '';
189
 
190
  }
191
  }
@@ -438,6 +445,13 @@
438
  }
439
  }
440
 
 
 
 
 
 
 
 
441
  /* Session */
442
 
443
  /**
182
  function pmxi_get_remote_image_ext($filePath){
183
 
184
  $response = wp_remote_get($filePath);
185
+ $headers = wp_remote_retrieve_headers( $response );
186
  $content_type = (!empty($headers['content-type'])) ? explode('/', $headers['content-type']) : false;
187
+ if (!empty($content_type[1])){
188
+ if (preg_match('%jpeg%i', $content_type[1])) return 'jpeg';
189
+ if (preg_match('%jpg%i', $content_type[1])) return 'jpg';
190
+ if (preg_match('%png%i', $content_type[1])) return 'png';
191
+ if (preg_match('%gif%i', $content_type[1])) return 'gif';
192
+ return $content_type[1];
193
+ }
194
 
195
+ return '';
196
 
197
  }
198
  }
445
  }
446
  }
447
 
448
+ if ( ! function_exists('pmxi_cdata_filter')):
449
+ function pmxi_cdata_filter($matches){
450
+ PMXI_Import_Record::$cdata[] = $matches[0];
451
+ return '{{CPLACE_'. count(PMXI_Import_Record::$cdata) .'}}';
452
+ }
453
+ endif;
454
+
455
  /* Session */
456
 
457
  /**
helpers/pmxi_insert_attachment.php CHANGED
@@ -96,6 +96,16 @@ function pmxi_insert_attachment($object, $file = false, $parent = 0) {
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 ) {
@@ -118,6 +128,23 @@ function pmxi_insert_attachment($object, $file = false, $parent = 0) {
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
 
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
+ /**
100
+ * Filter attachment post data before it is updated in or added
101
+ * to the database.
102
+ *
103
+ * @since 3.9.0
104
+ *
105
+ * @param array $data Array of sanitized attachment post data.
106
+ * @param array $object Array of un-sanitized attachment post data.
107
+ */
108
+ $data = apply_filters( 'wp_insert_attachment_data', $data, $object );
109
  $data = wp_unslash( $data );
110
 
111
  if ( $update ) {
128
  $wpdb->update( $wpdb->posts, compact("post_name"), array( 'ID' => $post_ID ) );
129
  }
130
 
131
+ if ( is_object_in_taxonomy($post_type, 'category') )
132
+ wp_set_post_categories( $post_ID, $post_category );
133
+
134
+ if ( isset( $tags_input ) && is_object_in_taxonomy($post_type, 'post_tag') )
135
+ wp_set_post_tags( $post_ID, $tags_input );
136
+
137
+ // support for all custom taxonomies
138
+ if ( !empty($tax_input) ) {
139
+ foreach ( $tax_input as $taxonomy => $tags ) {
140
+ $taxonomy_obj = get_taxonomy($taxonomy);
141
+ if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
142
+ $tags = array_filter($tags);
143
+ if ( current_user_can($taxonomy_obj->cap->assign_terms) )
144
+ wp_set_post_terms( $post_ID, $tags, $taxonomy );
145
+ }
146
+ }
147
+
148
  if ( $file )
149
  update_attached_file( $post_ID, $file );
150
 
helpers/pmxi_insert_post.php CHANGED
@@ -26,15 +26,7 @@ function pmxi_insert_post($postarr, $wp_error = false){
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
  }
@@ -58,10 +50,10 @@ function pmxi_insert_post($postarr, $wp_error = false){
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 {
@@ -70,7 +62,7 @@ function pmxi_insert_post($postarr, $wp_error = false){
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
26
 
27
  // Get the post ID and GUID
28
  $post_ID = $ID;
29
+
 
 
 
 
 
 
 
 
30
  } else {
31
  $previous_status = 'new';
32
  }
50
  $post_author = $user_id;
51
 
52
  // Create a valid post name. Drafts and pending posts are allowed to have an empty
53
+ // post name.
54
  if ( empty($post_name) ) {
55
+ if ( !in_array( $post_status, array( 'draft', 'pending', 'auto-draft' ) ) )
56
+ $post_name = sanitize_title($post_title);
57
  else
58
  $post_name = '';
59
  } else {
62
  if ( $update && strtolower( urlencode( $post_name ) ) == $check_name && get_post_field( 'post_name', $ID ) == $check_name )
63
  $post_name = $check_name;
64
  else // new post, or slug has changed.
65
+ $post_name = sanitize_title($post_name);
66
  }
67
 
68
  // 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
helpers/pmxi_recursion_taxes.php CHANGED
@@ -2,10 +2,10 @@
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(
@@ -18,7 +18,7 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
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(
@@ -32,11 +32,13 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
32
  }
33
  else{
34
 
 
 
35
  if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
36
 
37
  $parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
38
 
39
- $term = is_exists_term($tx_name, $parent, (int)$parent_id);
40
 
41
  if ( empty($term) and ! is_wp_error($term) ){
42
  $term = wp_insert_term(
@@ -49,7 +51,7 @@ function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
49
  }
50
  else{
51
 
52
- $term = is_exists_term($tx_name, $parent);
53
  if ( empty($term) and !is_wp_error($term) ){
54
  $term = wp_insert_term(
55
  $parent, // the term
2
  function pmxi_recursion_taxes($parent, $tx_name, $txes, $key){
3
 
4
  if (is_array($parent)){
5
+ $parent['name'] = htmlspecialchars($parent['name']);
6
  if (empty($parent['parent'])){
7
 
8
+ $term = term_exists($parent['name'], $tx_name);
9
 
10
  if ( empty($term) and !is_wp_error($term) ){
11
  $term = wp_insert_term(
18
  else{
19
  $parent_id = pmxi_recursion_taxes($parent['parent'], $tx_name, $txes, $key);
20
 
21
+ $term = term_exists($parent['name'], $tx_name, (int)$parent_id);
22
 
23
  if ( empty($term) and !is_wp_error($term) ){
24
  $term = wp_insert_term(
32
  }
33
  else{
34
 
35
+ $parent = htmlspecialchars($parent);
36
+
37
  if ( !empty($txes[$key - 1]) and !empty($txes[$key - 1]['parent']) and $parent != $txes[$key - 1]['parent']) {
38
 
39
  $parent_id = pmxi_recursion_taxes($txes[$key - 1]['parent'], $tx_name, $txes, $key - 1);
40
 
41
+ $term = term_exists($parent, $tx_name, (int)$parent_id);
42
 
43
  if ( empty($term) and ! is_wp_error($term) ){
44
  $term = wp_insert_term(
51
  }
52
  else{
53
 
54
+ $term = term_exists($parent, $tx_name);
55
  if ( empty($term) and !is_wp_error($term) ){
56
  $term = wp_insert_term(
57
  $parent, // the term
helpers/reverse_taxonomies_html.php CHANGED
@@ -2,7 +2,7 @@
2
 
3
  if ( ! function_exists('reverse_taxonomies_html') ) {
4
 
5
- function reverse_taxonomies_html($post_taxonomies, $item_id, &$i, $ctx_name, $entry){
6
  $childs = array();
7
  foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
8
 
2
 
3
  if ( ! function_exists('reverse_taxonomies_html') ) {
4
 
5
+ function reverse_taxonomies_html($post_taxonomies, $item_id, &$i, $ctx_name = '', $entry = ''){
6
  $childs = array();
7
  foreach ($post_taxonomies as $j => $cat) if ($cat->parent_id == $item_id) { $childs[] = $cat; }
8
 
helpers/wp_delete_attachments.php CHANGED
@@ -17,6 +17,10 @@ function wp_delete_attachments($parent_id, $unlink = true, $type = '') {
17
  wp_delete_attachment($attach->ID, true);
18
  }
19
  else{
 
 
 
 
20
  global $wpdb;
21
  $sql = "delete a,b,c
22
  FROM ".$wpdb->posts." a
@@ -27,7 +31,8 @@ function wp_delete_attachments($parent_id, $unlink = true, $type = '') {
27
 
28
  $wpdb->query(
29
  $wpdb->prepare($sql, '')
30
- );
 
31
  }
32
  }
33
  }
17
  wp_delete_attachment($attach->ID, true);
18
  }
19
  else{
20
+
21
+ do_action( 'delete_attachment', $attach->ID );
22
+ do_action( 'delete_post', $attach->ID );
23
+
24
  global $wpdb;
25
  $sql = "delete a,b,c
26
  FROM ".$wpdb->posts." a
31
 
32
  $wpdb->query(
33
  $wpdb->prepare($sql, '')
34
+ );
35
+
36
  }
37
  }
38
  }
models/import/record.php CHANGED
@@ -1,6 +1,10 @@
1
  <?php
2
 
3
  class PMXI_Import_Record extends PMXI_Model_Record {
 
 
 
 
4
 
5
  /**
6
  * Some pre-processing logic, such as removing control characters from xml to prevent parsing errors
@@ -8,8 +12,20 @@ class PMXI_Import_Record extends PMXI_Model_Record {
8
  */
9
  public static function preprocessXml( & $xml) {
10
 
11
- if ( empty(PMXI_Plugin::$session->data['pmxi_import']['is_csv']) and empty(PMXI_Plugin::$is_csv)) $xml = str_replace("&", "&amp;", str_replace("&amp;","&", $xml));
12
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  }
14
 
15
  /**
@@ -61,6 +77,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
61
  public function __construct($data = array()) {
62
  parent::__construct($data);
63
  $this->setTable(PMXI_Plugin::getInstance()->getTablePrefix() . 'imports');
 
64
  }
65
 
66
  /**
@@ -71,7 +88,10 @@ class PMXI_Import_Record extends PMXI_Model_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
 
@@ -138,13 +158,27 @@ class PMXI_Import_Record extends PMXI_Model_Record {
138
  count($titles) and $post_slug = array_fill(0, count($titles), '');
139
  }
140
 
 
 
 
 
 
 
 
 
 
141
  $chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
142
- $contents = XmlImportParser::factory(
143
- ((!empty($this->template['is_keep_linebreaks']) and intval($this->template['is_keep_linebreaks'])) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
144
- $cxpath,
145
- $this->template['content'],
146
- $file)->parse($records
147
- ); $tmp_files[] = $file;
 
 
 
 
 
148
 
149
  $chunk == 1 and $logger and call_user_func($logger, __('Composing dates...', 'pmxi_plugin'));
150
  if ('specific' == $this->options['date_type']) {
@@ -489,7 +523,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
489
  $post_type = ($this->options['custom_type'] == 'product' and class_exists('PMWI_Plugin')) ? $this->options['custom_type'] : (($this->options['custom_type'] == 'page') ? 'page' : 'post');
490
  } else {
491
  $post_type = $this->options['type'];
492
- }
493
 
494
  $addons = array();
495
  $addons_data = array();
@@ -566,15 +600,10 @@ class PMXI_Import_Record extends PMXI_Model_Record {
566
  'post_date' => $dates[$i],
567
  'post_date_gmt' => get_gmt_from_date($dates[$i]),
568
  'post_author' => $post_author[$i],
569
- 'tags_input' => $tags[$i]
570
- );
571
-
572
- if ('post' != $articleData['post_type']){
573
- $articleData += array(
574
- 'menu_order' => $this->options['order'],
575
- 'post_parent' => $this->options['parent'],
576
- );
577
- }
578
 
579
  // Re-import Records Matching
580
  $post_to_update = false; $post_to_update_id = false;
@@ -590,18 +619,11 @@ class PMXI_Import_Record extends PMXI_Model_Record {
590
  ));
591
 
592
  if ( ! $postRecord->isEmpty() )
593
- $post_to_update = get_post($post_to_update_id = $postRecord->post_id);
594
 
595
  // if Manual Matching re-import option seleted
596
  } else {
597
-
598
- $postRecord->clear();
599
- // find corresponding article among previously imported
600
- $postRecord->getBy(array(
601
- 'unique_key' => $unique_keys[$i],
602
- 'import_id' => $this->id,
603
- ));
604
-
605
  if ('custom field' == $this->options['duplicate_indicator']) {
606
  $custom_duplicate_value = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_value'], $file)->parse($records); $tmp_files[] = $file;
607
  $custom_duplicate_name = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
@@ -621,6 +643,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
621
  }
622
 
623
  if (!empty($specified_records)){
 
624
  if ( ! in_array($created + $updated + $skipped + 1, $specified_records) ){
625
 
626
  if ( ! $postRecord->isEmpty() ) $postRecord->set(array('iteration' => $this->iteration))->update();
@@ -734,7 +757,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
734
  }
735
  if ( ! $this->options['is_update_parent']){
736
  $articleData['post_parent'] = $post_to_update->post_parent;
737
- }
 
 
 
 
 
 
738
  }
739
  if ( $this->options['update_all_data'] == 'yes' or ( $this->options['update_all_data'] == 'no' and $this->options['is_update_attachments'])) {
740
  wp_delete_attachments($articleData['ID'], true, 'files');
@@ -905,7 +934,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
905
 
906
  $encoded_meta = array();
907
 
908
- foreach ($serialized_meta as $m_key => $values) {
909
 
910
  if (!empty($articleData['ID'])){
911
 
@@ -960,6 +989,13 @@ class PMXI_Import_Record extends PMXI_Model_Record {
960
  if (function_exists($import_func)) call_user_func($import_func, $importData, $addons_data[$class]);
961
  }
962
  }
 
 
 
 
 
 
 
963
 
964
  // [/addons import]
965
 
@@ -967,214 +1003,223 @@ class PMXI_Import_Record extends PMXI_Model_Record {
967
  if ('post' != $articleData['post_type'] and !empty($this->options['page_template'])) update_post_meta($pid, '_wp_page_template', $this->options['page_template']);
968
 
969
  // [featured image]
970
- if ( ! 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']))) {
971
 
972
- require_once(ABSPATH . 'wp-admin/includes/image.php');
973
 
974
- $success_images = false;
975
- $gallery_attachment_ids = array();
976
-
977
- $_pmxi_images = array();
978
-
979
- $imgs = ( ! empty($this->options['featured_delim']) ) ? str_getcsv($featured_images[$i], $this->options['featured_delim']) : explode("\n", $featured_images[$i]);
980
-
981
- if (!empty($imgs)) {
982
-
983
- if ( $this->options['set_image_meta_data'] ){
984
- $img_titles = ( ! empty($this->options['image_meta_title_delim']) ) ? str_getcsv($image_meta_titles[$i], $this->options['image_meta_title_delim']) : explode("\n", $image_meta_titles[$i]);
985
- $img_captions = ( ! empty($this->options['image_meta_caption_delim']) ) ? str_getcsv($image_meta_captions[$i], $this->options['image_meta_caption_delim']) : explode("\n", $image_meta_captions[$i]);
986
- $img_alts = ( ! empty($this->options['image_meta_alt_delim']) ) ? str_getcsv($image_meta_alts[$i], $this->options['image_meta_alt_delim']) : explode("\n", $image_meta_alts[$i]);
987
- $img_descriptions = ( ! empty($this->options['image_meta_description_delim']) ) ? str_getcsv($image_meta_descriptions[$i], $this->options['image_meta_description_delim']) : explode("\n", $image_meta_descriptions[$i]);
988
- }
989
 
990
- foreach ($imgs as $k => $img_url) { if (empty($img_url)) continue;
 
 
 
 
991
 
992
- $url = str_replace(" ", "%20", trim($img_url));
993
- $bn = preg_replace('/[\\?|&].*/', '', basename($url));
994
-
995
- $img_ext = pmxi_getExtensionFromStr($url);
996
- $default_extension = pmxi_getExtension($bn);
 
997
 
998
- if ($img_ext == "")
999
- $img_ext = pmxi_get_remote_image_ext($url);
1000
 
1001
- // generate local file name
1002
- $image_name = urldecode(($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? sanitize_file_name($auto_rename_images[$i] . '_' . (($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn)) : sanitize_file_name((($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn))) . (("" != $img_ext) ? '.' . $img_ext : '');
1003
-
1004
- // if wizard store image data to custom field
1005
- $create_image = false;
1006
- $download_image = true;
1007
-
1008
- if (base64_decode($url, true) !== false){
1009
- $img = @imagecreatefromstring(base64_decode($url));
1010
- if($img)
1011
- {
1012
- $image_filename = md5(time()) . '.jpg';
1013
- $image_filepath = $uploads['path'] . '/' . $image_filename;
1014
- imagejpeg($img, $image_filepath);
1015
- if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1016
- $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));
1017
- $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1018
- } else {
1019
- $create_image = true;
1020
- }
1021
- }
1022
- }
1023
- else {
1024
 
1025
- $image_filename = wp_unique_filename($uploads['path'], $image_name);
1026
- $image_filepath = $uploads['path'] . '/' . $image_filename;
1027
-
1028
- // keep existing and add newest images
1029
- 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"){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1030
 
1031
- $attachment_imgs = get_posts( array(
1032
- 'post_type' => 'attachment',
1033
- 'posts_per_page' => -1,
1034
- 'post_parent' => $pid,
1035
- ) );
1036
-
1037
- if ( $attachment_imgs ) {
1038
- foreach ( $attachment_imgs as $attachment_img ) {
1039
- if ($attachment_img->guid == $uploads['url'] . '/' . $image_name){
1040
- $download_image = false;
1041
- $success_images = true;
1042
- if ( ! has_post_thumbnail($pid) )
1043
- set_post_thumbnail($pid, $attachment_img->ID);
1044
- else
1045
- $gallery_attachment_ids[] = $attachment_img->ID;
 
 
 
 
 
 
 
 
 
 
 
1046
 
1047
- $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']));
1048
- }
1049
- }
1050
  }
1051
 
1052
- }
1053
-
1054
- if ($download_image){
1055
 
1056
- // do not download images
1057
- if ( ! $this->options['download_images'] ){
1058
 
1059
- $image_filename = $image_name;
1060
- $image_filepath = $uploads['path'] . '/' . $image_filename;
1061
-
1062
- $existing_attachment = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->prefix ."posts WHERE guid = '%s'", $uploads['url'] . '/' . $image_filename ) );
1063
-
1064
- if ( ! empty($existing_attachment->ID) ){
1065
 
1066
- $download_image = false;
1067
- $create_image = false;
1068
 
1069
- if ( ! has_post_thumbnail($pid) )
1070
- set_post_thumbnail($pid, $existing_attachment->ID);
1071
- else
1072
- $gallery_attachment_ids[] = $existing_attachment->ID;
1073
 
1074
- do_action( 'pmxi_gallery_image', $pid, $existing_attachment->ID, $image_filepath);
1075
 
1076
- }
1077
- else{
1078
-
1079
- if ( @file_exists($image_filepath) ){
1080
- $download_image = false;
1081
- if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1082
- $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));
1083
- $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1084
- @unlink($image_filepath);
1085
- } else {
1086
- $create_image = true;
 
1087
  }
1088
  }
1089
- }
1090
- }
1091
-
1092
- if ($download_image){
1093
-
1094
- $request = get_file_curl($url, $image_filepath);
1095
-
1096
- if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1097
- @unlink($image_filepath); // delete file since failed upload may result in empty file created
1098
- } elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1099
- $create_image = true;
1100
- }
1101
-
1102
- if ( ! $create_image ){
1103
 
1104
- $url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
1105
 
1106
  $request = get_file_curl($url, $image_filepath);
1107
 
1108
  if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1109
- $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
1110
- $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1111
- @unlink($image_filepath); // delete file since failed upload may result in empty file created
1112
- } elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1113
- $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));
1114
- $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1115
- @unlink($image_filepath);
1116
- } else {
1117
  $create_image = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1118
  }
1119
  }
1120
  }
1121
  }
1122
- }
1123
 
1124
- if ($create_image){
1125
 
1126
- $attachment = array(
1127
- 'post_mime_type' => image_type_to_mime_type($image_info[2]),
1128
- 'guid' => $uploads['url'] . '/' . $image_filename,
1129
- 'post_title' => $image_filename,
1130
- 'post_content' => '',
1131
- 'post_author' => $post_author[$i],
1132
- );
1133
- if (($image_meta = wp_read_image_metadata($image_filepath))) {
1134
- if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title'])))
1135
- $attachment['post_title'] = $image_meta['title'];
1136
- if (trim($image_meta['caption']))
1137
- $attachment['post_content'] = $image_meta['caption'];
1138
- }
1139
 
1140
- $attid = ($this->options['is_fast_mode']) ? pmxi_insert_attachment($attachment, $image_filepath, $pid) : wp_insert_attachment($attachment, $image_filepath, $pid);
1141
 
1142
- if (is_wp_error($attid)) {
1143
- $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $attid->get_error_message());
1144
- $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1145
- } else {
1146
- // you must first include the image.php file
1147
- // for the function wp_generate_attachment_metadata() to work
1148
- require_once(ABSPATH . 'wp-admin/includes/image.php');
1149
- wp_update_attachment_metadata($attid, wp_generate_attachment_metadata($attid, $image_filepath));
1150
-
1151
- if ( $this->options['set_image_meta_data'] ){
1152
- $update_attachment_meta = array();
1153
- if ( ! empty($img_titles[$k]) ) $update_attachment_meta['post_title'] = $img_titles[$k];
1154
- if ( ! empty($img_captions[$k]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$k];
1155
- if ( ! empty($img_descriptions[$k]) ) $update_attachment_meta['post_content'] = $img_descriptions[$k];
1156
- if ( ! empty($img_alts[$k]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$k]);
1157
-
1158
- if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
1159
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1160
  }
 
 
 
 
 
 
 
 
1161
 
1162
- do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
1163
 
1164
- $success_images = true;
1165
- if ( ! has_post_thumbnail($pid) )
1166
- set_post_thumbnail($pid, $attid);
1167
- else
1168
- $gallery_attachment_ids[] = $attid;
1169
- }
1170
- }
1171
- }
1172
- }
1173
- // Set product gallery images
1174
- if ( $post_type == "product" and !empty($gallery_attachment_ids) )
1175
- update_post_meta($pid, '_product_image_gallery', implode(',', $gallery_attachment_ids));
1176
- // Create entry as Draft if no images are downloaded successfully
1177
- if ( ! $success_images and "yes" == $this->options['create_draft'] ) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
1178
  }
1179
  // [/featured image]
1180
 
@@ -1226,7 +1271,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1226
  $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1227
  } else {
1228
  wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attachment_filepath));
1229
- do_action( 'pmxi_attachment_uploaded', $pid, $attid, $image_filepath);
1230
  }
1231
  }
1232
  }
@@ -1269,15 +1314,19 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1269
 
1270
  $parent_id = (!empty($single_tax['parent'])) ? pmxi_recursion_taxes($single_tax['parent'], $tx_name, $txes[$i], $key) : '';
1271
 
1272
- $term = is_exists_term($tx_name, $single_tax['name'], (int)$parent_id);
1273
 
1274
  if ( empty($term) and !is_wp_error($term) ){
1275
- $term_attr = array('parent'=> (!empty($parent_id)) ? $parent_id : 0);
1276
- $term = wp_insert_term(
1277
- $single_tax['name'], // the term
1278
- $tx_name, // the taxonomy
1279
- $term_attr
1280
- );
 
 
 
 
1281
  }
1282
 
1283
  if ( is_wp_error($term) ){
@@ -1356,14 +1405,21 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1356
 
1357
  $parent_id = (!empty($single_cat['parent'])) ? pmxi_recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
1358
 
1359
- $term = is_exists_term('category', $single_cat['name'], (int)$parent_id);
1360
-
1361
- if ( empty($term) and ! is_wp_error($term) ){
1362
- $term = wp_insert_term(
1363
- $single_cat['name'], // the term
1364
- 'category', // the taxonomy
1365
- array('parent' => ((!empty($parent_id)) ? (int)$parent_id : 0))
1366
- );
 
 
 
 
 
 
 
1367
  }
1368
 
1369
  if ( is_wp_error($term) ){
@@ -1450,8 +1506,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1450
  'imported' => $created + $updated,
1451
  'created' => $created,
1452
  'updated' => $updated,
1453
- 'skipped' => $skipped,
1454
- 'queue_chunk_number' => $created + $updated + $skipped
1455
  ))->update();
1456
 
1457
  if ( ! $is_cron ){
@@ -1517,6 +1572,8 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1517
  // Delete posts from database
1518
  if (!empty($missing_ids) && is_array($missing_ids) and ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
1519
 
 
 
1520
  $sql = "delete a,b,c
1521
  FROM ".$this->wpdb->posts." a
1522
  LEFT JOIN ".$this->wpdb->term_relationships." b ON ( a.ID = b.object_id )
@@ -1525,9 +1582,7 @@ class PMXI_Import_Record extends PMXI_Model_Record {
1525
 
1526
  $this->wpdb->query(
1527
  $this->wpdb->prepare($sql, '')
1528
- );
1529
-
1530
- do_action('pmxi_delete_post', $missing_ids);
1531
  }
1532
 
1533
  }
1
  <?php
2
 
3
  class PMXI_Import_Record extends PMXI_Model_Record {
4
+
5
+ public static $cdata = array();
6
+
7
+ protected $errors;
8
 
9
  /**
10
  * Some pre-processing logic, such as removing control characters from xml to prevent parsing errors
12
  */
13
  public static function preprocessXml( & $xml) {
14
 
15
+ if ( empty(PMXI_Plugin::$session->data['pmxi_import']['is_csv']) and empty(PMXI_Plugin::$is_csv)){
16
 
17
+ self::$cdata = array();
18
+
19
+ $xml = preg_replace_callback('/<!\[CDATA\[[^\]\]>]*\]\]>/s', 'pmxi_cdata_filter', $xml );
20
+
21
+ $xml = str_replace("&", "&amp;", str_replace("&amp;","&", $xml));
22
+
23
+ if ( ! empty(self::$cdata) ){
24
+ foreach (self::$cdata as $key => $val) {
25
+ $xml = str_replace('{{CPLACE_' . ($key + 1) . '}}', $val, $xml);
26
+ }
27
+ }
28
+ }
29
  }
30
 
31
  /**
77
  public function __construct($data = array()) {
78
  parent::__construct($data);
79
  $this->setTable(PMXI_Plugin::getInstance()->getTablePrefix() . 'imports');
80
+ $this->errors = new WP_Error();
81
  }
82
 
83
  /**
88
  * @chainable
89
  */
90
  public function process($xml, $logger = NULL, $chunk = false, $is_cron = false, $xpath_prefix = '') {
91
+
92
  add_filter('user_has_cap', array($this, '_filter_has_cap_unfiltered_html')); kses_init(); // do not perform special filtering for imported content
93
+
94
+ kses_remove_filters();
95
 
96
  $cxpath = $xpath_prefix . $this->xpath;
97
 
158
  count($titles) and $post_slug = array_fill(0, count($titles), '');
159
  }
160
 
161
+ $chunk == 1 and $logger and call_user_func($logger, __('Composing menu order...', 'pmxi_plugin'));
162
+ $menu_order = array();
163
+ if (!empty($this->options['order'])){
164
+ $menu_order = XmlImportParser::factory($xml, $cxpath, $this->options['order'], $file)->parse($records); $tmp_files[] = $file;
165
+ }
166
+ else{
167
+ count($titles) and $menu_order = array_fill(0, count($titles), '');
168
+ }
169
+
170
  $chunk == 1 and $logger and call_user_func($logger, __('Composing contents...', 'pmxi_plugin'));
171
+ if (!empty($this->template['content'])){
172
+ $contents = XmlImportParser::factory(
173
+ ((!empty($this->template['is_keep_linebreaks']) and intval($this->template['is_keep_linebreaks'])) ? $xml : preg_replace('%\r\n?|\n%', ' ', $xml)),
174
+ $cxpath,
175
+ $this->template['content'],
176
+ $file)->parse($records
177
+ ); $tmp_files[] = $file;
178
+ }
179
+ else{
180
+ count($titles) and $contents = array_fill(0, count($titles), '');
181
+ }
182
 
183
  $chunk == 1 and $logger and call_user_func($logger, __('Composing dates...', 'pmxi_plugin'));
184
  if ('specific' == $this->options['date_type']) {
523
  $post_type = ($this->options['custom_type'] == 'product' and class_exists('PMWI_Plugin')) ? $this->options['custom_type'] : (($this->options['custom_type'] == 'page') ? 'page' : 'post');
524
  } else {
525
  $post_type = $this->options['type'];
526
+ }
527
 
528
  $addons = array();
529
  $addons_data = array();
600
  'post_date' => $dates[$i],
601
  'post_date_gmt' => get_gmt_from_date($dates[$i]),
602
  'post_author' => $post_author[$i],
603
+ 'tags_input' => $tags[$i],
604
+ 'menu_order' => (int) $menu_order[$i],
605
+ 'post_parent' => (int) $this->options['parent']
606
+ );
 
 
 
 
 
607
 
608
  // Re-import Records Matching
609
  $post_to_update = false; $post_to_update_id = false;
619
  ));
620
 
621
  if ( ! $postRecord->isEmpty() )
622
+ $post_to_update = get_post($post_to_update_id = $postRecord->post_id);
623
 
624
  // if Manual Matching re-import option seleted
625
  } else {
626
+
 
 
 
 
 
 
 
627
  if ('custom field' == $this->options['duplicate_indicator']) {
628
  $custom_duplicate_value = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_value'], $file)->parse($records); $tmp_files[] = $file;
629
  $custom_duplicate_name = XmlImportParser::factory($xml, $cxpath, $this->options['custom_duplicate_name'], $file)->parse($records); $tmp_files[] = $file;
643
  }
644
 
645
  if (!empty($specified_records)){
646
+
647
  if ( ! in_array($created + $updated + $skipped + 1, $specified_records) ){
648
 
649
  if ( ! $postRecord->isEmpty() ) $postRecord->set(array('iteration' => $this->iteration))->update();
757
  }
758
  if ( ! $this->options['is_update_parent']){
759
  $articleData['post_parent'] = $post_to_update->post_parent;
760
+ }
761
+ if ( ! $this->options['is_update_post_author']){
762
+ $articleData['post_author'] = $post_to_update->post_author;
763
+ }
764
+
765
+ $articleData = apply_filters('pmxi_article_data', $articleData, $this, $post_to_update);
766
+
767
  }
768
  if ( $this->options['update_all_data'] == 'yes' or ( $this->options['update_all_data'] == 'no' and $this->options['is_update_attachments'])) {
769
  wp_delete_attachments($articleData['ID'], true, 'files');
934
 
935
  $encoded_meta = array();
936
 
937
+ foreach ($serialized_meta as $m_key => $values) { if ( empty($m_key) ) continue;
938
 
939
  if (!empty($articleData['ID'])){
940
 
989
  if (function_exists($import_func)) call_user_func($import_func, $importData, $addons_data[$class]);
990
  }
991
  }
992
+ if ( count(PMXI_Admin_Addons::get_active_addons()) ){
993
+ $is_post_exist = get_post($pid);
994
+ if ( empty($is_post_exist) ) {
995
+ $logger and call_user_func($logger, sprintf(__('`%s` post was deleted', 'pmxi_plugin'), $articleData['post_title']));
996
+ continue;
997
+ }
998
+ }
999
 
1000
  // [/addons import]
1001
 
1003
  if ('post' != $articleData['post_type'] and !empty($this->options['page_template'])) update_post_meta($pid, '_wp_page_template', $this->options['page_template']);
1004
 
1005
  // [featured image]
1006
+ if ( ! empty($uploads) and false === $uploads['error'] and (empty($articleData['ID']) or $this->options['update_all_data'] == "yes" or ( $this->options['update_all_data'] == "no" and $this->options['is_update_images']))) {
1007
 
1008
+ if (!empty($featured_images[$i])){
1009
 
1010
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
1011
+
1012
+ $success_images = false;
1013
+ $gallery_attachment_ids = array();
 
 
 
 
 
 
 
 
 
 
 
1014
 
1015
+ $_pmxi_images = array();
1016
+
1017
+ $imgs = ( ! empty($this->options['featured_delim']) ) ? str_getcsv($featured_images[$i], $this->options['featured_delim']) : explode("\n", $featured_images[$i]);
1018
+
1019
+ if (!empty($imgs)) {
1020
 
1021
+ if ( $this->options['set_image_meta_data'] ){
1022
+ $img_titles = ( ! empty($this->options['image_meta_title_delim']) ) ? str_getcsv($image_meta_titles[$i], $this->options['image_meta_title_delim']) : explode("\n", $image_meta_titles[$i]);
1023
+ $img_captions = ( ! empty($this->options['image_meta_caption_delim']) ) ? str_getcsv($image_meta_captions[$i], $this->options['image_meta_caption_delim']) : explode("\n", $image_meta_captions[$i]);
1024
+ $img_alts = ( ! empty($this->options['image_meta_alt_delim']) ) ? str_getcsv($image_meta_alts[$i], $this->options['image_meta_alt_delim']) : explode("\n", $image_meta_alts[$i]);
1025
+ $img_descriptions = ( ! empty($this->options['image_meta_description_delim']) ) ? str_getcsv($image_meta_descriptions[$i], $this->options['image_meta_description_delim']) : explode("\n", $image_meta_descriptions[$i]);
1026
+ }
1027
 
1028
+ foreach ($imgs as $k => $img_url) { if (empty($img_url)) continue;
 
1029
 
1030
+ $url = str_replace(" ", "%20", trim($img_url));
1031
+ $bn = preg_replace('/[\\?|&].*/', '', basename($url));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1032
 
1033
+ $img_ext = pmxi_getExtensionFromStr($url);
1034
+ $default_extension = pmxi_getExtension($bn);
1035
+
1036
+ if ($img_ext == "")
1037
+ $img_ext = pmxi_get_remote_image_ext($url);
1038
+
1039
+ // generate local file name
1040
+ $image_name = urldecode(($this->options['auto_rename_images'] and "" != $auto_rename_images[$i]) ? sanitize_file_name(($img_ext) ? str_replace("." . $default_extension, "", $auto_rename_images[$i]) : $auto_rename_images[$i]) : sanitize_file_name((($img_ext) ? str_replace("." . $default_extension, "", $bn) : $bn))) . (("" != $img_ext) ? '.' . $img_ext : '');
1041
+
1042
+ // if wizard store image data to custom field
1043
+ $create_image = false;
1044
+ $download_image = true;
1045
+
1046
+ if (base64_decode($url, true) !== false){
1047
+ $img = @imagecreatefromstring(base64_decode($url));
1048
+ if($img)
1049
+ {
1050
+ $image_filename = md5(time()) . '.jpg';
1051
+ $image_filepath = $uploads['path'] . '/' . $image_filename;
1052
+ imagejpeg($img, $image_filepath);
1053
+ if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1054
+ $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));
1055
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1056
+ } else {
1057
+ $create_image = true;
1058
+ }
1059
+ }
1060
+ }
1061
+ else {
1062
 
1063
+ $image_filename = wp_unique_filename($uploads['path'], $image_name);
1064
+ $image_filepath = $uploads['path'] . '/' . $image_filename;
1065
+
1066
+ // keep existing and add newest images
1067
+ 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"){
1068
+
1069
+ $attachment_imgs = get_posts( array(
1070
+ 'post_type' => 'attachment',
1071
+ 'posts_per_page' => -1,
1072
+ 'post_parent' => $pid,
1073
+ ) );
1074
+
1075
+ if ( $attachment_imgs ) {
1076
+ foreach ( $attachment_imgs as $attachment_img ) {
1077
+ if ($attachment_img->guid == $uploads['url'] . '/' . $image_name){
1078
+ $download_image = false;
1079
+ $success_images = true;
1080
+ if ( ! has_post_thumbnail($pid) )
1081
+ set_post_thumbnail($pid, $attachment_img->ID);
1082
+ else
1083
+ $gallery_attachment_ids[] = $attachment_img->ID;
1084
+
1085
+ $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']));
1086
+ }
1087
+ }
1088
+ }
1089
 
 
 
 
1090
  }
1091
 
1092
+ if ($download_image){
 
 
1093
 
1094
+ // do not download images
1095
+ if ( ! $this->options['download_images'] ){
1096
 
1097
+ $image_filename = $image_name;
1098
+ $image_filepath = $uploads['path'] . '/' . $image_filename;
1099
+
1100
+ $existing_attachment = $this->wpdb->get_row( $this->wpdb->prepare( "SELECT * FROM " . $this->wpdb->prefix ."posts WHERE guid = '%s'", $uploads['url'] . '/' . $image_filename ) );
1101
+
1102
+ if ( ! empty($existing_attachment->ID) ){
1103
 
1104
+ $download_image = false;
1105
+ $create_image = false;
1106
 
1107
+ if ( ! has_post_thumbnail($pid) )
1108
+ set_post_thumbnail($pid, $existing_attachment->ID);
1109
+ else
1110
+ $gallery_attachment_ids[] = $existing_attachment->ID;
1111
 
1112
+ do_action( 'pmxi_gallery_image', $pid, $existing_attachment->ID, $image_filepath);
1113
 
1114
+ }
1115
+ else{
1116
+
1117
+ if ( @file_exists($image_filepath) ){
1118
+ $download_image = false;
1119
+ if( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1120
+ $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));
1121
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1122
+ @unlink($image_filepath);
1123
+ } else {
1124
+ $create_image = true;
1125
+ }
1126
  }
1127
  }
1128
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
1129
 
1130
+ if ($download_image){
1131
 
1132
  $request = get_file_curl($url, $image_filepath);
1133
 
1134
  if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1135
+ @unlink($image_filepath); // delete file since failed upload may result in empty file created
1136
+ } elseif( ($image_info = @getimagesize($image_filepath)) and in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
 
 
 
 
 
 
1137
  $create_image = true;
1138
+ }
1139
+
1140
+ if ( ! $create_image ){
1141
+
1142
+ $url = str_replace(" ", "%20", trim(pmxi_convert_encoding($img_url)));
1143
+
1144
+ $request = get_file_curl($url, $image_filepath);
1145
+
1146
+ if ( (is_wp_error($request) or $request === false) and ! @file_put_contents($image_filepath, @file_get_contents($url))) {
1147
+ $logger and call_user_func($logger, sprintf(__('<b>WARNING</b>: File %s cannot be saved locally as %s', 'pmxi_plugin'), $url, $image_filepath));
1148
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1149
+ @unlink($image_filepath); // delete file since failed upload may result in empty file created
1150
+ } elseif( ! ($image_info = @getimagesize($image_filepath)) or ! in_array($image_info[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) {
1151
+ $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));
1152
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1153
+ @unlink($image_filepath);
1154
+ } else {
1155
+ $create_image = true;
1156
+ }
1157
  }
1158
  }
1159
  }
1160
  }
 
1161
 
1162
+ if ($create_image){
1163
 
1164
+ $attachment = array(
1165
+ 'post_mime_type' => image_type_to_mime_type($image_info[2]),
1166
+ 'guid' => $uploads['url'] . '/' . $image_filename,
1167
+ 'post_title' => $image_filename,
1168
+ 'post_content' => '',
1169
+ 'post_author' => $post_author[$i],
1170
+ );
1171
+ if (($image_meta = wp_read_image_metadata($image_filepath))) {
1172
+ if (trim($image_meta['title']) && ! is_numeric(sanitize_title($image_meta['title'])))
1173
+ $attachment['post_title'] = $image_meta['title'];
1174
+ if (trim($image_meta['caption']))
1175
+ $attachment['post_content'] = $image_meta['caption'];
1176
+ }
1177
 
1178
+ $attid = ($this->options['is_fast_mode']) ? pmxi_insert_attachment($attachment, $image_filepath, $pid) : wp_insert_attachment($attachment, $image_filepath, $pid);
1179
 
1180
+ if (is_wp_error($attid)) {
1181
+ $logger and call_user_func($logger, __('<b>WARNING</b>', 'pmxi_plugin') . ': ' . $attid->get_error_message());
1182
+ $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1183
+ } else {
1184
+ // you must first include the image.php file
1185
+ // for the function wp_generate_attachment_metadata() to work
1186
+ require_once(ABSPATH . 'wp-admin/includes/image.php');
1187
+ wp_update_attachment_metadata($attid, wp_generate_attachment_metadata($attid, $image_filepath));
 
 
 
 
 
 
 
 
 
1188
 
1189
+ if ( $this->options['set_image_meta_data'] ){
1190
+ $update_attachment_meta = array();
1191
+ if ( ! empty($img_titles[$k]) ) $update_attachment_meta['post_title'] = $img_titles[$k];
1192
+ if ( ! empty($img_captions[$k]) ) $update_attachment_meta['post_excerpt'] = $img_captions[$k];
1193
+ if ( ! empty($img_descriptions[$k]) ) $update_attachment_meta['post_content'] = $img_descriptions[$k];
1194
+ if ( ! empty($img_alts[$k]) ) update_post_meta($attid, '_wp_attachment_image_alt', $img_alts[$k]);
1195
+
1196
+ if ( ! empty($update_attachment_meta)) $this->wpdb->update( $this->wpdb->posts, $update_attachment_meta, array('ID' => $attid) );
1197
+
1198
+ }
1199
+
1200
+ do_action( 'pmxi_gallery_image', $pid, $attid, $image_filepath);
1201
+
1202
+ $success_images = true;
1203
+ if ( ! has_post_thumbnail($pid) )
1204
+ set_post_thumbnail($pid, $attid);
1205
+ else
1206
+ $gallery_attachment_ids[] = $attid;
1207
  }
1208
+ }
1209
+ }
1210
+ }
1211
+ // Set product gallery images
1212
+ if ( $post_type == "product" and !empty($gallery_attachment_ids) )
1213
+ update_post_meta($pid, '_product_image_gallery', implode(',', $gallery_attachment_ids));
1214
+ // Create entry as Draft if no images are downloaded successfully
1215
+ if ( ! $success_images and "yes" == $this->options['create_draft'] ) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
1216
 
1217
+ } else {
1218
 
1219
+ // Create entry as Draft if no images are downloaded successfully
1220
+ if ( "yes" == $this->options['create_draft'] ) $this->wpdb->update( $this->wpdb->posts, array('post_status' => 'draft'), array('ID' => $pid) );
1221
+
1222
+ }
 
 
 
 
 
 
 
 
 
 
1223
  }
1224
  // [/featured image]
1225
 
1271
  $logger and PMXI_Plugin::$session['pmxi_import']['warnings'] = ++PMXI_Plugin::$session->data['pmxi_import']['warnings'];
1272
  } else {
1273
  wp_update_attachment_metadata($attach_id, wp_generate_attachment_metadata($attach_id, $attachment_filepath));
1274
+ do_action( 'pmxi_attachment_uploaded', $pid, $attach_id, $image_filepath);
1275
  }
1276
  }
1277
  }
1314
 
1315
  $parent_id = (!empty($single_tax['parent'])) ? pmxi_recursion_taxes($single_tax['parent'], $tx_name, $txes[$i], $key) : '';
1316
 
1317
+ $term = term_exists($single_tax['name'], $tx_name, (int)$parent_id);
1318
 
1319
  if ( empty($term) and !is_wp_error($term) ){
1320
+
1321
+ $term = term_exists(htmlspecialchars($single_tax['name']), $tx_name, (int)$parent_id);
1322
+ if ( empty($term) and !is_wp_error($term) ){
1323
+ $term_attr = array('parent'=> (!empty($parent_id)) ? $parent_id : 0);
1324
+ $term = wp_insert_term(
1325
+ $single_tax['name'], // the term
1326
+ $tx_name, // the taxonomy
1327
+ $term_attr
1328
+ );
1329
+ }
1330
  }
1331
 
1332
  if ( is_wp_error($term) ){
1405
 
1406
  $parent_id = (!empty($single_cat['parent'])) ? pmxi_recursion_taxes($single_cat['parent'], 'category', $cats[$i], $key) : '';
1407
 
1408
+ $term = term_exists($single_cat['name'], 'category', (int)$parent_id);
1409
+
1410
+ if ( empty($term) and ! is_wp_error($term) ){
1411
+
1412
+ $term = term_exists(htmlspecialchars($single_cat['name']), 'category', (int)$parent_id);
1413
+
1414
+ if ( empty($term) and ! is_wp_error($term) ){
1415
+
1416
+ $term = wp_insert_term(
1417
+ $single_cat['name'], // the term
1418
+ 'category', // the taxonomy
1419
+ array('parent' => ((!empty($parent_id)) ? (int)$parent_id : 0))
1420
+ );
1421
+
1422
+ }
1423
  }
1424
 
1425
  if ( is_wp_error($term) ){
1506
  'imported' => $created + $updated,
1507
  'created' => $created,
1508
  'updated' => $updated,
1509
+ 'skipped' => $skipped
 
1510
  ))->update();
1511
 
1512
  if ( ! $is_cron ){
1572
  // Delete posts from database
1573
  if (!empty($missing_ids) && is_array($missing_ids) and ! $this->options['is_update_missing_cf'] and ! $this->options['set_missing_to_draft']){
1574
 
1575
+ do_action('pmxi_delete_post', $missing_ids);
1576
+
1577
  $sql = "delete a,b,c
1578
  FROM ".$this->wpdb->posts." a
1579
  LEFT JOIN ".$this->wpdb->term_relationships." b ON ( a.ID = b.object_id )
1582
 
1583
  $this->wpdb->query(
1584
  $this->wpdb->prepare($sql, '')
1585
+ );
 
 
1586
  }
1587
 
1588
  }
plugin.php CHANGED
@@ -3,7 +3,7 @@
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.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.1.4');
32
 
33
  define('PMXI_EDITION', 'free');
34
 
@@ -96,6 +96,10 @@ final class PMXI_Plugin {
96
  return self::$instance;
97
  }
98
 
 
 
 
 
99
  /**
100
  * Common logic for requestin plugin info fields
101
  */
@@ -169,7 +173,7 @@ final class PMXI_Plugin {
169
  * @param string $rootDir Plugin root dir
170
  * @param string $pluginFilePath Plugin main file
171
  */
172
- protected function __construct() {
173
 
174
  $this->load_plugin_textdomain();
175
 
@@ -235,7 +239,7 @@ final class PMXI_Plugin {
235
  }
236
 
237
  // register admin page pre-dispatcher
238
- add_action('admin_init', array($this, '__adminInit'));
239
  add_action('admin_init', array($this, '_fix_options'));
240
 
241
  global $wpdb;
@@ -310,10 +314,55 @@ final class PMXI_Plugin {
310
  * pre-dispatching logic for admin page controllers
311
  */
312
  public function __adminInit() {
 
313
  $input = new PMXI_Input();
314
- $page = strtolower($input->getpost('page', ''));
 
315
  if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\w-]+)$%', $page)) {
316
- $this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
  }
318
  }
319
 
@@ -336,69 +385,31 @@ final class PMXI_Plugin {
336
  return ob_get_clean();
337
  }
338
 
 
 
 
339
  /**
340
  * Dispatch admin page: call corresponding controller based on get parameter `page`
341
  * The method is called twice: 1st time as handler `parse_header` action and then as admin menu item handler
342
  * @param string[optional] $page When $page set to empty string ealier buffered content is outputted, otherwise controller is called based on $page value
343
  */
344
  public function adminDispatcher($page = '', $action = 'index') {
345
- static $buffer = NULL;
346
- static $buffer_callback = NULL;
347
- if ('' === $page) {
348
- if ( ! is_null($buffer)) {
349
  echo '<div class="wrap">';
350
- echo $buffer;
351
  do_action('pmxi_action_after');
352
  echo '</div>';
353
- } elseif ( ! is_null($buffer_callback)) {
354
  echo '<div class="wrap">';
355
- call_user_func($buffer_callback);
356
  do_action('pmxi_action_after');
357
  echo '</div>';
358
  } else {
359
  throw new Exception('There is no previousely buffered content to display.');
360
  }
361
- } else {
362
- // capitalize prefix and first letters of class name parts
363
- if (function_exists('preg_replace_callback')){
364
- $controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"),str_replace('-', '_', $page));
365
- }
366
- else{
367
- $controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page));
368
- }
369
- $actionName = str_replace('-', '_', $action);
370
- if (method_exists($controllerName, $actionName)) {
371
- $this->_admin_current_screen = (object)array(
372
- 'id' => $controllerName,
373
- 'base' => $controllerName,
374
- 'action' => $actionName,
375
- 'is_ajax' => isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest',
376
- 'is_network' => is_network_admin(),
377
- 'is_user' => is_user_admin(),
378
- );
379
- add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
380
- add_filter('admin_body_class', create_function('', 'return "' . PMXI_Plugin::PREFIX . 'plugin";'));
381
-
382
- $controller = new $controllerName();
383
- if ( ! $controller instanceof PMXI_Controller_Admin) {
384
- throw new Exception("Administration page `$page` matches to a wrong controller type.");
385
- }
386
-
387
- if ($this->_admin_current_screen->is_ajax) { // ajax request
388
- $controller->$action();
389
- do_action('pmxi_action_after');
390
- die(); // stop processing since we want to output only what controller is randered, nothing in addition
391
- } elseif ( ! $controller->isInline) {
392
- ob_start();
393
- $controller->$action();
394
- $buffer = ob_get_clean();
395
- } else {
396
- $buffer_callback = array($controller, $action);
397
- }
398
- } else { // redirect to dashboard if requested page and/or action don't exist
399
- wp_redirect(admin_url()); die();
400
- }
401
- }
402
  }
403
 
404
  public function replace_callback($matches){
@@ -620,8 +631,8 @@ final class PMXI_Plugin {
620
  'featured_delim' => '',
621
  'atch_delim' => ',',
622
  'post_taxonomies' => array(),
623
- 'parent' => '',
624
- 'order' => '0',
625
  'status' => 'publish',
626
  'page_template' => 'default',
627
  'page_taxonomies' => array(),
@@ -671,6 +682,7 @@ final class PMXI_Plugin {
671
  'update_images_logic' => 'full_update',
672
  'is_update_dates' => 1,
673
  'is_update_menu_order' => 1,
 
674
  'is_update_parent' => 1,
675
  'is_keep_attachments' => 0,
676
  'is_keep_imgs' => 0,
@@ -733,7 +745,7 @@ final class PMXI_Plugin {
733
  }
734
 
735
  public static function is_ajax(){
736
- return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') ? true : false ;
737
  }
738
 
739
  }
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.5
7
  Author: Soflyy
8
  */
9
 
28
  */
29
  define('PMXI_PREFIX', 'pmxi_');
30
 
31
+ define('PMXI_VERSION', '3.1.5');
32
 
33
  define('PMXI_EDITION', 'free');
34
 
96
  return self::$instance;
97
  }
98
 
99
+ static public function getEddName(){
100
+ return 'WP All Import';
101
+ }
102
+
103
  /**
104
  * Common logic for requestin plugin info fields
105
  */
173
  * @param string $rootDir Plugin root dir
174
  * @param string $pluginFilePath Plugin main file
175
  */
176
+ protected function __construct() {
177
 
178
  $this->load_plugin_textdomain();
179
 
239
  }
240
 
241
  // register admin page pre-dispatcher
242
+ add_action('admin_init', array($this, '__adminInit'), 1);
243
  add_action('admin_init', array($this, '_fix_options'));
244
 
245
  global $wpdb;
314
  * pre-dispatching logic for admin page controllers
315
  */
316
  public function __adminInit() {
317
+
318
  $input = new PMXI_Input();
319
+ $page = strtolower($input->getpost('page', ''));
320
+
321
  if (preg_match('%^' . preg_quote(str_replace('_', '-', self::PREFIX), '%') . '([\w-]+)$%', $page)) {
322
+ //$this->adminDispatcher($page, strtolower($input->getpost('action', 'index')));
323
+
324
+ $action = strtolower($input->getpost('action', 'index'));
325
+
326
+ // capitalize prefix and first letters of class name parts
327
+ if (function_exists('preg_replace_callback')){
328
+ $controllerName = preg_replace_callback('%(^' . preg_quote(self::PREFIX, '%') . '|_).%', array($this, "replace_callback"),str_replace('-', '_', $page));
329
+ }
330
+ else{
331
+ $controllerName = preg_replace('%(^' . preg_quote(self::PREFIX, '%') . '|_).%e', 'strtoupper("$0")', str_replace('-', '_', $page));
332
+ }
333
+ $actionName = str_replace('-', '_', $action);
334
+ if (method_exists($controllerName, $actionName)) {
335
+ $this->_admin_current_screen = (object)array(
336
+ 'id' => $controllerName,
337
+ 'base' => $controllerName,
338
+ 'action' => $actionName,
339
+ 'is_ajax' => strpos($_SERVER["HTTP_ACCEPT"], 'json') !== false,
340
+ 'is_network' => is_network_admin(),
341
+ 'is_user' => is_user_admin(),
342
+ );
343
+ add_filter('current_screen', array($this, 'getAdminCurrentScreen'));
344
+ add_filter('admin_body_class', create_function('', 'return "' . PMXI_Plugin::PREFIX . 'plugin";'));
345
+
346
+ $controller = new $controllerName();
347
+ if ( ! $controller instanceof PMXI_Controller_Admin) {
348
+ throw new Exception("Administration page `$page` matches to a wrong controller type.");
349
+ }
350
+
351
+ if ($this->_admin_current_screen->is_ajax) { // ajax request
352
+ $controller->$action();
353
+ do_action('pmxi_action_after');
354
+ die(); // stop processing since we want to output only what controller is randered, nothing in addition
355
+ } elseif ( ! $controller->isInline) {
356
+ @ob_start();
357
+ $controller->$action();
358
+ self::$buffer = @ob_get_clean();
359
+ } else {
360
+ self::$buffer_callback = array($controller, $action);
361
+ }
362
+ } else { // redirect to dashboard if requested page and/or action don't exist
363
+ wp_redirect(admin_url()); die();
364
+ }
365
+
366
  }
367
  }
368
 
385
  return ob_get_clean();
386
  }
387
 
388
+ static $buffer = NULL;
389
+ static $buffer_callback = NULL;
390
+
391
  /**
392
  * Dispatch admin page: call corresponding controller based on get parameter `page`
393
  * The method is called twice: 1st time as handler `parse_header` action and then as admin menu item handler
394
  * @param string[optional] $page When $page set to empty string ealier buffered content is outputted, otherwise controller is called based on $page value
395
  */
396
  public function adminDispatcher($page = '', $action = 'index') {
397
+
398
+ if ('' === $page) {
399
+ if ( ! is_null(self::$buffer)) {
 
400
  echo '<div class="wrap">';
401
+ echo self::$buffer;
402
  do_action('pmxi_action_after');
403
  echo '</div>';
404
+ } elseif ( ! is_null(self::$buffer_callback)) {
405
  echo '<div class="wrap">';
406
+ call_user_func(self::$buffer_callback);
407
  do_action('pmxi_action_after');
408
  echo '</div>';
409
  } else {
410
  throw new Exception('There is no previousely buffered content to display.');
411
  }
412
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
  }
414
 
415
  public function replace_callback($matches){
631
  'featured_delim' => '',
632
  'atch_delim' => ',',
633
  'post_taxonomies' => array(),
634
+ 'parent' => 0,
635
+ 'order' => 0,
636
  'status' => 'publish',
637
  'page_template' => 'default',
638
  'page_taxonomies' => array(),
682
  'update_images_logic' => 'full_update',
683
  'is_update_dates' => 1,
684
  'is_update_menu_order' => 1,
685
+ 'is_update_post_author' => 1,
686
  'is_update_parent' => 1,
687
  'is_keep_attachments' => 0,
688
  'is_keep_imgs' => 0,
745
  }
746
 
747
  public static function is_ajax(){
748
+ return strpos($_SERVER["HTTP_ACCEPT"], 'json') !== false;
749
  }
750
 
751
  }
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: soflyy
3
  Tags: wordpress, xml, csv, datafeed, import
4
  Requires at least: 3.6.1
5
- Tested up to: 3.9.1
6
- Stable tag: 3.1.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
 
@@ -87,6 +87,14 @@ Does it work with special character encoding like Hebrew, Arabic, Chinese, etc?
87
 
88
  == Changelog ==
89
 
 
 
 
 
 
 
 
 
90
  = 3.1.4 =
91
  * changed support email
92
 
2
  Contributors: soflyy
3
  Tags: wordpress, xml, csv, datafeed, import
4
  Requires at least: 3.6.1
5
+ Tested up to: 4.0
6
+ Stable tag: 3.1.5
7
 
8
  WP All Import is an extremely powerful plugin that makes it easy to import any XML or CSV file to WordPress.
9
 
87
 
88
  == Changelog ==
89
 
90
+ = 3.1.5 =
91
+ * fixed pmxi_delete_post action
92
+ * fixed import menu order & post parent for pages
93
+ * fixed import log for continue import feature
94
+ * added is update author option
95
+ * fixed post formats
96
+ * fixed UTC dates on manage imports page
97
+
98
  = 3.1.4 =
99
  * changed support email
100
 
static/js/admin.js CHANGED
@@ -151,7 +151,7 @@
151
  $modal.addClass('loading').empty().dialog('open').dialog('option', 'position', 'center');
152
  if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
153
  $.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
154
- $modal.removeClass('loading').html(response).dialog('option', 'position', 'center');
155
  var $tag = $('.tag');
156
  var tagno = parseInt($tag.find('input[name="tagno"]').val());
157
  $preview.find('.navigation a').live('click', function () {
@@ -159,7 +159,7 @@
159
  $tag.addClass('loading').css('opacity', 0.7);
160
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
161
  var $indicator = $('<span />').insertBefore($tag);
162
- $tag.replaceWith(data);
163
  $indicator.next().tag().prevObject.remove();
164
  if ($('#variations_xpath').length){
165
  $('#variations_xpath').data('checkedValue', '').change();
@@ -174,7 +174,7 @@
174
  $preview.find('input[name="tagno"]').die();
175
  $preview.find('.navigation a').die('click');
176
  $form.find('.preview').click();
177
- }, 'html');
178
  return false;
179
  });
180
  $preview.find('input[name="tagno"]').live('change', function () {
@@ -182,7 +182,7 @@
182
  $tag.addClass('loading').css('opacity', 0.7);
183
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
184
  var $indicator = $('<span />').insertBefore($tag);
185
- $tag.replaceWith(data);
186
  $indicator.next().tag().prevObject.remove();
187
  if ($('#variations_xpath').length){
188
  $('#variations_xpath').data('checkedValue', '').change();
@@ -197,7 +197,7 @@
197
  $preview.find('input[name="tagno"]').die();
198
  $preview.find('.navigation a').die('click');
199
  $form.find('.preview').click();
200
- }, 'html');
201
  return false;
202
  });
203
 
@@ -206,7 +206,7 @@
206
  $tag.addClass('loading').css('opacity', 0.7);
207
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: 0}, function (data) {
208
  var $indicator = $('<span />').insertBefore($tag);
209
- $tag.replaceWith(data);
210
  $indicator.next().tag().prevObject.remove();
211
  if ($('.layout').length){
212
  var offset = $('.layout').offset();
@@ -216,9 +216,9 @@
216
  $('.tag').css({'top':''});
217
  }
218
  set_encoding = false;
219
- }, 'html');
220
  }
221
- });
222
  return false;
223
  });
224
  $form.find('.set_encoding').live('click', function(e){
@@ -665,7 +665,7 @@
665
  $tag.addClass('loading').css('opacity', 0.7);
666
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
667
  var $indicator = $('<span />').insertBefore($tag);
668
- $tag.replaceWith(data);
669
  $indicator.next().tag().prevObject.remove();
670
  if ($('#variations_xpath').length){
671
  $('#variations_xpath').data('checkedValue', '').change();
@@ -677,7 +677,7 @@
677
  else
678
  $('.tag').css({'top':''});
679
  }
680
- }, 'html');
681
  return false;
682
  });
683
  $tag.find('input[name="tagno"]').live('change', function () {
@@ -686,7 +686,7 @@
686
  $tag.addClass('loading').css('opacity', 0.7);
687
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
688
  var $indicator = $('<span />').insertBefore($tag);
689
- $tag.replaceWith(data);
690
  $indicator.next().tag().prevObject.remove();
691
  if ($('#variations_xpath').length){
692
  $('#variations_xpath').data('checkedValue', '').change();
@@ -698,7 +698,7 @@
698
  else
699
  $('.tag').css({'top':''});
700
  }
701
- }, 'html');
702
  return false;
703
  });
704
  });
@@ -932,11 +932,11 @@
932
 
933
  $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: key}, function (data) {
934
 
935
- parent_fieldset.find('input[name^=custom_name]:visible:last').after(data);
936
 
937
  parent_fieldset.removeClass('loading');
938
 
939
- }, 'html');
940
  }
941
 
942
  });
@@ -947,9 +947,9 @@
947
  $ths.parents('fieldset:first').addClass('loading');
948
  $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: $ths.val()}, function (data) {
949
  $ths.parents('td:first').find('.ex_values').remove();
950
- $ths.after(data);
951
  $ths.parents('fieldset:first').removeClass('loading');
952
- }, 'html');
953
 
954
  });
955
 
@@ -1037,5 +1037,5 @@
1037
  if ($('#pmxi_tabs').length && parseInt($('#pmxi_tabs').find('.is_disabled').val()) ) {
1038
  $('form.options').find('input, select, textarea').attr('disabled','disabled');
1039
  }
1040
-
1041
  });})(jQuery);
151
  $modal.addClass('loading').empty().dialog('open').dialog('option', 'position', 'center');
152
  if (tinyMCE != undefined) tinyMCE.triggerSave(false, false);
153
  $.post('admin.php?page=pmxi-admin-import&action=preview', $form.serialize(), function (response) {
154
+ $modal.removeClass('loading').html(response.html).dialog('option', 'position', 'center');
155
  var $tag = $('.tag');
156
  var tagno = parseInt($tag.find('input[name="tagno"]').val());
157
  $preview.find('.navigation a').live('click', function () {
159
  $tag.addClass('loading').css('opacity', 0.7);
160
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
161
  var $indicator = $('<span />').insertBefore($tag);
162
+ $tag.replaceWith(data.html);
163
  $indicator.next().tag().prevObject.remove();
164
  if ($('#variations_xpath').length){
165
  $('#variations_xpath').data('checkedValue', '').change();
174
  $preview.find('input[name="tagno"]').die();
175
  $preview.find('.navigation a').die('click');
176
  $form.find('.preview').click();
177
+ }, 'json');
178
  return false;
179
  });
180
  $preview.find('input[name="tagno"]').live('change', function () {
182
  $tag.addClass('loading').css('opacity', 0.7);
183
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
184
  var $indicator = $('<span />').insertBefore($tag);
185
+ $tag.replaceWith(data.html);
186
  $indicator.next().tag().prevObject.remove();
187
  if ($('#variations_xpath').length){
188
  $('#variations_xpath').data('checkedValue', '').change();
197
  $preview.find('input[name="tagno"]').die();
198
  $preview.find('.navigation a').die('click');
199
  $form.find('.preview').click();
200
+ }, 'json');
201
  return false;
202
  });
203
 
206
  $tag.addClass('loading').css('opacity', 0.7);
207
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: 0}, function (data) {
208
  var $indicator = $('<span />').insertBefore($tag);
209
+ $tag.replaceWith(data.html);
210
  $indicator.next().tag().prevObject.remove();
211
  if ($('.layout').length){
212
  var offset = $('.layout').offset();
216
  $('.tag').css({'top':''});
217
  }
218
  set_encoding = false;
219
+ }, 'json');
220
  }
221
+ }, 'json');
222
  return false;
223
  });
224
  $form.find('.set_encoding').live('click', function(e){
665
  $tag.addClass('loading').css('opacity', 0.7);
666
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
667
  var $indicator = $('<span />').insertBefore($tag);
668
+ $tag.replaceWith(data.html);
669
  $indicator.next().tag().prevObject.remove();
670
  if ($('#variations_xpath').length){
671
  $('#variations_xpath').data('checkedValue', '').change();
677
  else
678
  $('.tag').css({'top':''});
679
  }
680
+ }, 'json');
681
  return false;
682
  });
683
  $tag.find('input[name="tagno"]').live('change', function () {
686
  $tag.addClass('loading').css('opacity', 0.7);
687
  $.post('admin.php?page=pmxi-admin-import&action=tag', {tagno: tagno}, function (data) {
688
  var $indicator = $('<span />').insertBefore($tag);
689
+ $tag.replaceWith(data.html);
690
  $indicator.next().tag().prevObject.remove();
691
  if ($('#variations_xpath').length){
692
  $('#variations_xpath').data('checkedValue', '').change();
698
  else
699
  $('.tag').css({'top':''});
700
  }
701
+ }, 'json');
702
  return false;
703
  });
704
  });
932
 
933
  $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: key}, function (data) {
934
 
935
+ parent_fieldset.find('input[name^=custom_name]:visible:last').after(data.html);
936
 
937
  parent_fieldset.removeClass('loading');
938
 
939
+ }, 'json');
940
  }
941
 
942
  });
947
  $ths.parents('fieldset:first').addClass('loading');
948
  $.post('admin.php?page=pmxi-admin-settings&action=meta_values', {key: $ths.val()}, function (data) {
949
  $ths.parents('td:first').find('.ex_values').remove();
950
+ $ths.after(data.html);
951
  $ths.parents('fieldset:first').removeClass('loading');
952
+ }, 'json');
953
 
954
  });
955
 
1037
  if ($('#pmxi_tabs').length && parseInt($('#pmxi_tabs').find('.is_disabled').val()) ) {
1038
  $('form.options').find('input, select, textarea').attr('disabled','disabled');
1039
  }
1040
+
1041
  });})(jQuery);
static/js/pmxi.js CHANGED
@@ -8,7 +8,7 @@
8
  $(this).parents('div.updated:first').slideUp();
9
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss', {dismiss: true}, function (data) {
10
 
11
- }, 'html');
12
  });
13
 
14
  $('#dismiss_manage_top').click(function(){
@@ -16,7 +16,7 @@
16
  $(this).parents('div.updated:first').slideUp();
17
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_top', {dismiss: true}, function (data) {
18
 
19
- }, 'html');
20
 
21
  });
22
 
@@ -25,8 +25,9 @@
25
  $(this).parents('div.updated_bottom:first').slideUp();
26
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_bottom', {dismiss: true}, function (data) {
27
 
28
- }, 'html');
29
 
30
  });
31
 
 
32
  });})(jQuery);
8
  $(this).parents('div.updated:first').slideUp();
9
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss', {dismiss: true}, function (data) {
10
 
11
+ }, 'json');
12
  });
13
 
14
  $('#dismiss_manage_top').click(function(){
16
  $(this).parents('div.updated:first').slideUp();
17
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_top', {dismiss: true}, function (data) {
18
 
19
+ }, 'json');
20
 
21
  });
22
 
25
  $(this).parents('div.updated_bottom:first').slideUp();
26
  $.post('admin.php?page=pmxi-admin-settings&action=dismiss_manage_bottom', {dismiss: true}, function (data) {
27
 
28
+ }, 'json');
29
 
30
  });
31
 
32
+
33
  });})(jQuery);
views/admin/cron/index.php DELETED
@@ -1,2 +0,0 @@
1
- <h2><?php _e('WP All Import Scheduled Imports', 'pmxi_plugin') ?></h2>
2
-
 
 
views/admin/import/index.php CHANGED
@@ -27,6 +27,7 @@ $l10n = array(
27
  var plugin_url = '<?php echo PMXI_ROOT_URL; ?>';
28
  var swfuploadL10n = <?php echo json_encode($l10n); ?>;
29
  </script>
 
30
  <table class="layout pmxi_step_1">
31
  <tr>
32
  <td class="left">
@@ -49,7 +50,8 @@ $l10n = array(
49
  <?php do_action('pmxi_choose_file_header'); ?>
50
  <form method="post" class="choose-file 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') ?>
 
53
  <div class="file-type-container">
54
  <h3>
55
  <input type="radio" id="type_upload" name="type" value="upload" checked="checked" />
@@ -73,11 +75,11 @@ $l10n = array(
73
  <label for="type_url"><?php _e('Download File From URL', 'pmxi_plugin') ?></label>
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" />
@@ -102,7 +104,7 @@ $l10n = array(
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>
105
- <div id="url_upload_status"></div>
106
  <p class="submit-buttons">
107
  <input type="hidden" name="is_submitted" value="1" />
108
  <?php wp_nonce_field('choose-file', '_wpnonce_choose-file') ?>
27
  var plugin_url = '<?php echo PMXI_ROOT_URL; ?>';
28
  var swfuploadL10n = <?php echo json_encode($l10n); ?>;
29
  </script>
30
+
31
  <table class="layout pmxi_step_1">
32
  <tr>
33
  <td class="left">
50
  <?php do_action('pmxi_choose_file_header'); ?>
51
  <form method="post" class="choose-file enter-submit" enctype="multipart/form-data" autocomplete="off">
52
  <input type="hidden" name="is_submitted" value="1" />
53
+ <?php wp_nonce_field('upload-xml', '_wpnonce_upload-xml') ?>
54
+
55
  <div class="file-type-container">
56
  <h3>
57
  <input type="radio" id="type_upload" name="type" value="upload" checked="checked" />
75
  <label for="type_url"><?php _e('Download File From URL', 'pmxi_plugin') ?></label>
76
  </h3>
77
  <div class="file-type-options">
78
+ <input type="text" class="regular-text" name="url" value="" disabled="disabled"/>
79
  <p>To have the option to set up a cron-based recurring import, specify the URL to your file.</p>
80
  <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>
81
  </div>
82
+ </div>
83
  <div class="file-type-container">
84
  <h3>
85
  <input type="radio" id="type_file" name="type" value="file" />
104
  <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>
105
  </div>
106
  </div>
107
+ <div id="url_upload_status"></div>
108
  <p class="submit-buttons">
109
  <input type="hidden" name="is_submitted" value="1" />
110
  <?php wp_nonce_field('choose-file', '_wpnonce_choose-file') ?>
views/admin/import/options.php CHANGED
@@ -129,7 +129,7 @@
129
  </div>
130
  <?php if ($isWizard or $this->isTemplateEdit): ?>
131
  <div class="right options">
132
- <?php $this->tag() ?>
133
  </div>
134
  <?php endif ?>
135
  </div>
129
  </div>
130
  <?php if ($isWizard or $this->isTemplateEdit): ?>
131
  <div class="right options">
132
+ <?php $this->tag( false ); ?>
133
  </div>
134
  <?php endif ?>
135
  </div>
views/admin/import/options/_custom_fields_template.php CHANGED
@@ -2,7 +2,7 @@
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>
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>
views/admin/import/options/_main_options_template.php CHANGED
@@ -65,7 +65,7 @@
65
  <div class="col3">
66
  <h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
67
  <div>
68
- <?php $post_formats = get_terms( 'post_format' , array('hide_empty' => false)); ?>
69
 
70
  <div class="input">
71
  <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"' : '' ?> />
@@ -73,12 +73,12 @@
73
  </div>
74
 
75
  <?php
76
- if ( ! empty($post_formats) ){
77
- foreach ($post_formats as $post_format) {
78
  ?>
79
  <div class="input">
80
- <input type="radio" id="post_format_<?php echo $post_format->slug . "_" . $entry; ?>" name="post_format" value="<?php echo $post_format->name; ?>" <?php echo $post_format->name == $post['post_format'] ? 'checked="checked"' : '' ?> />
81
- <label for="post_format_<?php echo $post_format->slug . "_" . $entry; ?>"><?php _e( $post_format->name, 'pmxi_plugin') ?></label>
82
  </div>
83
  <?php
84
  }
65
  <div class="col3">
66
  <h3><?php _e('Post Format', 'pmxi_plugin') ?></h3>
67
  <div>
68
+ <?php $post_formats = get_theme_support( 'post-formats' ); ?>
69
 
70
  <div class="input">
71
  <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"' : '' ?> />
73
  </div>
74
 
75
  <?php
76
+ if ( ! empty($post_formats[0]) ){
77
+ foreach ($post_formats[0] as $post_format) {
78
  ?>
79
  <div class="input">
80
+ <input type="radio" id="post_format_<?php echo $post_format . "_" . $entry; ?>" name="post_format" value="<?php echo $post_format; ?>" <?php echo $post_format == $post['post_format'] ? 'checked="checked"' : '' ?> />
81
+ <label for="post_format_<?php echo $post_format . "_" . $entry; ?>"><?php _e( ucfirst($post_format), 'pmxi_plugin') ?></label>
82
  </div>
83
  <?php
84
  }
views/admin/import/options/_reimport_template.php CHANGED
@@ -103,6 +103,11 @@
103
  <input type="checkbox" id="is_update_title_<?php echo $entry; ?>" name="is_update_title" value="1" <?php echo $post['is_update_title'] ? 'checked="checked"': '' ?> />
104
  <label for="is_update_title_<?php echo $entry; ?>"><?php _e('Title', 'pmxi_plugin') ?></label>
105
  </div>
 
 
 
 
 
106
  <div class="input">
107
  <input type="hidden" name="is_update_slug" value="0" />
108
  <input type="checkbox" id="is_update_slug_<?php echo $entry; ?>" name="is_update_slug" value="1" <?php echo $post['is_update_slug'] ? 'checked="checked"': '' ?> />
103
  <input type="checkbox" id="is_update_title_<?php echo $entry; ?>" name="is_update_title" value="1" <?php echo $post['is_update_title'] ? 'checked="checked"': '' ?> />
104
  <label for="is_update_title_<?php echo $entry; ?>"><?php _e('Title', 'pmxi_plugin') ?></label>
105
  </div>
106
+ <div class="input">
107
+ <input type="hidden" name="is_update_post_author" value="0" />
108
+ <input type="checkbox" id="is_update_post_author_<?php echo $entry; ?>" name="is_update_post_author" value="1" <?php echo $post['is_update_post_author'] ? 'checked="checked"': '' ?> />
109
+ <label for="is_update_post_author_<?php echo $entry; ?>"><?php _e('Author', 'pmxi_plugin') ?></label>
110
+ </div>
111
  <div class="input">
112
  <input type="hidden" name="is_update_slug" value="0" />
113
  <input type="checkbox" id="is_update_slug_<?php echo $entry; ?>" name="is_update_slug" value="1" <?php echo $post['is_update_slug'] ? 'checked="checked"': '' ?> />
views/admin/import/template.php CHANGED
@@ -105,7 +105,7 @@
105
  <?php if ($this->isWizard or $this->isTemplateEdit): ?>
106
  <td class="right template-sidebar">
107
  <div style="position:relative;">
108
- <?php $this->tag() ?>
109
  </div>
110
  </td>
111
  <?php endif ?>
105
  <?php if ($this->isWizard or $this->isTemplateEdit): ?>
106
  <td class="right template-sidebar">
107
  <div style="position:relative;">
108
+ <?php $this->tag( false ); ?>
109
  </div>
110
  </td>
111
  <?php endif ?>
views/admin/manage/index.php CHANGED
@@ -152,7 +152,7 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
152
  <?php if ('0000-00-00 00:00:00' == $item['first_import']): ?>
153
  <em>never</em>
154
  <?php else: ?>
155
- <?php echo mysql2date(__('Y/m/d g:i a', 'pmxi_plugin'), $item['first_import']) ?>
156
  <?php endif ?>
157
  </td>
158
  <?php
@@ -163,26 +163,11 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
163
  <?php if ('0000-00-00 00:00:00' == $item['registered_on']): ?>
164
  <em>never</em>
165
  <?php else: ?>
166
- <?php echo mysql2date(__('Y/m/d g:i a', 'pmxi_plugin'), $item['registered_on']) ?>
167
  <?php endif ?>
168
  </td>
169
  <?php
170
- break;
171
- case 'next_import':
172
- ?>
173
- <td>
174
- <?php if ('0000-00-00 00:00:00' == $item['registered_on'] or empty($item['scheduled'])): ?>
175
- <em>never</em>
176
- <?php
177
- else:
178
- $task = new _PMXI_Import_Record_Cron_Parser($item['scheduled']);
179
- $task_date = $task->getNextRunDate();
180
- echo mysql2date(__('Y/m/d g:i a', 'pmxi_plugin'), $task_date->format('Y-m-d H:i:s'));
181
- endif;
182
- ?>
183
- </td>
184
- <?php
185
- break;
186
  case 'name':
187
  ?>
188
  <td>
@@ -315,6 +300,7 @@ $columns = apply_filters('pmxi_manage_imports_columns', $columns);
315
  </div>
316
  </div>
317
  <div class="clear"></div>
 
318
  <?php
319
  // notify user
320
  if (!PMXI_Plugin::getInstance()->getOption('dismiss_manage_bottom')) {
152
  <?php if ('0000-00-00 00:00:00' == $item['first_import']): ?>
153
  <em>never</em>
154
  <?php else: ?>
155
+ <?php echo get_date_from_gmt( $item['first_import'], 'Y/m/d g:i a'); ?>
156
  <?php endif ?>
157
  </td>
158
  <?php
163
  <?php if ('0000-00-00 00:00:00' == $item['registered_on']): ?>
164
  <em>never</em>
165
  <?php else: ?>
166
+ <?php echo get_date_from_gmt( $item['registered_on'], 'Y/m/d g:i a' ); ?>
167
  <?php endif ?>
168
  </td>
169
  <?php
170
+ break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
171
  case 'name':
172
  ?>
173
  <td>
300
  </div>
301
  </div>
302
  <div class="clear"></div>
303
+
304
  <?php
305
  // notify user
306
  if (!PMXI_Plugin::getInstance()->getOption('dismiss_manage_bottom')) {