Import Export WordPress Users and WooCommerce Customers - Version 1.2.9

Version Description

  • Tested OK with WC 3.6.3 and WP 5.2.1
Download this release

Release Info

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

Code changes from version 1.2.8 to 1.2.9

includes/exporter/class-wf-customerimpexpcsv-exporter.php CHANGED
@@ -15,14 +15,11 @@ class WF_CustomerImpExpCsv_Exporter {
15
  $export_limit = !empty($_POST['limit']) ? intval($_POST['limit']) : 999999999;
16
  $export_offset = !empty($_POST['offset']) ? intval($_POST['offset']) : 0;
17
  $csv_columns = include( 'data/data-wf-post-columns.php' );
18
-
19
  $user_columns_name = !empty($_POST['columns_name']) ? $_POST['columns_name'] : $csv_columns;
20
  $export_columns = !empty($_POST['columns']) ? $_POST['columns'] : array();
21
-
22
  $export_user_roles = !empty($_POST['user_roles']) ? $_POST['user_roles'] : array();
23
  $delimiter = !empty($_POST['delimiter']) ? $_POST['delimiter'] : ',';
24
 
25
-
26
  $wpdb->hide_errors();
27
  @set_time_limit(0);
28
  if (function_exists('apache_setenv'))
@@ -37,8 +34,6 @@ class WF_CustomerImpExpCsv_Exporter {
37
 
38
  $fp = fopen('php://output', 'w');
39
 
40
-
41
-
42
  $args = array(
43
  'fields' => 'ID', // exclude standard wp_users fields from get_users query -> get Only ID##
44
  'role__in' => $export_user_roles, //An array of role names. Matched users must have at least one of these roles. Default empty array.
@@ -58,9 +53,6 @@ class WF_CustomerImpExpCsv_Exporter {
58
  $row[] = $temp_head;
59
  }
60
 
61
-
62
-
63
-
64
  $row = array_map('WF_CustomerImpExpCsv_Exporter::wrap_column', $row);
65
  fwrite($fp, implode($delimiter, $row) . "\n");
66
  unset($row);
@@ -105,10 +97,8 @@ class WF_CustomerImpExpCsv_Exporter {
105
  */
106
  public static function get_customers_csv_row($id, $export_columns, $csv_columns) {
107
  $user = get_user_by('id', $id);
108
-
109
  $customer_data = array();
110
  foreach ($csv_columns as $key) {
111
-
112
  $customer_data[$key] = !empty($user->{$key}) ? maybe_serialize($user->{$key}) : '';
113
  }
114
  $user_roles = (!empty($user->roles)) ? $user->roles : array();
15
  $export_limit = !empty($_POST['limit']) ? intval($_POST['limit']) : 999999999;
16
  $export_offset = !empty($_POST['offset']) ? intval($_POST['offset']) : 0;
17
  $csv_columns = include( 'data/data-wf-post-columns.php' );
 
18
  $user_columns_name = !empty($_POST['columns_name']) ? $_POST['columns_name'] : $csv_columns;
19
  $export_columns = !empty($_POST['columns']) ? $_POST['columns'] : array();
 
20
  $export_user_roles = !empty($_POST['user_roles']) ? $_POST['user_roles'] : array();
21
  $delimiter = !empty($_POST['delimiter']) ? $_POST['delimiter'] : ',';
22
 
 
23
  $wpdb->hide_errors();
24
  @set_time_limit(0);
25
  if (function_exists('apache_setenv'))
34
 
35
  $fp = fopen('php://output', 'w');
36
 
 
 
37
  $args = array(
38
  'fields' => 'ID', // exclude standard wp_users fields from get_users query -> get Only ID##
39
  'role__in' => $export_user_roles, //An array of role names. Matched users must have at least one of these roles. Default empty array.
53
  $row[] = $temp_head;
54
  }
55
 
 
 
 
56
  $row = array_map('WF_CustomerImpExpCsv_Exporter::wrap_column', $row);
57
  fwrite($fp, implode($delimiter, $row) . "\n");
58
  unset($row);
97
  */
98
  public static function get_customers_csv_row($id, $export_columns, $csv_columns) {
99
  $user = get_user_by('id', $id);
 
100
  $customer_data = array();
101
  foreach ($csv_columns as $key) {
 
102
  $customer_data[$key] = !empty($user->{$key}) ? maybe_serialize($user->{$key}) : '';
103
  }
104
  $user_roles = (!empty($user->roles)) ? $user->roles : array();
includes/importer/class-wf-csv-parser.php CHANGED
@@ -4,231 +4,128 @@
4
  */
5
  class WF_CSV_Parser {
6
 
7
- var $row;
8
- var $post_type;
9
- var $posts = array();
10
- var $processed_posts = array();
11
- var $file_url_import_enabled = true;
12
- var $log;
13
- var $merged = 0;
14
- var $skipped = 0;
15
- var $imported = 0;
16
- var $errored = 0;
17
- var $id;
18
- var $file_url;
19
- var $delimiter;
20
- var $send_mail;
21
-
22
- /**
23
- * Constructor
24
- */
25
- public function __construct( $post_type = 'user' ) {
26
- $this->post_type = $post_type;
27
- $this->user_base_fields = array(
28
- 'ID' => 'ID',
29
- 'user_login' => 'user_login',
30
- 'user_pass' => 'user_pass',
31
- 'user_nicename' => 'user_nicename',
32
- 'user_email' => 'user_email',
33
- 'user_url' => 'user_url',
34
- 'user_registered' => 'user_registered',
35
- 'display_name' => 'display_name',
36
- 'first_name' => 'first_name',
37
- 'last_name' => 'last_name',
38
- 'user_status' => 'user_status',
39
- 'roles' => 'roles'
40
- );
41
-
42
- }
43
-
44
 
45
  /**
46
- * Format data from the csv file
47
- * @param string $data
48
- * @param string $enc
49
- * @return string
50
- */
51
- public function format_data_from_csv( $data, $enc ) {
52
- return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
53
- }
54
-
55
- /**
56
- * Parse the data
57
- * @param string $file [description]
58
- * @param string $delimiter [description]
59
- * @param array $mapping [description]
60
- * @param integer $start_pos [description]
61
- * @param integer $end_pos [description]
62
- * @return array
63
- */
64
- public function parse_data( $file, $delimiter, $mapping, $start_pos = 0, $end_pos = null, $eval_field ) {
65
- // Set locale
66
- $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
67
- if ( $enc )
68
- setlocale( LC_ALL, 'en_US.' . $enc );
69
- @ini_set( 'auto_detect_line_endings', true );
70
-
71
- $parsed_data = array();
72
- $raw_headers = array();
73
-
74
- // Put all CSV data into an associative array
75
- if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
76
-
77
- $header = fgetcsv( $handle, 0, $delimiter );
78
- if ( $start_pos != 0 )
79
- fseek( $handle, $start_pos );
80
-
81
- while ( ( $postmeta = fgetcsv( $handle, 0, $delimiter ) ) !== FALSE ) {
82
- $row = array();
83
-
84
- foreach ( $header as $key => $heading ) {
85
- $s_heading = strtolower($heading);
86
-
87
- // Check if this heading is being mapped to a different field
88
- if ( isset( $mapping[$s_heading] ) ) {
89
- if ( $mapping[$s_heading] == 'import_as_meta' ) {
90
-
91
- $s_heading = 'meta:' . $s_heading;
92
-
93
- }else {
94
- $s_heading = esc_attr( $mapping[$s_heading] );
95
- }
96
- }
97
- if( !empty($mapping) ){
98
- foreach ($mapping as $mkey => $mvalue) {
99
- if(trim($mvalue) === trim($heading)){
100
- $s_heading = $mkey;
101
- }
102
- }
103
- }
104
-
105
- if ( $s_heading == '' )
106
- continue;
107
-
108
- // Add the heading to the parsed data
109
- $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
110
 
111
- if(!empty($eval_field[strtolower($heading)]))
112
- $row[$s_heading] = $this->evaluate_field($row[$s_heading], $eval_field[strtolower($s_heading)]);
113
-
114
- // Raw Headers stores the actual column name in the CSV
115
- $raw_headers[ $s_heading ] = $heading;
116
- }
117
- $parsed_data[] = $row;
118
 
119
- unset( $postmeta, $row );
120
-
121
- $position = ftell( $handle );
122
-
123
- if ( $end_pos && $position >= $end_pos )
124
- break;
125
- }
126
- fclose( $handle );
127
- }
128
- return array( $parsed_data, $raw_headers, $position );
129
- }
130
-
131
- private function evaluate_field($value, $evaluation_field){
132
- $processed_value = $value;
133
- if(!empty($evaluation_field)){
134
- $operator = substr($evaluation_field, 0, 1);
135
- if(in_array($operator, array('=', '+', '-', '*', '/', '&' , '@'))){
136
- $eval_val = substr($evaluation_field, 1);
137
- switch($operator){
138
- case '=':
139
- $processed_value = trim($eval_val);
140
- break;
141
- case '+':
142
- $processed_value = $this->hf_currency_formatter($value) + $eval_val;
143
- break;
144
- case '-':
145
- $processed_value = $value - $eval_val;
146
- break;
147
- case '*':
148
- $processed_value = $value * $eval_val;
149
- break;
150
- case '/':
151
- $processed_value = $value / $eval_val;
152
- break;
153
- case '@':
154
- $date = DateTime::createFromFormat($eval_val, $value);
155
- $processed_value = $date->format('Y-m-d H:i:s');
156
- break;
157
- case '&':
158
- if (strpos($eval_val, '[VAL]') !== false) {
159
- $processed_value = str_replace('[VAL]',$value,$eval_val);
160
- }
161
- else{
162
- $processed_value = $value . $eval_val;
163
- }
164
- break;
165
- }
166
- }
167
- }
168
- return $processed_value;
169
- }
170
-
171
- /**
172
- * Parse users
173
- * @param array $item
174
- * @param integer $merge_empty_cells
175
- * @return array
176
- */
177
-
178
-
179
-
180
-
181
- public function parse_users( $item, $raw_headers, $merging, $record_offset ) {
182
-
183
-
184
- global $WF_CSV_User_Import, $wpdb;
185
-
186
- $results = array();
187
- $row = 0;
188
- $skipped = 0;
189
-
190
- $row++;
191
- if ( $row <= $record_offset ) {
192
- if($WF_CSV_User_Import->log)
193
- $WF_CSV_User_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped due to record offset.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
194
- unset($item);
195
- return;
196
- }
197
- if ( empty($item['user_email']) ) {
198
- if($WF_CSV_User_Import->log)
199
- $WF_CSV_User_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped: cannot insert user without email.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
200
- unset($item);
201
- return;
202
- }elseif(!is_email($item['user_email'])){
203
- if($WF_CSV_User_Import->log)
204
- $WF_CSV_User_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped: Email is not valid.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
205
- unset($item);
206
- return;
207
- }
208
 
209
- $user_details = array();
210
- foreach ($this->user_base_fields as $key => $value) {
211
- $user_details[$key] = isset( $item[$value] ) ? $item[$value] : "" ;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
  }
 
 
 
 
 
 
 
 
 
 
213
 
214
-
215
- $parsed_details = array();
216
-
217
- $parsed_details['user_details'] = $user_details;
218
-
219
-
220
- // the $user_details array will now contain the necessary name-value pairs for the wp_users table
221
- $results[] = $parsed_details;
222
-
223
- // Result
224
- return array(
225
- $this->post_type => $results,
226
- 'skipped' => $skipped,
227
- );
228
- }
229
-
230
- function hf_currency_formatter($price){
231
- $decimal_seperator = wc_get_price_decimal_separator();
232
- return preg_replace("[^0-9\\'.$decimal_seperator.']", "", $price);
 
 
 
 
 
 
 
 
 
 
 
 
 
233
  }
 
 
 
 
 
 
 
 
 
 
234
  }
4
  */
5
  class WF_CSV_Parser {
6
 
7
+ var $row;
8
+ var $post_type;
9
+ var $log;
10
+ var $skipped = 0;
11
+ var $delimiter;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  /**
14
+ * Constructor
15
+ */
16
+ public function __construct( $post_type = 'user' ) {
17
+ $this->post_type = $post_type;
18
+ $this->user_base_fields = array(
19
+ 'ID' => 'ID',
20
+ 'user_login' => 'user_login',
21
+ 'user_pass' => 'user_pass',
22
+ 'user_nicename' => 'user_nicename',
23
+ 'user_email' => 'user_email',
24
+ 'user_url' => 'user_url',
25
+ 'user_registered' => 'user_registered',
26
+ 'display_name' => 'display_name',
27
+ 'first_name' => 'first_name',
28
+ 'last_name' => 'last_name',
29
+ 'user_status' => 'user_status',
30
+ 'roles' => 'roles'
31
+ );
32
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
 
 
 
 
 
 
 
34
 
35
+ /**
36
+ * Format data from the csv file
37
+ * @param string $data
38
+ * @param string $enc
39
+ * @return string
40
+ */
41
+ public function format_data_from_csv( $data, $enc ) {
42
+ return ( $enc == 'UTF-8' ) ? $data : utf8_encode( $data );
43
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ /**
46
+ * Parse the data
47
+ * @param string $file [description]
48
+ * @param string $delimiter [description]
49
+ * @param integer $start_pos [description]
50
+ * @param integer $end_pos [description]
51
+ * @return array
52
+ */
53
+ public function parse_data( $file, $delimiter, $start_pos = 0, $end_pos = null ) {
54
+ // Set locale
55
+ $enc = mb_detect_encoding( $file, 'UTF-8, ISO-8859-1', true );
56
+ if ( $enc )
57
+ setlocale( LC_ALL, 'en_US.' . $enc );
58
+ @ini_set( 'auto_detect_line_endings', true );
59
+ $parsed_data = array();
60
+ $raw_headers = array();
61
+ // Put all CSV data into an associative array
62
+ if ( ( $handle = fopen( $file, "r" ) ) !== FALSE ) {
63
+ $header = fgetcsv( $handle, 0, $delimiter );
64
+ if ( $start_pos != 0 )
65
+ fseek( $handle, $start_pos );
66
+ while ( ( $postmeta = fgetcsv( $handle, 0, $delimiter ) ) !== FALSE ) {
67
+ $row = array();
68
+ foreach ( $header as $key => $heading ) {
69
+ $s_heading = strtolower($heading);
70
+ if ( $s_heading == '' )
71
+ continue;
72
+ // Add the heading to the parsed data
73
+ $row[$s_heading] = ( isset( $postmeta[$key] ) ) ? $this->format_data_from_csv( $postmeta[$key], $enc ) : '';
74
+ // Raw Headers stores the actual column name in the CSV
75
+ $raw_headers[ $s_heading ] = $heading;
76
  }
77
+ $parsed_data[] = $row;
78
+ unset( $postmeta, $row );
79
+ $position = ftell( $handle );
80
+ if ( $end_pos && $position >= $end_pos )
81
+ break;
82
+ }
83
+ fclose( $handle );
84
+ }
85
+ return array( $parsed_data, $raw_headers, $position );
86
+ }
87
 
88
+ /**
89
+ * Parse users
90
+ * @param array $item
91
+ * @return array
92
+ */
93
+ public function parse_users( $item, $raw_headers, $record_offset ) {
94
+ global $WF_CSV_Customer_Import, $wpdb;
95
+ $results = array();
96
+ $row = 0;
97
+ $skipped = 0;
98
+
99
+ $row++;
100
+ if ( $row <= $record_offset ) {
101
+ if($WF_CSV_Customer_Import->log)
102
+ $WF_CSV_Customer_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped due to record offset.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
103
+ unset($item);
104
+ return;
105
+ }
106
+ if ( empty($item['user_email']) ) {
107
+ if($WF_CSV_Customer_Import->log)
108
+ $WF_CSV_Customer_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped: cannot insert user without email.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
109
+ unset($item);
110
+ return;
111
+ }elseif(!is_email($item['user_email'])){
112
+ if($WF_CSV_Customer_Import->log)
113
+ $WF_CSV_Customer_Import->hf_log_data_change( 'user-csv-import', sprintf( __( '> Row %s - skipped: Email is not valid.', 'users-customers-import-export-for-wp-woocommerce' ), $row ) );
114
+ unset($item);
115
+ return;
116
+ }
117
+ $user_details = array();
118
+ foreach ($this->user_base_fields as $key => $value) {
119
+ $user_details[$key] = isset( $item[$value] ) ? $item[$value] : "" ;
120
  }
121
+ $parsed_details = array();
122
+ $parsed_details['user_details'] = $user_details;
123
+ // the $user_details array will now contain the necessary name-value pairs for the wp_users table
124
+ $results[] = $parsed_details;
125
+ // Result
126
+ return array(
127
+ $this->post_type => $results,
128
+ 'skipped' => $skipped,
129
+ );
130
+ }
131
  }
includes/importer/class-wf-customerimpexpcsv-customer-import.php CHANGED
@@ -13,12 +13,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
13
  var $id;
14
  var $file_url;
15
  var $delimiter;
16
- var $send_mail;
17
- var $profile;
18
- var $merge_empty_cells;
19
- var $processed_terms = array();
20
  var $processed_posts = array();
21
- var $merged = 0;
22
  var $skipped = 0;
23
  var $imported = 0;
24
  var $errored = 0;
@@ -30,32 +25,25 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
30
  * Constructor
31
  */
32
  public function __construct() {
33
-
34
  // Check that the class exists before trying to use it
35
- if (function_exists('WC')) {
36
- if(WC()->version < '2.7.0')
37
- {
38
- $this->log = new WC_Logger();
39
- }
40
- else
41
- {
42
- $this->log = wc_get_logger();
43
- }
44
- }
45
- $this->import_page = 'wordpress_hf_user_csv';
46
- $this->file_url_import_enabled = apply_filters('woocommerce_csv_product_file_url_import_enabled', true);
47
  }
48
 
49
- public function hf_log_data_change ($content = 'user-csv-import',$data='')
50
- {
51
- if (WC()->version < '2.7.0')
52
- {
53
- $this->log->add($content,$data);
54
- }else
55
- {
56
- $context = array( 'source' => $content );
57
- $this->log->log("debug", $data ,$context);
58
- }
59
  }
60
 
61
  /**
@@ -64,8 +52,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
64
  * Manages the three separate stages of the CSV import process
65
  */
66
  public function dispatch() {
67
-
68
- global $woocommerce, $wpdb;
69
 
70
  if (!empty($_POST['delimiter'])) {
71
  $this->delimiter = stripslashes(trim($_POST['delimiter']));
@@ -75,24 +62,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
75
 
76
  if (!$this->delimiter)
77
  $this->delimiter = ',';
78
-
79
-
80
- $this->send_mail = !empty($_POST['send_mail']) ? 1 : 0;
81
-
82
-
83
- if (!empty($_POST['profile'])) {
84
- $this->profile = stripslashes(trim($_POST['profile']));
85
- } else if (!empty($_GET['profile'])) {
86
- $this->profile = stripslashes(trim($_GET['profile']));
87
- }
88
- if (!$this->profile)
89
- $this->profile = '';
90
-
91
- if (!empty($_POST['merge_empty_cells']) || !empty($_GET['merge_empty_cells'])) {
92
- $this->merge_empty_cells = 1;
93
- } else {
94
- $this->merge_empty_cells = 0;
95
- }
96
 
97
  $step = empty($_GET['step']) ? 0 : (int) $_GET['step'];
98
 
@@ -145,167 +114,138 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
145
  <tr>
146
  <th class="status">&nbsp;</th>
147
  <th class="row"><?php _e('Row', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
148
- <th><?php _e('User ID', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
149
- <th><?php _e('User Status', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
150
- <th class="reason"><?php _e('Status Msg', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
151
- </tr>
152
  </thead>
153
  <tfoot>
154
- <tr class="importer-loading">
155
- <td colspan="5"></td> </tr>
 
156
  </tfoot>
157
  <tbody></tbody>
158
- </table>
159
  <script type="text/javascript">
160
- jQuery(document).ready(function($) {
161
-
162
- if (! window.console) { window.console = function(){}; }
163
-
164
- var processed_terms = [];
165
- var processed_posts = [];
166
- var i = 1;
167
- var done_count = 0;
168
- function import_rows(start_pos, end_pos) {
169
-
170
- var data = {
171
- action: 'user_csv_import_request',
172
- file: '<?php echo addslashes($file); ?>',
173
- mapping: '<?php echo @json_encode($_POST['map_from']); ?>',
174
- profile: '<?php echo $this->profile; ?>',
175
- eval_field: '<?php echo @stripslashes(json_encode(($_POST['eval_field']), JSON_HEX_APOS)) ?>',
176
- start_pos: start_pos,
177
- end_pos: end_pos,
178
- };
179
- data.eval_field = $.parseJSON(data.eval_field);
180
- return $.ajax({
181
- url: '<?php echo add_query_arg(array('import_page' => $this->import_page, 'step' => '3', 'merge' => !empty($_GET['merge']) ? '1' : '0'), admin_url('admin-ajax.php')); ?>',
182
- data: data,
183
- type: 'POST',
184
- success: function(response) {
185
- if (response) {
186
-
187
- try {
188
  // Get the valid JSON only from the returned string
189
- if (response.indexOf("<!--WC_START-->") >= 0)
190
- response = response.split("<!--WC_START-->")[1]; // Strip off before after WC_START
191
-
192
- if (response.indexOf("<!--WC_END-->") >= 0)
193
- response = response.split("<!--WC_END-->")[0]; // Strip off anything after WC_END
194
 
195
  // Parse
196
-
197
  var results = $.parseJSON(response);
198
  if (results.error) {
199
-
200
- $('#import-progress tbody').append('<tr id="row-' + i + '" class="error"><td class="status" colspan="5">' + results.error + '</td></tr>');
201
- i++;
202
- } else if (results.import_results && $(results.import_results).size() > 0) {
203
-
204
- $.each(results.processed_terms, function(index, value) {
205
- processed_terms.push(value);
206
- });
207
- $.each(results.processed_posts, function(index, value) {
208
- processed_posts.push(value);
209
- });
210
- $(results.import_results).each(function(index, row) {
211
- $('#import-progress tbody').append('<tr id="row-' + i + '" class="' + row['status'] + '"><td><mark class="result" title="' + row['status'] + '">' + row['status'] + '</mark></td><td class="row">' + i + '</td><td>' + row['user_id'] + '</td><td>' + row['post_id'] + ' - ' + row['post_title'] + '</td><td class="reason">' + row['reason'] + '</td></tr>');
212
- i++;
213
- });
214
- }
215
-
216
- } catch (err) {}
217
-
218
- } else {
219
- $('#import-progress tbody').append('<tr class="error"><td class="status" colspan="5">' + '<?php _e('AJAX Error', 'users-customers-import-export-for-wp-woocommerce'); ?>' + '</td></tr>');
220
- }
221
-
222
- var w = $(window);
223
- var row = $("#row-" + (i - 1));
224
- if (row.length) {
225
- w.scrollTop(row.offset().top - (w.height() / 2));
226
- }
227
-
228
- done_count++;
229
- $('body').trigger('user_csv_import_request_complete');
230
- }
231
- });
232
- }
233
-
234
- var rows = [];
235
- <?php
236
- $limit = apply_filters('woocommerce_csv_import_limit_per_request', 10);
237
- $enc = mb_detect_encoding($file, 'UTF-8, ISO-8859-1', true);
238
- if ($enc)
239
- setlocale(LC_ALL, 'en_US.' . $enc);
240
- @ini_set('auto_detect_line_endings', true);
241
-
242
- $count = 0;
243
- $previous_position = 0;
244
- $position = 0;
245
- $import_count = 0;
246
-
247
- // Get CSV positions
248
- if (( $handle = fopen($file, "r") ) !== FALSE) {
249
-
250
- while (( $postmeta = fgetcsv($handle, 0, $this->delimiter) ) !== FALSE) {
251
- $count++;
252
-
253
- if ($count >= $limit) {
254
- $previous_position = $position;
255
- $position = ftell($handle);
256
- $count = 0;
257
- $import_count ++;
258
-
259
- // Import rows between $previous_position $position
260
- ?>rows.push([ <?php echo $previous_position; ?>, <?php echo $position; ?> ]); <?php
261
  }
262
- }
263
-
264
- // Remainder
265
- if ($count > 0) {
266
- ?>rows.push([ <?php echo $position; ?>, '' ]); <?php
267
- $import_count ++;
268
- }
269
-
270
- fclose($handle);
271
- }
272
- ?>
273
 
274
- var data = rows.shift();
275
- var regen_count = 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
276
  import_rows( data[0], data[1] );
 
 
277
 
278
- $('body').on( 'user_csv_import_request_complete', function() {
279
- if ( done_count == <?php echo $import_count; ?> ) {
280
-
281
- import_done();
282
- } else {
283
- // Call next request
284
- data = rows.shift();
285
- import_rows( data[0], data[1] );
286
- }
287
- } );
288
-
289
- function import_done() {
290
- var data = {
291
- action: 'user_csv_import_request',
292
- file: '<?php echo $file; ?>',
293
- processed_terms: processed_terms,
294
- processed_posts: processed_posts,
295
- };
296
-
297
- $.ajax({
298
- url: '<?php echo add_query_arg(array('import_page' => $this->import_page, 'step' => '4', 'merge' => !empty($_GET['merge']) ? 1 : 0), admin_url('admin-ajax.php')); ?>',
299
- data: data,
300
- type: 'POST',
301
- success: function( response ) {
302
- console.log( response );
303
- $('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
304
- $('.importer-loading').hide();
305
- }
306
- });
307
  }
308
- });
 
 
309
  </script>
310
  <?php
311
  } else {
@@ -313,7 +253,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
313
  }
314
  break;
315
  case 3 :
316
-
317
  // Check access - cannot use nonce here as it will expire after multiple requests
318
  if (function_exists('WC')) {
319
  if (!current_user_can('manage_woocommerce'))
@@ -330,25 +269,15 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
330
  $wpdb->hide_errors();
331
 
332
  $file = stripslashes($_POST['file']);
333
- $mapping = json_decode(stripslashes($_POST['mapping']), true);
334
- $profile = isset($_POST['profile']) ? $_POST['profile'] : '';
335
- $eval_field = $_POST['eval_field'];
336
  $start_pos = isset($_POST['start_pos']) ? absint($_POST['start_pos']) : 0;
337
  $end_pos = isset($_POST['end_pos']) ? absint($_POST['end_pos']) : '';
338
 
339
- if ($profile !== '') {
340
- $profile_array = get_option('wf_user_csv_imp_exp_mapping');
341
- $profile_array[$profile] = array($mapping, $eval_field);
342
- update_option('wf_user_csv_imp_exp_mapping', $profile_array);
343
- }
344
-
345
- $position = $this->import_start($file, $mapping, $start_pos, $end_pos, $eval_field);
346
  $this->import();
347
  $this->import_end();
348
 
349
  $results = array();
350
  $results['import_results'] = $this->import_results;
351
- $results['processed_terms'] = $this->processed_terms;
352
  $results['processed_posts'] = $this->processed_posts;
353
 
354
  echo "<!--WC_START-->";
@@ -362,9 +291,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
362
  if (!current_user_can('manage_woocommerce'))
363
  die();
364
  }
365
-
366
  add_filter('http_request_timeout', array($this, 'bump_request_timeout'));
367
-
368
  if (function_exists('gc_enable'))
369
  gc_enable();
370
 
@@ -373,7 +300,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
373
  @flush();
374
  $wpdb->hide_errors();
375
 
376
- $this->processed_terms = isset($_POST['processed_terms']) ? $_POST['processed_terms'] : array();
377
  $this->processed_posts = isset($_POST['processed_posts']) ? $_POST['processed_posts'] : array();
378
 
379
  _e('Step 1...', 'users-customers-import-export-for-wp-woocommerce') . ' ';
@@ -394,7 +320,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
394
  exit;
395
  break;
396
  }
397
-
398
  $this->footer();
399
  }
400
 
@@ -410,7 +335,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
410
  */
411
  public function import_options() {
412
  $j = 0;
413
-
414
  if ($this->id)
415
  $file = get_attached_file($this->id);
416
  else if ($this->file_url_import_enabled)
@@ -426,10 +350,8 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
426
 
427
  // Get headers
428
  if (( $handle = fopen($file, "r") ) !== FALSE) {
429
-
430
  $row = $raw_headers = array();
431
  $header = fgetcsv($handle, 0, $this->delimiter);
432
-
433
  while (( $postmeta = fgetcsv($handle, 0, $this->delimiter) ) !== FALSE) {
434
  foreach ($header as $key => $heading) {
435
  if (!$heading)
@@ -442,29 +364,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
442
  }
443
  fclose($handle);
444
  }
445
-
446
- $mapping_from_db = get_option('wf_user_csv_imp_exp_mapping');
447
-
448
- if ($this->profile !== '' && !empty($_GET['clearmapping'])) {
449
- unset($mapping_from_db[$this->profile]);
450
- update_option('wf_user_csv_imp_exp_mapping', $mapping_from_db);
451
- $this->profile = '';
452
- }
453
- if ($this->profile !== '')
454
- $mapping_from_db = $mapping_from_db[$this->profile];
455
-
456
- $saved_mapping = null;
457
- $saved_evaluation = null;
458
- if ($mapping_from_db && is_array($mapping_from_db) && count($mapping_from_db) == 2 && empty($_GET['clearmapping'])) {
459
- $reset_action = 'admin.php?clearmapping=1&amp;profile=' . $this->profile . '&amp;import=' . $this->import_page . '&amp;step=1&amp;merge=' . (!empty($_GET['merge']) ? 1 : 0 ) . '&amp;file_url=' . $this->file_url . '&amp;delimiter=' . $this->delimiter . '&amp;merge_empty_cells=' . $this->merge_empty_cells. '&amp;send_mail=' . $this->send_mail . '&amp;file_id=' . $this->id . '';
460
- $reset_action = esc_attr(wp_nonce_url($reset_action, 'import-upload'));
461
- echo '<h3>' . __('Columns are pre-selected using the Mapping file: "<b style="color:gray">' . $this->profile . '</b>". <a href="' . $reset_action . '"> Delete</a> this mapping file.', 'users-customers-import-export-for-wp-woocommerce') . '</h3>';
462
- $saved_mapping = $mapping_from_db[0];
463
- $saved_evaluation = $mapping_from_db[1];
464
- }
465
-
466
- $merge = (!empty($_GET['merge']) && $_GET['merge']) ? 1 : 0;
467
-
468
  include( 'views/html-wf-import-options.php' );
469
  }
470
 
@@ -472,20 +371,17 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
472
  * The main controller for the actual import stage.
473
  */
474
  public function import() {
475
- global $woocommerce, $wpdb;
476
-
477
  wp_suspend_cache_invalidation(true);
478
  if ($this->log) {
479
  $this->hf_log_data_change('user-csv-import', '---');
480
  $this->hf_log_data_change('user-csv-import', __('Processing users.', 'users-customers-import-export-for-wp-woocommerce'));
481
  }
482
- $merging = 1;
483
  $record_offset = 0;
484
 
485
  $i = 0;
486
  //echo '<pre>';print_r($this->parsed_data);exit;
487
  foreach ($this->parsed_data as $key => &$item) {
488
- $user = $this->parser->parse_users($item, $this->raw_headers, $merging, $record_offset);
489
  if (!is_wp_error($user))
490
  $this->process_users($user['user'][0]);
491
  else
@@ -504,9 +400,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
504
  *
505
  * @param string $file Path to the CSV file for importing
506
  */
507
- public function import_start($file, $mapping, $start_pos, $end_pos, $eval_field) {
508
-
509
-
510
  if (function_exists('WC')) {
511
  if (WC()->version < '2.7.0') {
512
  $memory = size_format(woocommerce_let_to_num(ini_get('memory_limit')));
@@ -515,20 +409,21 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
515
  $memory = size_format(wc_let_to_num(ini_get('memory_limit')));
516
  $wp_memory = size_format(wc_let_to_num(WP_MEMORY_LIMIT));
517
  }
518
- }
 
 
 
519
  if ($this->log) {
520
  $this->hf_log_data_change('user-csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory);
521
- $this->hf_log_data_change('user-csv-import', __('Parsing products CSV.', 'users-customers-import-export-for-wp-woocommerce'));
522
  }
523
  $this->parser = new WF_CSV_Parser('user');
524
 
525
-
526
- list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data($file, $this->delimiter, $mapping, $start_pos, $end_pos, $eval_field);
527
  if ($this->log)
528
- $this->hf_log_data_change('user-csv-import', __('Finished parsing products CSV.', 'users-customers-import-export-for-wp-woocommerce'));
529
 
530
  unset($import_data);
531
-
532
  wp_defer_term_counting(true);
533
  wp_defer_comment_counting(true);
534
 
@@ -539,7 +434,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
539
  * Performs post-import cleanup of files and the cache
540
  */
541
  public function import_end() {
542
-
543
  //wp_cache_flush(); Stops output in some hosting environments
544
  foreach (get_taxonomies() as $tax) {
545
  delete_option("{$tax}_children");
@@ -559,32 +453,24 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
559
  * @return bool False if error uploading or invalid file, true otherwise
560
  */
561
  public function handle_upload() {
562
-
563
  if (empty($_POST['file_url'])) {
564
-
565
  $file = wp_import_handle_upload();
566
-
567
  if (isset($file['error'])) {
568
  echo '<p><strong>' . __('Sorry, there has been an error.', 'users-customers-import-export-for-wp-woocommerce') . '</strong><br />';
569
  echo esc_html($file['error']) . '</p>';
570
  return false;
571
  }
572
-
573
  $this->id = (int) $file['id'];
574
  return true;
575
  } else {
576
-
577
  if (file_exists(ABSPATH . $_POST['file_url'])) {
578
-
579
  $this->file_url = esc_attr($_POST['file_url']);
580
  return true;
581
  } else {
582
-
583
  echo '<p><strong>' . __('Sorry, there has been an error.', 'users-customers-import-export-for-wp-woocommerce') . '</strong></p>';
584
  return false;
585
  }
586
  }
587
-
588
  return false;
589
  }
590
 
@@ -592,19 +478,13 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
592
  * Create new posts based on import information
593
  */
594
  private function process_users($post) {
595
-
596
-
597
- global $wpdb;
598
- $this->imported = $this->merged = 0;
599
-
600
  // plan a dry run
601
  //$dry_run = isset( $_POST['dry_run'] ) && $_POST['dry_run'] ? true : false;
602
  $dry_run = 0; //mockup import and check weather the users can be imported without fail
603
  if ($this->log) {
604
  $this->hf_log_data_change('user-csv-import', '---');
605
- $this->hf_log_data_change('user-csv-import', __('Processing users.', 'users-customers-import-export-for-wp-woocommerce'));
606
  }
607
-
608
  if (empty($post['user_details']['user_email'])) {
609
  $this->add_import_result('skipped', __('Cannot insert user without email', 'users-customers-import-export-for-wp-woocommerce'), 1, 1, 1);
610
  unset($post);
@@ -614,12 +494,9 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
614
  unset($post);
615
  return;
616
  }
617
-
618
  $user_id = $this->hf_check_customer($post);
619
-
620
  $new_added = false;
621
 
622
-
623
  if ($user_id) {
624
  $usr_msg = 'User already exists.';
625
  $user_info = get_userdata($user_id);
@@ -629,7 +506,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
629
  $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $usr_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id), true);
630
  unset($post);
631
  return;
632
- } else{
633
  $user_id = $this->hf_create_customer($post);
634
  $new_added = true;
635
  if (is_wp_error($user_id)) {
@@ -656,15 +533,10 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
656
  $user_info = get_userdata($user_id);
657
  $user_string = sprintf('<a href="%s">%s</a>', get_edit_user_link($user_id), $user_info->first_name);
658
 
659
-
660
  $this->add_import_result('imported', __($out_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id , $user_string, $user_id);
661
  if ($this->log)
662
  $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $out_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id), true);
663
  $this->imported++;
664
- if ($this->log) {
665
- $this->hf_log_data_change('user-csv-import', sprintf(__('> Finished importing user %s', 'users-customers-import-export-for-wp-woocommerce'), $dry_run ? "" : $user_id ));
666
- $this->hf_log_data_change('user-csv-import', __('Finished processing users.', 'users-customers-import-export-for-wp-woocommerce'));
667
- }
668
 
669
  unset($post);
670
  }
@@ -677,7 +549,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
677
  $found_customer = false;
678
 
679
  if (!empty($customer_email)) {
680
-
681
  if (is_email($customer_email) && false !== email_exists($customer_email)) {
682
  $found_customer = email_exists($customer_email);
683
  } elseif (!empty($username) && false !== username_exists($username)) {
@@ -688,11 +559,9 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
688
  }
689
 
690
  public function hf_create_customer($data) {
691
-
692
  $customer_email = (!empty($data['user_details']['user_email']) ) ? $data['user_details']['user_email'] : '';
693
  $username = (!empty($data['user_details']['user_login']) ) ? $data['user_details']['user_login'] : '';
694
  $customer_id = (!empty($data['user_details']['ID']) ) ? $data['user_details']['ID'] : '';
695
-
696
  if (!empty($data['user_details']['user_pass'])) {
697
  $password = (strlen( $data['user_details']['user_pass'])==34 ) ? $data['user_details']['user_pass'] : wp_hash_password($data['user_details']['user_pass']);
698
  $password_generated = false;
@@ -702,17 +571,12 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
702
  }
703
  $found_customer = false;
704
  if (is_email($customer_email)) {
705
-
706
-
707
-
708
  // Not in test mode, create a user account for this email
709
  if (empty($username)) {
710
-
711
  $maybe_username = explode('@', $customer_email);
712
  $maybe_username = sanitize_user($maybe_username[0]);
713
  $counter = 1;
714
  $username = $maybe_username;
715
-
716
  while (username_exists($username)) {
717
  $username = $maybe_username . $counter;
718
  $counter++;
@@ -723,8 +587,6 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
723
  wp_insert_user(array('ID' => $found_customer,'user_login'=>$username,'user_email'=>$customer_email, 'user_pass' => $password));
724
 
725
  if (!is_wp_error($found_customer)) {
726
-
727
-
728
  $wp_user_object = new WP_User($found_customer);
729
  $roles = get_editable_roles();
730
  $new_roles = explode(',', $data['user_details']['roles']);
@@ -735,16 +597,16 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
735
  // If there are no roles, delete all of the user's roles
736
  $roles_to_remove = $user_roles;
737
  } else {
738
- $roles_to_remove = array_diff( $user_roles, $new_roles );
739
  }
740
  foreach ( $roles_to_remove as $_role ) {
741
- $wp_user_object->remove_role( $_role );
742
  }
743
  if(!empty($new_roles)){
744
  // Make sure that we don't call $wp_user_object->add_role() any more than it's necessary
745
  $_new_roles = array_diff( $new_roles, array_intersect( array_values( $wp_user_object->roles ), array_keys( $roles ) ) );
746
  foreach ( $_new_roles as $_role ) {
747
- $wp_user_object->add_role( $_role );
748
  }
749
  }
750
  $user_nicename = (!empty($data['user_details']['user_nicename'])) ? $data['user_details']['user_nicename'] : '';
@@ -765,17 +627,13 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
765
  'user_status' => $user_status,
766
  )
767
  );
768
-
769
  }
770
  } else {
771
-
772
  $found_customer = new WP_Error('hf_invalid_customer', sprintf(__('User could not be created without Email.', 'users-customers-import-export-for-wp-woocommerce'), $customer_id));
773
  }
774
-
775
  return $found_customer;
776
  }
777
 
778
-
779
  /**
780
  * Log a row's import status
781
  */
@@ -818,8 +676,7 @@ class WF_CustomerImpExpCsv_Customer_Import extends WP_Importer {
818
  $action = 'admin.php?import=wordpress_hf_user_csv&amp;step=1';
819
  $bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
820
  $size = size_format($bytes);
821
- $upload_dir = wp_upload_dir();
822
-
823
  include( 'views/html-wf-import-greeting.php' );
824
  }
825
 
13
  var $id;
14
  var $file_url;
15
  var $delimiter;
 
 
 
 
16
  var $processed_posts = array();
 
17
  var $skipped = 0;
18
  var $imported = 0;
19
  var $errored = 0;
25
  * Constructor
26
  */
27
  public function __construct() {
 
28
  // Check that the class exists before trying to use it
29
+ if (function_exists('WC')) {
30
+ if(WC()->version < '2.7.0'){
31
+ $this->log = new WC_Logger();
32
+ } else {
33
+ $this->log = wc_get_logger();
34
+ }
35
+ }
36
+ $this->import_page = 'wordpress_hf_user_csv';
37
+ $this->file_url_import_enabled = apply_filters('woocommerce_csv_product_file_url_import_enabled', true);
 
 
 
38
  }
39
 
40
+ public function hf_log_data_change ($content = 'user-csv-import',$data='') {
41
+ if (WC()->version < '2.7.0'){
42
+ $this->log->add($content,$data);
43
+ }else{
44
+ $context = array( 'source' => $content );
45
+ $this->log->log("debug", $data ,$context);
46
+ }
 
 
 
47
  }
48
 
49
  /**
52
  * Manages the three separate stages of the CSV import process
53
  */
54
  public function dispatch() {
55
+ global $wpdb;
 
56
 
57
  if (!empty($_POST['delimiter'])) {
58
  $this->delimiter = stripslashes(trim($_POST['delimiter']));
62
 
63
  if (!$this->delimiter)
64
  $this->delimiter = ',';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  $step = empty($_GET['step']) ? 0 : (int) $_GET['step'];
67
 
114
  <tr>
115
  <th class="status">&nbsp;</th>
116
  <th class="row"><?php _e('Row', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
117
+ <th><?php _e('User ID', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
118
+ <th><?php _e('User Status', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
119
+ <th class="reason"><?php _e('Status Msg', 'users-customers-import-export-for-wp-woocommerce'); ?></th>
120
+ </tr>
121
  </thead>
122
  <tfoot>
123
+ <tr class="importer-loading">
124
+ <td colspan="5"></td>
125
+ </tr>
126
  </tfoot>
127
  <tbody></tbody>
128
+ </table>
129
  <script type="text/javascript">
130
+ jQuery(document).ready(function($) {
131
+ if (! window.console) { window.console = function(){}; }
132
+ var processed_posts = [];
133
+ var i = 1;
134
+ var done_count = 0;
135
+ function import_rows(start_pos, end_pos) {
136
+ var data = {
137
+ action: 'user_csv_import_request',
138
+ file: '<?php echo addslashes($file); ?>',
139
+ start_pos: start_pos,
140
+ end_pos: end_pos,
141
+ };
142
+ return $.ajax({
143
+ url: '<?php echo add_query_arg(array('import_page' => $this->import_page, 'step' => '3'), admin_url('admin-ajax.php')); ?>',
144
+ data: data,
145
+ type: 'POST',
146
+ success: function(response) {
147
+ if (response) {
148
+ try {
 
 
 
 
 
 
 
 
 
149
  // Get the valid JSON only from the returned string
150
+ if (response.indexOf("<!--WC_START-->") >= 0)
151
+ response = response.split("<!--WC_START-->")[1]; // Strip off before after WC_START
152
+ if (response.indexOf("<!--WC_END-->") >= 0)
153
+ response = response.split("<!--WC_END-->")[0]; // Strip off anything after WC_END
 
154
 
155
  // Parse
 
156
  var results = $.parseJSON(response);
157
  if (results.error) {
158
+ $('#import-progress tbody').append('<tr id="row-' + i + '" class="error"><td class="status" colspan="5">' + results.error + '</td></tr>');
159
+ i++;
160
+ } else if (results.import_results && $(results.import_results).size() > 0) {
161
+ $.each(results.processed_posts, function(index, value) {
162
+ processed_posts.push(value);
163
+ });
164
+ $(results.import_results).each(function(index, row) {
165
+ $('#import-progress tbody').append('<tr id="row-' + i + '" class="' + row['status'] + '"><td><mark class="result" title="' + row['status'] + '">' + row['status'] + '</mark></td><td class="row">' + i + '</td><td>' + row['user_id'] + '</td><td>' + row['post_id'] + ' - ' + row['post_title'] + '</td><td class="reason">' + row['reason'] + '</td></tr>');
166
+ i++;
167
+ });
168
+ }
169
+ } catch (err) {}
170
+ } else {
171
+ $('#import-progress tbody').append('<tr class="error"><td class="status" colspan="5">' + '<?php _e('AJAX Error', 'users-customers-import-export-for-wp-woocommerce'); ?>' + '</td></tr>');
172
+ }
173
+
174
+ var w = $(window);
175
+ var row = $("#row-" + (i - 1));
176
+ if (row.length) {
177
+ w.scrollTop(row.offset().top - (w.height() / 2));
178
+ }
179
+ done_count++;
180
+ $('body').trigger('user_csv_import_request_complete');
181
+ }
182
+ });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
  }
 
 
 
 
 
 
 
 
 
 
 
184
 
185
+ var rows = [];
186
+ <?php
187
+ $limit = apply_filters('woocommerce_csv_import_limit_per_request', 10);
188
+ $enc = mb_detect_encoding($file, 'UTF-8, ISO-8859-1', true);
189
+ if ($enc)
190
+ setlocale(LC_ALL, 'en_US.' . $enc);
191
+ @ini_set('auto_detect_line_endings', true);
192
+ $count = 0;
193
+ $previous_position = 0;
194
+ $position = 0;
195
+ $import_count = 0;
196
+ // Get CSV positions
197
+ if (( $handle = fopen($file, "r") ) !== FALSE) {
198
+ while (( $postmeta = fgetcsv($handle, 0, $this->delimiter)) !== FALSE) {
199
+ $count++;
200
+ if ($count >= $limit) {
201
+ $previous_position = $position;
202
+ $position = ftell($handle);
203
+ $count = 0;
204
+ $import_count ++;
205
+ // Import rows between $previous_position $position
206
+ ?>rows.push([ <?php echo $previous_position; ?>, <?php echo $position; ?> ]); <?php
207
+ }
208
+ }
209
+ // Remainder
210
+ if ($count > 0) {
211
+ ?>rows.push([ <?php echo $position; ?>, '' ]); <?php
212
+ $import_count ++;
213
+ }
214
+ fclose($handle);
215
+ }
216
+ ?>
217
+ var data = rows.shift();
218
+ var regen_count = 0;
219
+ import_rows( data[0], data[1] );
220
+
221
+ $('body').on( 'user_csv_import_request_complete', function() {
222
+ if ( done_count == <?php echo $import_count; ?> ) {
223
+ import_done();
224
+ } else {
225
+ // Call next request
226
+ data = rows.shift();
227
  import_rows( data[0], data[1] );
228
+ }
229
+ });
230
 
231
+ function import_done() {
232
+ var data = {
233
+ action: 'user_csv_import_request',
234
+ file: '<?php echo $file; ?>',
235
+ processed_posts: processed_posts,
236
+ };
237
+ $.ajax({
238
+ url: '<?php echo add_query_arg(array('import_page' => $this->import_page, 'step' => '4'), admin_url('admin-ajax.php')); ?>',
239
+ data: data,
240
+ type: 'POST',
241
+ success: function( response ) {
242
+ console.log( response );
243
+ $('#import-progress tbody').append( '<tr class="complete"><td colspan="5">' + response + '</td></tr>' );
244
+ $('.importer-loading').hide();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
245
  }
246
+ });
247
+ }
248
+ });
249
  </script>
250
  <?php
251
  } else {
253
  }
254
  break;
255
  case 3 :
 
256
  // Check access - cannot use nonce here as it will expire after multiple requests
257
  if (function_exists('WC')) {
258
  if (!current_user_can('manage_woocommerce'))
269
  $wpdb->hide_errors();
270
 
271
  $file = stripslashes($_POST['file']);
 
 
 
272
  $start_pos = isset($_POST['start_pos']) ? absint($_POST['start_pos']) : 0;
273
  $end_pos = isset($_POST['end_pos']) ? absint($_POST['end_pos']) : '';
274
 
275
+ $position = $this->import_start($file, $start_pos, $end_pos);
 
 
 
 
 
 
276
  $this->import();
277
  $this->import_end();
278
 
279
  $results = array();
280
  $results['import_results'] = $this->import_results;
 
281
  $results['processed_posts'] = $this->processed_posts;
282
 
283
  echo "<!--WC_START-->";
291
  if (!current_user_can('manage_woocommerce'))
292
  die();
293
  }
 
294
  add_filter('http_request_timeout', array($this, 'bump_request_timeout'));
 
295
  if (function_exists('gc_enable'))
296
  gc_enable();
297
 
300
  @flush();
301
  $wpdb->hide_errors();
302
 
 
303
  $this->processed_posts = isset($_POST['processed_posts']) ? $_POST['processed_posts'] : array();
304
 
305
  _e('Step 1...', 'users-customers-import-export-for-wp-woocommerce') . ' ';
320
  exit;
321
  break;
322
  }
 
323
  $this->footer();
324
  }
325
 
335
  */
336
  public function import_options() {
337
  $j = 0;
 
338
  if ($this->id)
339
  $file = get_attached_file($this->id);
340
  else if ($this->file_url_import_enabled)
350
 
351
  // Get headers
352
  if (( $handle = fopen($file, "r") ) !== FALSE) {
 
353
  $row = $raw_headers = array();
354
  $header = fgetcsv($handle, 0, $this->delimiter);
 
355
  while (( $postmeta = fgetcsv($handle, 0, $this->delimiter) ) !== FALSE) {
356
  foreach ($header as $key => $heading) {
357
  if (!$heading)
364
  }
365
  fclose($handle);
366
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
367
  include( 'views/html-wf-import-options.php' );
368
  }
369
 
371
  * The main controller for the actual import stage.
372
  */
373
  public function import() {
 
 
374
  wp_suspend_cache_invalidation(true);
375
  if ($this->log) {
376
  $this->hf_log_data_change('user-csv-import', '---');
377
  $this->hf_log_data_change('user-csv-import', __('Processing users.', 'users-customers-import-export-for-wp-woocommerce'));
378
  }
 
379
  $record_offset = 0;
380
 
381
  $i = 0;
382
  //echo '<pre>';print_r($this->parsed_data);exit;
383
  foreach ($this->parsed_data as $key => &$item) {
384
+ $user = $this->parser->parse_users($item, $this->raw_headers, $record_offset);
385
  if (!is_wp_error($user))
386
  $this->process_users($user['user'][0]);
387
  else
400
  *
401
  * @param string $file Path to the CSV file for importing
402
  */
403
+ public function import_start($file,$start_pos, $end_pos) {
 
 
404
  if (function_exists('WC')) {
405
  if (WC()->version < '2.7.0') {
406
  $memory = size_format(woocommerce_let_to_num(ini_get('memory_limit')));
409
  $memory = size_format(wc_let_to_num(ini_get('memory_limit')));
410
  $wp_memory = size_format(wc_let_to_num(WP_MEMORY_LIMIT));
411
  }
412
+ } else {
413
+ $memory = size_format($this->wf_let_to_num(ini_get('memory_limit')));
414
+ $wp_memory = size_format($this->wf_let_to_num(WP_MEMORY_LIMIT));
415
+ }
416
  if ($this->log) {
417
  $this->hf_log_data_change('user-csv-import', '---[ New Import ] PHP Memory: ' . $memory . ', WP Memory: ' . $wp_memory);
418
+ $this->hf_log_data_change('user-csv-import', __('Parsing users CSV.', 'users-customers-import-export-for-wp-woocommerce'));
419
  }
420
  $this->parser = new WF_CSV_Parser('user');
421
 
422
+ list( $this->parsed_data, $this->raw_headers, $position ) = $this->parser->parse_data($file, $this->delimiter, $start_pos, $end_pos);
 
423
  if ($this->log)
424
+ $this->hf_log_data_change('user-csv-import', __('Finished parsing users CSV.', 'users-customers-import-export-for-wp-woocommerce'));
425
 
426
  unset($import_data);
 
427
  wp_defer_term_counting(true);
428
  wp_defer_comment_counting(true);
429
 
434
  * Performs post-import cleanup of files and the cache
435
  */
436
  public function import_end() {
 
437
  //wp_cache_flush(); Stops output in some hosting environments
438
  foreach (get_taxonomies() as $tax) {
439
  delete_option("{$tax}_children");
453
  * @return bool False if error uploading or invalid file, true otherwise
454
  */
455
  public function handle_upload() {
 
456
  if (empty($_POST['file_url'])) {
 
457
  $file = wp_import_handle_upload();
 
458
  if (isset($file['error'])) {
459
  echo '<p><strong>' . __('Sorry, there has been an error.', 'users-customers-import-export-for-wp-woocommerce') . '</strong><br />';
460
  echo esc_html($file['error']) . '</p>';
461
  return false;
462
  }
 
463
  $this->id = (int) $file['id'];
464
  return true;
465
  } else {
 
466
  if (file_exists(ABSPATH . $_POST['file_url'])) {
 
467
  $this->file_url = esc_attr($_POST['file_url']);
468
  return true;
469
  } else {
 
470
  echo '<p><strong>' . __('Sorry, there has been an error.', 'users-customers-import-export-for-wp-woocommerce') . '</strong></p>';
471
  return false;
472
  }
473
  }
 
474
  return false;
475
  }
476
 
478
  * Create new posts based on import information
479
  */
480
  private function process_users($post) {
481
+ $this->imported = 0;
 
 
 
 
482
  // plan a dry run
483
  //$dry_run = isset( $_POST['dry_run'] ) && $_POST['dry_run'] ? true : false;
484
  $dry_run = 0; //mockup import and check weather the users can be imported without fail
485
  if ($this->log) {
486
  $this->hf_log_data_change('user-csv-import', '---');
 
487
  }
 
488
  if (empty($post['user_details']['user_email'])) {
489
  $this->add_import_result('skipped', __('Cannot insert user without email', 'users-customers-import-export-for-wp-woocommerce'), 1, 1, 1);
490
  unset($post);
494
  unset($post);
495
  return;
496
  }
 
497
  $user_id = $this->hf_check_customer($post);
 
498
  $new_added = false;
499
 
 
500
  if ($user_id) {
501
  $usr_msg = 'User already exists.';
502
  $user_info = get_userdata($user_id);
506
  $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $usr_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id), true);
507
  unset($post);
508
  return;
509
+ } else {
510
  $user_id = $this->hf_create_customer($post);
511
  $new_added = true;
512
  if (is_wp_error($user_id)) {
533
  $user_info = get_userdata($user_id);
534
  $user_string = sprintf('<a href="%s">%s</a>', get_edit_user_link($user_id), $user_info->first_name);
535
 
 
536
  $this->add_import_result('imported', __($out_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id , $user_string, $user_id);
537
  if ($this->log)
538
  $this->hf_log_data_change('user-csv-import', sprintf(__('> &#8220;%s&#8221;' . $out_msg, 'users-customers-import-export-for-wp-woocommerce'), $user_id), true);
539
  $this->imported++;
 
 
 
 
540
 
541
  unset($post);
542
  }
549
  $found_customer = false;
550
 
551
  if (!empty($customer_email)) {
 
552
  if (is_email($customer_email) && false !== email_exists($customer_email)) {
553
  $found_customer = email_exists($customer_email);
554
  } elseif (!empty($username) && false !== username_exists($username)) {
559
  }
560
 
561
  public function hf_create_customer($data) {
 
562
  $customer_email = (!empty($data['user_details']['user_email']) ) ? $data['user_details']['user_email'] : '';
563
  $username = (!empty($data['user_details']['user_login']) ) ? $data['user_details']['user_login'] : '';
564
  $customer_id = (!empty($data['user_details']['ID']) ) ? $data['user_details']['ID'] : '';
 
565
  if (!empty($data['user_details']['user_pass'])) {
566
  $password = (strlen( $data['user_details']['user_pass'])==34 ) ? $data['user_details']['user_pass'] : wp_hash_password($data['user_details']['user_pass']);
567
  $password_generated = false;
571
  }
572
  $found_customer = false;
573
  if (is_email($customer_email)) {
 
 
 
574
  // Not in test mode, create a user account for this email
575
  if (empty($username)) {
 
576
  $maybe_username = explode('@', $customer_email);
577
  $maybe_username = sanitize_user($maybe_username[0]);
578
  $counter = 1;
579
  $username = $maybe_username;
 
580
  while (username_exists($username)) {
581
  $username = $maybe_username . $counter;
582
  $counter++;
587
  wp_insert_user(array('ID' => $found_customer,'user_login'=>$username,'user_email'=>$customer_email, 'user_pass' => $password));
588
 
589
  if (!is_wp_error($found_customer)) {
 
 
590
  $wp_user_object = new WP_User($found_customer);
591
  $roles = get_editable_roles();
592
  $new_roles = explode(',', $data['user_details']['roles']);
597
  // If there are no roles, delete all of the user's roles
598
  $roles_to_remove = $user_roles;
599
  } else {
600
+ $roles_to_remove = array_diff( $user_roles, $new_roles );
601
  }
602
  foreach ( $roles_to_remove as $_role ) {
603
+ $wp_user_object->remove_role( $_role );
604
  }
605
  if(!empty($new_roles)){
606
  // Make sure that we don't call $wp_user_object->add_role() any more than it's necessary
607
  $_new_roles = array_diff( $new_roles, array_intersect( array_values( $wp_user_object->roles ), array_keys( $roles ) ) );
608
  foreach ( $_new_roles as $_role ) {
609
+ $wp_user_object->add_role( $_role );
610
  }
611
  }
612
  $user_nicename = (!empty($data['user_details']['user_nicename'])) ? $data['user_details']['user_nicename'] : '';
627
  'user_status' => $user_status,
628
  )
629
  );
 
630
  }
631
  } else {
 
632
  $found_customer = new WP_Error('hf_invalid_customer', sprintf(__('User could not be created without Email.', 'users-customers-import-export-for-wp-woocommerce'), $customer_id));
633
  }
 
634
  return $found_customer;
635
  }
636
 
 
637
  /**
638
  * Log a row's import status
639
  */
676
  $action = 'admin.php?import=wordpress_hf_user_csv&amp;step=1';
677
  $bytes = apply_filters('import_upload_size_limit', wp_max_upload_size());
678
  $size = size_format($bytes);
679
+ $upload_dir = wp_upload_dir();
 
680
  include( 'views/html-wf-import-greeting.php' );
681
  }
682
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: webtoffee
3
  Donate link: https://www.webtoffee.com/plugins/
4
  Tags: Export Users to CSV, Import Users from CSV, woocommerce export customers, user export, export import users, woocommerce import customers, woocommerce export customer email
5
  Requires at least: 3.0.1
6
- Tested up to: 5.1.1
7
- Stable tag: 1.2.8
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -19,8 +19,8 @@ Import users and export users made fast and simple! Import Export WordPress User
19
 
20
  &#128312; Users Export - Export Users to CSV file.</li>
21
  &#128312; Users import - Import Users from CSV format to WordPress/WooCommerce Store.
22
- &#128312; Tested OK with WooCommerce 3.6.1
23
- &#128312; Tested OK with PHP 7.3.3
24
 
25
  Highlights: WordPress Users Export, WordPress Users CSV Import Suite, Export WordPress Users to CSV. Pro Version supports export and import of all additional user meta like WooCommerce details.
26
 
@@ -149,6 +149,8 @@ No. You may want to use https://wordpress.org/plugins/order-import-export-for-wo
149
 
150
  == Changelog ==
151
 
 
 
152
  = 1.2.8 =
153
  * Tested OK with WC 3.6.1
154
  = 1.2.7 =
@@ -221,5 +223,5 @@ No. You may want to use https://wordpress.org/plugins/order-import-export-for-wo
221
 
222
  == Upgrade Notice ==
223
 
224
- = 1.2.8 =
225
- * Tested OK with WC 3.6.1
3
  Donate link: https://www.webtoffee.com/plugins/
4
  Tags: Export Users to CSV, Import Users from CSV, woocommerce export customers, user export, export import users, woocommerce import customers, woocommerce export customer email
5
  Requires at least: 3.0.1
6
+ Tested up to: 5.2.1
7
+ Stable tag: 1.2.9
8
  License: GPLv3
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
19
 
20
  &#128312; Users Export - Export Users to CSV file.</li>
21
  &#128312; Users import - Import Users from CSV format to WordPress/WooCommerce Store.
22
+ &#128312; Tested OK with WooCommerce 3.6.3
23
+ &#128312; Tested OK with PHP 7.3.5
24
 
25
  Highlights: WordPress Users Export, WordPress Users CSV Import Suite, Export WordPress Users to CSV. Pro Version supports export and import of all additional user meta like WooCommerce details.
26
 
149
 
150
  == Changelog ==
151
 
152
+ = 1.2.9 =
153
+ * Tested OK with WC 3.6.3 and WP 5.2.1
154
  = 1.2.8 =
155
  * Tested OK with WC 3.6.1
156
  = 1.2.7 =
223
 
224
  == Upgrade Notice ==
225
 
226
+ = 1.2.9 =
227
+ * Tested OK with WC 3.6.3 and WP 5.2.1
styles/select2.css CHANGED
@@ -1,4 +1 @@
1
- .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #ddd;border-radius:0px;cursor:text;line-height: 1.5}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none;margin: 5px 5px 0 0}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
2
- #v_offset.input-text{width: 400px;padding: 6px}
3
- #v_limit.input-text{width: 400px;padding: 6px}
4
- #v_user_roles{width: 400px}
1
+ .select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-selection--single .select2-selection__clear{position:relative}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap}.select2-container .select2-search--inline{float:left}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;padding:0}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051}.select2-results{display:block}.select2-results__options{list-style:none;margin:0;padding:0}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none}.select2-results__option[aria-selected]{cursor:pointer}.select2-container--open .select2-dropdown{left:0}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-search--dropdown{display:block;padding:4px}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none}.select2-search--dropdown.select2-search--hide{display:none}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0)}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;-webkit-clip-path:inset(50%) !important;clip-path:inset(50%) !important;height:1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;white-space:nowrap !important}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #ddd;border-radius:0px;cursor:text;line-height: 1.5}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%}.select2-container--default .select2-selection--multiple .select2-selection__rendered li{list-style:none;margin: 5px 5px 0 0}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-search--inline{float:right}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;box-shadow:none;-webkit-appearance:textfield}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--default .select2-results__option[role=group]{padding:0}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic .select2-selection--single{background-color:#f7f7f7;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #fff 50%, #eee 100%);background-image:-o-linear-gradient(top, #fff 50%, #eee 100%);background-image:linear-gradient(to bottom, #fff 50%, #eee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eee 50%, #ccc 100%);background-image:-o-linear-gradient(top, #eee 50%, #ccc 100%);background-image:linear-gradient(to bottom, #eee 50%, #ccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0)}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #fff 0%, #eee 50%);background-image:-o-linear-gradient(top, #fff 0%, #eee 50%);background-image:linear-gradient(to bottom, #fff 0%, #eee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0)}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eee 50%, #fff 100%);background-image:-o-linear-gradient(top, #eee 50%, #fff 100%);background-image:linear-gradient(to bottom, #eee 50%, #fff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0)}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;box-shadow:none}.select2-container--classic .select2-dropdown{background-color:#fff;border:1px solid transparent}.select2-container--classic .select2-dropdown--above{border-bottom:none}.select2-container--classic .select2-dropdown--below{border-top:none}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto}.select2-container--classic .select2-results__option[role=group]{padding:0}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:#fff}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb}
 
 
 
styles/wf-style.css CHANGED
@@ -150,4 +150,7 @@
150
  border-color: #5ccc96;
151
  }
152
  .wt-userimport-rating-link{color:yellow;}
153
- .review-and-deactivate{color: #aa0073;}
 
 
 
150
  border-color: #5ccc96;
151
  }
152
  .wt-userimport-rating-link{color:yellow;}
153
+ .review-and-deactivate{color: #aa0073;}
154
+ #v_offset.input-text{width: 400px;padding: 6px}
155
+ #v_limit.input-text{width: 400px;padding: 6px}
156
+ #v_user_roles{width: 400px}
users-customers-import-export-for-wp-woocommerce.php CHANGED
@@ -6,8 +6,8 @@
6
  Description: Export and Import User/Customers details From and To your WordPress/WooCommerce.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/wordpress-users-woocommerce-customers-import-export/
9
- Version: 1.2.8
10
- WC tested up to: 3.6.1
11
  Text Domain: users-customers-import-export-for-wp-woocommerce
12
  License: GPLv3
13
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
@@ -36,7 +36,7 @@ if( !defined('WF_CUSTOMER_IMP_EXP_ID') )
36
 
37
  if( !defined('WF_CUSTOMER_IMP_EXP_VERSION') )
38
  {
39
- define("WF_CUSTOMER_IMP_EXP_VERSION", "1.2.8");
40
  }
41
 
42
 
6
  Description: Export and Import User/Customers details From and To your WordPress/WooCommerce.
7
  Author: WebToffee
8
  Author URI: https://www.webtoffee.com/product/wordpress-users-woocommerce-customers-import-export/
9
+ Version: 1.2.9
10
+ WC tested up to: 3.6.3
11
  Text Domain: users-customers-import-export-for-wp-woocommerce
12
  License: GPLv3
13
  License URI: https://www.gnu.org/licenses/gpl-3.0.html
36
 
37
  if( !defined('WF_CUSTOMER_IMP_EXP_VERSION') )
38
  {
39
+ define("WF_CUSTOMER_IMP_EXP_VERSION", "1.2.9");
40
  }
41
 
42