Import Export WordPress Users and WooCommerce Customers - Version 1.0.5

Version Description

  • Fixed PHP 7.0 Compatibility Issue and warning WC_Logger::log was called incorrectly. WC_Logger::log was called with an invalid level 1
Download this release

Release Info

Developer xadapter
Plugin Icon 128x128 Import Export WordPress Users and WooCommerce Customers
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.4 to 1.0.5

customer-import-export.php CHANGED
@@ -6,7 +6,7 @@
6
  Description: Export and Import User/Customers details From and To your WordPress/WooCommerce.
7
  Author: XAdapter
8
  Author URI: http://www.xadapter.com/
9
- Version: 1.0.4
10
  Text Domain: wf_customer_import_export
11
  */
12
 
6
  Description: Export and Import User/Customers details From and To your WordPress/WooCommerce.
7
  Author: XAdapter
8
  Author URI: http://www.xadapter.com/
9
+ Version: 1.0.5
10
  Text Domain: wf_customer_import_export
11
  */
12
 
includes/importer/class-wf-csv-parser.php CHANGED
@@ -226,6 +226,6 @@ class WF_CSV_Parser {
226
 
227
  function hf_currency_formatter($price){
228
  $decimal_seperator = wc_get_price_decimal_separator();
229
- return ereg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
230
  }
231
  }
226
 
227
  function hf_currency_formatter($price){
228
  $decimal_seperator = wc_get_price_decimal_separator();
229
+ return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
230
  }
231
  }
includes/importer/class-wf-customerimpexpcsv-customer-import.php CHANGED
@@ -28,17 +28,32 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
28
  /**
29
  * Constructor
30
  */
31
- public function __construct() {
32
 
33
  // Check that the class exists before trying to use it
34
- if (class_exists('WC_Logger')) {
35
- $this->log = new WC_Logger();
36
- }
37
-
38
- $this->import_page = 'wordpress_hf_user_csv';
39
- $this->file_url_import_enabled = apply_filters('woocommerce_csv_product_file_url_import_enabled', true);
40
-
41
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
43
  /**
44
  * Registered callback function for the WordPress Importer
@@ -453,8 +468,8 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
453
 
454
  wp_suspend_cache_invalidation(true);
455
  if ($this->log) {
456
- $this->log->add('user-csv-import', '---');
457
- $this->log->add('user-csv-import', __('Processing users.', 'wf_customer_import_export'));
458
  }
459
  $merging = 1;
460
  $record_offset = 0;
@@ -472,7 +487,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
472
  $i++;
473
  }
474
  if ($this->log)
475
- $this->log->add('user-csv-import', __('Finished processing Users.', 'wf_customer_import_export'));
476
  wp_suspend_cache_invalidation(false);
477
  }
478
 
@@ -493,15 +508,15 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
493
  }
494
 
495
  if ($this->log) {
496
- $this->log->add('user-csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory);
497
- $this->log->add('user-csv-import', __('Parsing products CSV.', 'wf_customer_import_export'));
498
  }
499
  $this->parser = new WF_CSV_Parser('user');
500
 
501
 
502
  list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data($file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field);
503
  if ($this->log)
504
- $this->log->add('user-csv-import', __('Finished parsing products CSV.', 'wf_customer_import_export'));
505
 
506
  unset($import_data);
507
 
@@ -577,8 +592,8 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
577
  //$dry_run = isset( $_POST['dry_run'] ) && $_POST['dry_run'] ? true : false;
578
  $dry_run = 0; //mockup import and check weather the users can be imported without fail
579
  if ($this->log) {
580
- $this->log->add('user-csv-import', '---');
581
- $this->log->add('user-csv-import', __('Processing users.', 'wf_customer_import_export'));
582
  }
583
 
584
  if (empty($post['user_details']['user_email'])) {
@@ -602,7 +617,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
602
  $user_string = sprintf('<a href="%s">%s</a>', get_edit_user_link($user_id), $user_info->first_name);
603
  $this->add_import_result('skipped', __($usr_msg, 'wf_customer_import_export'),$user_id , $user_string, $user_id);
604
  if ($this->log)
605
- $this->log->add('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $usr_msg, 'wf_customer_import_export'), $user_id), true);
606
  unset($post);
607
  return;
608
  } else{
@@ -612,14 +627,14 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
612
  $this->errored++;
613
  $this->add_import_result('failed', __($user_id->get_error_message(), 'wf_customer_import_export'), 0, 'failed', 1);
614
  if ($this->log)
615
- $this->log->add('user-csv-import', sprintf(__('> Error inserting %s: %s', 'wf_customer_import_export'), 1, $user_id->get_error_message()), true);
616
  $skipped++;
617
  unset($post);
618
  return;
619
  } elseif (empty($user_id)) {
620
  $this->errored++;
621
  if ($this->log)
622
- $this->log->add('user-csv-import', sprintf(__('An error occurred with the customer information provided.', 'wf_customer_import_export')));
623
  $this->add_import_result('skipped', __('An error occurred with the customer information provided.', 'wf_customer_import_export'), 0, 'failed', 1);
624
  $skipped++;
625
  unset($post);
@@ -635,11 +650,11 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
635
 
636
  $this->add_import_result('imported', __($out_msg, 'wf_customer_import_export'), $user_id , $user_string, $user_id);
637
  if ($this->log)
638
- $this->log->add('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $out_msg, 'wf_customer_import_export'), $user_id), true);
639
  $this->imported++;
640
  if ($this->log) {
641
- $this->log->add('user-csv-import', sprintf(__('> Finished importing user %s', 'wf_customer_import_export'), $dry_run ? "" : $user_id ));
642
- $this->log->add('user-csv-import', __('Finished processing users.', 'wf_customer_import_export'));
643
  }
644
 
645
  unset($post);
28
  /**
29
  * Constructor
30
  */
31
+ public function __construct() {
32
 
33
  // Check that the class exists before trying to use it
34
+ if(WC()->version < '3.0')
35
+ {
36
+ $this->log = new WC_Logger();
37
+ }
38
+ else
39
+ {
40
+ $this->log = wc_get_logger();
41
+ }
42
+ $this->import_page = 'wordpress_hf_user_csv';
43
+ $this->file_url_import_enabled = apply_filters('woocommerce_csv_product_file_url_import_enabled', true);
44
+ }
45
+
46
+ public function hf_log_data_change ($content = 'user-csv-import',$data='')
47
+ {
48
+ if (WC()->version < '2.7.0')
49
+ {
50
+ $this->log->add($content,$data);
51
+ }else
52
+ {
53
+ $context = array( 'source' => $content );
54
+ $this->log->log("debug", $data ,$context);
55
+ }
56
+ }
57
 
58
  /**
59
  * Registered callback function for the WordPress Importer
468
 
469
  wp_suspend_cache_invalidation(true);
470
  if ($this->log) {
471
+ $this->hf_log_data_change('user-csv-import', '---');
472
+ $this->hf_log_data_change('user-csv-import', __('Processing users.', 'wf_customer_import_export'));
473
  }
474
  $merging = 1;
475
  $record_offset = 0;
487
  $i++;
488
  }
489
  if ($this->log)
490
+ $this->hf_log_data_change('user-csv-import', __('Finished processing Users.', 'wf_customer_import_export'));
491
  wp_suspend_cache_invalidation(false);
492
  }
493
 
508
  }
509
 
510
  if ($this->log) {
511
+ $this->hf_log_data_change('user-csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory);
512
+ $this->hf_log_data_change('user-csv-import', __('Parsing products CSV.', 'wf_customer_import_export'));
513
  }
514
  $this->parser = new WF_CSV_Parser('user');
515
 
516
 
517
  list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data($file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field);
518
  if ($this->log)
519
+ $this->hf_log_data_change('user-csv-import', __('Finished parsing products CSV.', 'wf_customer_import_export'));
520
 
521
  unset($import_data);
522
 
592
  //$dry_run = isset( $_POST['dry_run'] ) && $_POST['dry_run'] ? true : false;
593
  $dry_run = 0; //mockup import and check weather the users can be imported without fail
594
  if ($this->log) {
595
+ $this->hf_log_data_change('user-csv-import', '---');
596
+ $this->hf_log_data_change('user-csv-import', __('Processing users.', 'wf_customer_import_export'));
597
  }
598
 
599
  if (empty($post['user_details']['user_email'])) {
617
  $user_string = sprintf('<a href="%s">%s</a>', get_edit_user_link($user_id), $user_info->first_name);
618
  $this->add_import_result('skipped', __($usr_msg, 'wf_customer_import_export'),$user_id , $user_string, $user_id);
619
  if ($this->log)
620
+ $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $usr_msg, 'wf_customer_import_export'), $user_id), true);
621
  unset($post);
622
  return;
623
  } else{
627
  $this->errored++;
628
  $this->add_import_result('failed', __($user_id->get_error_message(), 'wf_customer_import_export'), 0, 'failed', 1);
629
  if ($this->log)
630
+ $this->hf_log_data_change('user-csv-import', sprintf(__('> Error inserting %s: %s', 'wf_customer_import_export'), 1, $user_id->get_error_message()), true);
631
  $skipped++;
632
  unset($post);
633
  return;
634
  } elseif (empty($user_id)) {
635
  $this->errored++;
636
  if ($this->log)
637
+ $this->hf_log_data_change('user-csv-import', sprintf(__('An error occurred with the customer information provided.', 'wf_customer_import_export')));
638
  $this->add_import_result('skipped', __('An error occurred with the customer information provided.', 'wf_customer_import_export'), 0, 'failed', 1);
639
  $skipped++;
640
  unset($post);
650
 
651
  $this->add_import_result('imported', __($out_msg, 'wf_customer_import_export'), $user_id , $user_string, $user_id);
652
  if ($this->log)
653
+ $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $out_msg, 'wf_customer_import_export'), $user_id), true);
654
  $this->imported++;
655
  if ($this->log) {
656
+ $this->hf_log_data_change('user-csv-import', sprintf(__('> Finished importing user %s', 'wf_customer_import_export'), $dry_run ? "" : $user_id ));
657
+ $this->hf_log_data_change('user-csv-import', __('Finished processing users.', 'wf_customer_import_export'));
658
  }
659
 
660
  unset($post);
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: xadapter, niwf, mujeebur
3
  Tags: CSV, Export, Import, WooCommerce Customers, Wordpress Users
4
  Requires at least: 3.0.1
5
  Tested up to: 4.8
6
- Stable tag: 1.0.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -78,6 +78,9 @@ Yes. You can import or export multiple user roles along with other basic user de
78
 
79
  == Changelog ==
80
 
 
 
 
81
  = 1.0.4 =
82
  * Marketing Content Change.
83
 
@@ -92,6 +95,9 @@ Yes. You can import or export multiple user roles along with other basic user de
92
 
93
  == Upgrade Notice ==
94
 
 
 
 
95
  = 1.0.4 =
96
  * Marketing Content Change.
97
 
3
  Tags: CSV, Export, Import, WooCommerce Customers, Wordpress Users
4
  Requires at least: 3.0.1
5
  Tested up to: 4.8
6
+ Stable tag: 1.0.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
78
 
79
  == Changelog ==
80
 
81
+ = 1.0.5 =
82
+ * Fixed PHP 7.0 Compatibility Issue and warning WC_Logger::log was called incorrectly. WC_Logger::log was called with an invalid level 1
83
+
84
  = 1.0.4 =
85
  * Marketing Content Change.
86
 
95
 
96
  == Upgrade Notice ==
97
 
98
+ = 1.0.5 =
99
+ * Fixed PHP 7.0 Compatibility Issue and Bug Fix
100
+
101
  = 1.0.4 =
102
  * Marketing Content Change.
103