Import users from CSV with meta - Version 1.19

Version Description

  • New class to create diffent HTML elements to standarize plugin code
  • Different fixes in export function to avoid errors
  • New secondary tab section prepared
Download this release

Release Info

Developer carazo
Plugin Icon 128x128 Import users from CSV with meta
Version 1.19
Comparing to
See all releases

Code changes from version 1.18.4.4 to 1.19

assets/style.css CHANGED
@@ -82,6 +82,48 @@
82
  transition: all 300ms cubic-bezier(0.19, 1, 0.22, 1);
83
  }
84
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  .dataTables_wrapper .dataTables_length select{
86
  font-size: 13px;
87
  background: none;
@@ -89,6 +131,7 @@
89
  min-height: 13px;
90
  }
91
 
 
92
  #acui_exporter .user-exporter-progress-wrapper{
93
  padding: 5px;
94
  background-color: white;
82
  transition: all 300ms cubic-bezier(0.19, 1, 0.22, 1);
83
  }
84
 
85
+ .acui-subsubsub{
86
+ list-style: none;
87
+ padding: 0;
88
+ font-size: 13px;
89
+ float: left;
90
+ color: #646970;
91
+ margin: 0 0 10px;
92
+ width: 100%;
93
+ border-bottom: 1px solid #ccc;
94
+ box-shadow: 0 1px 1px rgb(0 0 0 / 4%);
95
+ }
96
+
97
+ .acui-subsubsub li {
98
+ display: inline-block;
99
+ margin: 0;
100
+ padding: 0;
101
+ white-space: nowrap;
102
+ }
103
+
104
+ .acui-subsubsub a {
105
+ padding: 13px;
106
+ display: block;
107
+ line-height: 2;
108
+ text-decoration: none;
109
+ }
110
+
111
+ .acui-subsubsub a.current {
112
+ color: #000;
113
+ border-bottom: 4px solid #00a0d2;
114
+ padding-bottom: 9px;
115
+ }
116
+
117
+ /* settings */
118
+ #acui_roles_wrapper label.roles{
119
+ margin-right: 5px;
120
+ }
121
+
122
+ input[type=checkbox].acui-checkbox{
123
+ margin-left: 2px;
124
+ }
125
+
126
+ /* dataTables */
127
  .dataTables_wrapper .dataTables_length select{
128
  font-size: 13px;
129
  background: none;
131
  min-height: 13px;
132
  }
133
 
134
+ /* exporter */
135
  #acui_exporter .user-exporter-progress-wrapper{
136
  padding: 5px;
137
  background-color: white;
classes/batch_exporter.php CHANGED
@@ -610,7 +610,7 @@ class ACUI_Batch_Exporter{
610
  }
611
 
612
  if( in_array( $key, $this->get_non_date_keys() ) || empty( $datetime_format ) ){
613
- return $this->clean_bad_characters_formulas( $value );
614
  }
615
 
616
  if( $this->get_convert_timestamp() && is_int( $value ) && ( ( $this->is_valid_timestamp( $value ) && strlen( $value ) > 4 ) || in_array( $key, $timestamp_keys) ) ){ // dates in timestamp format
@@ -621,6 +621,9 @@ class ACUI_Batch_Exporter{
621
  }
622
 
623
  function clean_bad_characters_formulas( $value ){
 
 
 
624
  if( strlen( $value ) == 0 )
625
  return $value;
626
 
610
  }
611
 
612
  if( in_array( $key, $this->get_non_date_keys() ) || empty( $datetime_format ) ){
613
+ return $value;
614
  }
615
 
616
  if( $this->get_convert_timestamp() && is_int( $value ) && ( ( $this->is_valid_timestamp( $value ) && strlen( $value ) > 4 ) || in_array( $key, $timestamp_keys) ) ){ // dates in timestamp format
621
  }
622
 
623
  function clean_bad_characters_formulas( $value ){
624
+ if( is_array( $value ) )
625
+ return $value;
626
+
627
  if( strlen( $value ) == 0 )
628
  return $value;
629
 
classes/cron.php CHANGED
@@ -17,7 +17,7 @@ class ACUI_Cron{
17
  $next_timestamp = wp_next_scheduled( 'acui_cron_process' );
18
  $period = sanitize_text_field( $form_data[ "period" ] );
19
 
20
- if( isset( $form_data["cron-activated"] ) && $form_data["cron-activated"] == "yes" ){
21
  update_option( "acui_cron_activated", true );
22
 
23
  $old_period = get_option( "acui_cron_period" );
@@ -35,20 +35,25 @@ class ACUI_Cron{
35
  wp_unschedule_event( $next_timestamp, 'acui_cron_process');
36
  }
37
 
38
- update_option( "acui_cron_send_mail", isset( $form_data["send-mail-cron"] ) && $form_data["send-mail-cron"] == "yes" );
39
- update_option( "acui_cron_send_mail_updated", isset( $form_data["send-mail-updated"] ) && $form_data["send-mail-updated"] == "yes" );
40
- update_option( "acui_cron_delete_users", isset( $form_data["cron-delete-users"] ) && $form_data["cron-delete-users"] == "yes" );
41
- update_option( "acui_cron_delete_users_assign_posts", sanitize_text_field( $form_data["cron-delete-users-assign-posts"] ) );
42
- update_option( "acui_move_file_cron", isset( $form_data["move-file-cron"] ) && $form_data["move-file-cron"] == "yes" );
43
- update_option( "acui_cron_path_to_move_auto_rename", isset( $form_data["path_to_move_auto_rename"] ) && $form_data["path_to_move_auto_rename"] == "yes" );
44
- update_option( "acui_cron_allow_multiple_accounts", ( isset( $form_data["allow_multiple_accounts"] ) && $form_data["allow_multiple_accounts"] == "yes" ) ? "allowed" : "not_allowed" );
 
 
 
45
  update_option( "acui_cron_path_to_file", sanitize_text_field( $form_data["path_to_file"] ) );
46
  update_option( "acui_cron_path_to_move", sanitize_text_field( $form_data["path_to_move"] ) );
47
  update_option( "acui_cron_period", sanitize_text_field( $form_data["period"] ) );
48
  update_option( "acui_cron_role", sanitize_text_field( $form_data["role"] ) );
49
- update_option( "acui_cron_update_roles_existing_users", isset( $form_data["update-roles-existing-users"] ) && $form_data["update-roles-existing-users"] == "yes" );
50
- update_option( "acui_cron_change_role_not_present", isset( $form_data["cron-change-role-not-present"] ) && $form_data["cron-change-role-not-present"] == "yes" );
51
- update_option( "acui_cron_change_role_not_present_role", sanitize_text_field( $form_data["cron-change-role-not-present-role"] ) );
 
 
52
  ?>
53
  <div class="updated">
54
  <p><?php _e( 'Settings updated correctly', 'import-users-from-csv-with-meta' ) ?></p>
@@ -123,7 +128,6 @@ class ACUI_Cron{
123
  $path_to_move_auto_rename = get_option( "acui_cron_path_to_move_auto_rename");
124
  $log = get_option( "acui_cron_log");
125
  $allow_multiple_accounts = get_option("acui_cron_allow_multiple_accounts");
126
- $loaded_periods = wp_get_schedules();
127
 
128
  $rest_api_execute_cron_url = home_url() . '/wp-json/import-users-from-csv-with-meta/v1/execute-cron/';
129
 
@@ -175,26 +179,28 @@ class ACUI_Cron{
175
  <tr class="form-field form-required">
176
  <th scope="row"><label for="cron-activated"><?php _e( 'Activate periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
177
  <td>
178
- <input type="checkbox" name="cron-activated" value="yes" <?php if( $cron_activated == true ) echo "checked='checked'"; ?>/>
179
  </td>
180
  </tr>
181
 
182
  <tr class="form-field">
183
  <th scope="row"><label for="path_to_file"><?php _e( "Path of file that are going to be imported", 'import-users-from-csv-with-meta' ); ?></label></th>
184
  <td>
185
- <input placeholder="<?php _e('Insert complete path to the file', 'import-users-from-csv-with-meta' ) ?>" type="text" name="path_to_file" id="path_to_file" value="<?php echo $path_to_file; ?>" style="width:70%;" />
186
  <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta' ); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv</p>
187
  </td>
188
  </tr>
189
 
190
  <tr class="form-field form-required">
191
  <th scope="row"><label for="period"><?php _e( 'Period', 'import-users-from-csv-with-meta' ); ?></label></th>
192
- <td>
193
- <select id="period" name="period">
194
- <?php foreach( $loaded_periods as $key => $value ): ?>
195
- <option <?php if( $period == $key ) echo "selected='selected'"; ?> value="<?php echo $key; ?>"><?php echo $value['display']; ?></option>
196
- <?php endforeach; ?>
197
- </select>
 
 
198
  <p class="description"><?php _e( 'How often the event should reoccur?', 'import-users-from-csv-with-meta' ); ?></p>
199
  </td>
200
  </tr>
@@ -202,36 +208,27 @@ class ACUI_Cron{
202
  <tr class="form-field form-required">
203
  <th scope="row"><label for="send-mail-cron"><?php _e( 'Send mail when using periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
204
  <td>
205
- <input type="checkbox" name="send-mail-cron" value="yes" <?php if( $send_mail_cron == true ) echo "checked='checked'"; ?>/>
206
  </td>
207
  </tr>
208
 
209
  <tr class="form-field form-required">
210
  <th scope="row"><label for="send-mail-updated"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
211
  <td>
212
- <input type="checkbox" name="send-mail-updated" value="yes" <?php if( $send_mail_updated == true ) echo "checked='checked'"; ?>/>
213
  </td>
214
  </tr>
215
 
216
  <tr class="form-field form-required">
217
  <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
218
  <td>
219
- <select id="role" name="role">
220
- <?php
221
- if( $role == '' )
222
- echo "<option selected='selected' value=''>" . __( 'Disable role assignment in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
223
- else
224
- echo "<option value=''>" . __( 'Disable role assignment in cron import', 'import-users-from-csv-with-meta' ) . "</option>";
225
-
226
- $list_roles = ACUI_Helper::get_editable_roles();
227
- foreach ($list_roles as $key => $value) {
228
- if($key == $role)
229
- echo "<option selected='selected' value='$key'>$value</option>";
230
- else
231
- echo "<option value='$key'>$value</option>";
232
- }
233
- ?>
234
- </select>
235
  <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
236
  </td>
237
  </tr>
@@ -239,7 +236,7 @@ class ACUI_Cron{
239
  <tr class="form-field form-required">
240
  <th scope="row"><label for="update-roles-existing-users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
241
  <td>
242
- <input type="checkbox" name="update-roles-existing-users" value="yes" <?php if( $update_roles_existing_users ) echo "checked='checked'"; ?>/>
243
  </td>
244
  </tr>
245
 
@@ -247,11 +244,11 @@ class ACUI_Cron{
247
  <th scope="row"><label for="move-file-cron"><?php _e( 'Move file after import?', 'import-users-from-csv-with-meta' ); ?></label></th>
248
  <td>
249
  <div style="float:left;">
250
- <input type="checkbox" name="move-file-cron" value="yes" <?php if( $move_file_cron == true ) echo "checked='checked'"; ?>/>
251
  </div>
252
 
253
  <div class="move-file-cron-cell" style="margin-left:25px;">
254
- <input placeholder="<?php _e( 'Insert complete path to the file', 'import-users-from-csv-with-meta'); ?>" type="text" name="path_to_move" id="path_to_move" value="<?php echo $path_to_move; ?>" style="width:70%;" />
255
  <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta'); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/move.csv</p>
256
  </div>
257
  </td>
@@ -261,7 +258,7 @@ class ACUI_Cron{
261
  <th scope="row"><label for="move-file-cron"><?php _e( 'Auto rename after move?', 'import-users-from-csv-with-meta' ); ?></label></th>
262
  <td>
263
  <div style="float:left;">
264
- <input type="checkbox" name="path_to_move_auto_rename" value="yes" <?php if( $path_to_move_auto_rename == true ) echo "checked='checked'"; ?>/>
265
  </div>
266
 
267
  <div style="margin-left:25px;">
@@ -282,25 +279,16 @@ class ACUI_Cron{
282
  <th scope="row"><label for="cron-delete-users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
283
  <td>
284
  <div style="float:left; margin-top: 10px;">
285
- <input type="checkbox" name="cron-delete-users" id="cron-delete-users" value="yes" <?php if( $cron_delete_users == true ) echo "checked='checked'"; ?>/>
286
  </div>
287
  <div style="margin-left:25px;">
288
- <select id="cron-delete-users-assign-posts" name="cron-delete-users-assign-posts">
289
- <?php
290
- if( $cron_delete_users_assign_posts == '' )
291
- echo "<option selected='selected' value=''>" . __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) . "</option>";
292
- else
293
- echo "<option value=''>" . __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) . "</option>";
294
-
295
- $blogusers = get_users( array( 'fields' => array( 'ID', 'display_name' ) ) );
296
-
297
- foreach ( $blogusers as $bloguser ) {
298
- if( $bloguser->ID == $cron_delete_users_assign_posts )
299
- echo "<option selected='selected' value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
300
- else
301
- echo "<option value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
302
- }
303
- ?>
304
  </select>
305
  <p class="description"><?php _e( 'Administrators will not be deleted anyway. After delete users, we can choose if we want to assign their posts to another user. If you do not choose some user, content will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
306
  </div>
@@ -311,17 +299,16 @@ class ACUI_Cron{
311
  <th scope="row"><label for="cron-change-role-not-present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
312
  <td>
313
  <div style="float:left; margin-top: 10px;">
314
- <input type="checkbox" name="cron-change-role-not-present" id="cron-change-role-not-present" value="yes" <?php checked( $cron_change_role_not_present ); ?> />
315
  </div>
316
  <div style="margin-left:25px;">
317
- <select name="cron-change-role-not-present-role" id="cron-change-role-not-present-role">
318
- <?php
319
- $list_roles = ACUI_Helper::get_editable_roles();
320
- foreach ($list_roles as $key => $value):
321
- ?>
322
- <option value='<?php echo $key; ?>' <?php selected( $cron_change_role_not_present_role, $key ); ?> ><?php echo $value; ?></option>
323
- <?php endforeach; ?>
324
- </select>
325
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
326
  </div>
327
  </td>
@@ -393,24 +380,20 @@ class ACUI_Cron{
393
 
394
  function check_delete_users_checked(){
395
  if( $('#cron-delete-users').is(':checked') ){
 
396
  $( '#cron-change-role-not-present-role' ).prop( 'disabled', true );
397
  $( '#cron-change-role-not-present' ).prop( 'disabled', true );
398
  } else {
 
399
  $( '#cron-change-role-not-present-role' ).prop( 'disabled', false );
400
  $( '#cron-change-role-not-present' ).prop( 'disabled', false );
401
  }
402
  }
403
 
404
  $( "[name='cron-delete-users']" ).change(function() {
405
- if( $(this).is( ":checked" ) ) {
406
  var returnVal = confirm("<?php _e( 'Are you sure to delete all users that are not present in the CSV? This action cannot be undone.', 'import-users-from-csv-with-meta' ); ?>");
407
- $(this).attr("checked", returnVal);
408
-
409
- if( returnVal )
410
- $( '#cron-delete-users-assign-posts' ).show();
411
- }
412
- else{
413
- $( '#cron-delete-users-assign-posts' ).hide();
414
  }
415
  });
416
 
@@ -423,10 +406,6 @@ class ACUI_Cron{
423
  }
424
  });
425
 
426
- <?php if( $cron_delete_users == '' ): ?>
427
- $( '#cron-delete-users-assign-posts' ).hide();
428
- <?php endif; ?>
429
-
430
  <?php if( !$move_file_cron ): ?>
431
  $( '.move-file-cron-cell' ).hide();
432
  <?php endif; ?>
17
  $next_timestamp = wp_next_scheduled( 'acui_cron_process' );
18
  $period = sanitize_text_field( $form_data[ "period" ] );
19
 
20
+ if( isset( $form_data["cron-activated"] ) && $form_data["cron-activated"] == "1" ){
21
  update_option( "acui_cron_activated", true );
22
 
23
  $old_period = get_option( "acui_cron_period" );
35
  wp_unschedule_event( $next_timestamp, 'acui_cron_process');
36
  }
37
 
38
+ update_option( "acui_cron_send_mail", isset( $form_data["send-mail-cron"] ) && $form_data["send-mail-cron"] == "1" );
39
+ update_option( "acui_cron_send_mail_updated", isset( $form_data["send-mail-updated"] ) && $form_data["send-mail-updated"] == "1" );
40
+ update_option( "acui_cron_delete_users", isset( $form_data["cron-delete-users"] ) && $form_data["cron-delete-users"] == "1" );
41
+
42
+ if( isset( $form_data["cron-delete-users-assign-posts"] ) )
43
+ update_option( "acui_cron_delete_users_assign_posts", sanitize_text_field( $form_data["cron-delete-users-assign-posts"] ) );
44
+
45
+ update_option( "acui_move_file_cron", isset( $form_data["move-file-cron"] ) && $form_data["move-file-cron"] == "1" );
46
+ update_option( "acui_cron_path_to_move_auto_rename", isset( $form_data["path_to_move_auto_rename"] ) && $form_data["path_to_move_auto_rename"] == "1" );
47
+ update_option( "acui_cron_allow_multiple_accounts", ( isset( $form_data["allow_multiple_accounts"] ) && $form_data["allow_multiple_accounts"] == "1" ) ? "allowed" : "not_allowed" );
48
  update_option( "acui_cron_path_to_file", sanitize_text_field( $form_data["path_to_file"] ) );
49
  update_option( "acui_cron_path_to_move", sanitize_text_field( $form_data["path_to_move"] ) );
50
  update_option( "acui_cron_period", sanitize_text_field( $form_data["period"] ) );
51
  update_option( "acui_cron_role", sanitize_text_field( $form_data["role"] ) );
52
+ update_option( "acui_cron_update_roles_existing_users", isset( $form_data["update-roles-existing-users"] ) && $form_data["update-roles-existing-users"] == "1" );
53
+ update_option( "acui_cron_change_role_not_present", isset( $form_data["cron-change-role-not-present"] ) && $form_data["cron-change-role-not-present"] == "1" );
54
+
55
+ if( isset( $form_data["cron-change-role-not-present-role"] ) )
56
+ update_option( "acui_cron_change_role_not_present_role", sanitize_text_field( $form_data["cron-change-role-not-present-role"] ) );
57
  ?>
58
  <div class="updated">
59
  <p><?php _e( 'Settings updated correctly', 'import-users-from-csv-with-meta' ) ?></p>
128
  $path_to_move_auto_rename = get_option( "acui_cron_path_to_move_auto_rename");
129
  $log = get_option( "acui_cron_log");
130
  $allow_multiple_accounts = get_option("acui_cron_allow_multiple_accounts");
 
131
 
132
  $rest_api_execute_cron_url = home_url() . '/wp-json/import-users-from-csv-with-meta/v1/execute-cron/';
133
 
179
  <tr class="form-field form-required">
180
  <th scope="row"><label for="cron-activated"><?php _e( 'Activate periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
181
  <td>
182
+ <?php ACUIHTML()->checkbox( array( 'name' => 'cron-activated', 'compare_value' => $cron_activated ) ); ?>
183
  </td>
184
  </tr>
185
 
186
  <tr class="form-field">
187
  <th scope="row"><label for="path_to_file"><?php _e( "Path of file that are going to be imported", 'import-users-from-csv-with-meta' ); ?></label></th>
188
  <td>
189
+ <?php ACUIHTML()->text( array( 'name' => 'path_to_file', 'value' => $path_to_file, 'class' => '', 'placeholder' => __( 'Insert complete path to the file', 'import-users-from-csv-with-meta' ) ) ); ?>
190
  <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta' ); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/test.csv</p>
191
  </td>
192
  </tr>
193
 
194
  <tr class="form-field form-required">
195
  <th scope="row"><label for="period"><?php _e( 'Period', 'import-users-from-csv-with-meta' ); ?></label></th>
196
+ <td>
197
+ <?php ACUIHTML()->select( array(
198
+ 'options' => ACUI_Helper::get_loaded_periods(),
199
+ 'name' => 'period',
200
+ 'selected' => $period,
201
+ 'show_option_all' => false,
202
+ 'show_option_none' => false,
203
+ )); ?>
204
  <p class="description"><?php _e( 'How often the event should reoccur?', 'import-users-from-csv-with-meta' ); ?></p>
205
  </td>
206
  </tr>
208
  <tr class="form-field form-required">
209
  <th scope="row"><label for="send-mail-cron"><?php _e( 'Send mail when using periodical import?', 'import-users-from-csv-with-meta' ); ?></label></th>
210
  <td>
211
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send-mail-cron', 'compare_value' => $send_mail_cron ) ); ?>
212
  </td>
213
  </tr>
214
 
215
  <tr class="form-field form-required">
216
  <th scope="row"><label for="send-mail-updated"><?php _e( 'Send mail also to users that are being updated?', 'import-users-from-csv-with-meta' ); ?></label></th>
217
  <td>
218
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send-mail-updated', 'compare_value' => $send_mail_updated ) ); ?>
219
  </td>
220
  </tr>
221
 
222
  <tr class="form-field form-required">
223
  <th scope="row"><label for="role"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></label></th>
224
  <td>
225
+ <?php ACUIHTML()->select( array(
226
+ 'options' => ACUI_Helper::get_editable_roles(),
227
+ 'name' => 'role',
228
+ 'selected' => $role,
229
+ 'show_option_all' => false,
230
+ 'show_option_none' => __( 'Disable role assignment in cron import', 'import-users-from-csv-with-meta' ),
231
+ )); ?>
 
 
 
 
 
 
 
 
 
232
  <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
233
  </td>
234
  </tr>
236
  <tr class="form-field form-required">
237
  <th scope="row"><label for="update-roles-existing-users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
238
  <td>
239
+ <?php ACUIHTML()->checkbox( array( 'name' => 'update-roles-existing-users', 'compare_value' => $update_roles_existing_users ) ); ?>
240
  </td>
241
  </tr>
242
 
244
  <th scope="row"><label for="move-file-cron"><?php _e( 'Move file after import?', 'import-users-from-csv-with-meta' ); ?></label></th>
245
  <td>
246
  <div style="float:left;">
247
+ <?php ACUIHTML()->checkbox( array( 'name' => 'move-file-cron', 'compare_value' => $move_file_cron ) ); ?>
248
  </div>
249
 
250
  <div class="move-file-cron-cell" style="margin-left:25px;">
251
+ <?php ACUIHTML()->text( array( 'name' => 'path_to_move', 'value' => $path_to_move, 'class' => '', 'placeholder' => __( 'Insert complete path to the file', 'import-users-from-csv-with-meta' ) ) ); ?>
252
  <p class="description"><?php _e( 'You have to introduce the path to file, i.e.:', 'import-users-from-csv-with-meta'); ?> <?php $upload_dir = wp_upload_dir(); echo $upload_dir["path"]; ?>/move.csv</p>
253
  </div>
254
  </td>
258
  <th scope="row"><label for="move-file-cron"><?php _e( 'Auto rename after move?', 'import-users-from-csv-with-meta' ); ?></label></th>
259
  <td>
260
  <div style="float:left;">
261
+ <?php ACUIHTML()->checkbox( array( 'name' => 'path_to_move_auto_rename', 'compare_value' => $path_to_move_auto_rename ) ); ?>
262
  </div>
263
 
264
  <div style="margin-left:25px;">
279
  <th scope="row"><label for="cron-delete-users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
280
  <td>
281
  <div style="float:left; margin-top: 10px;">
282
+ <?php ACUIHTML()->checkbox( array( 'name' => 'cron-delete-users', 'compare_value' => $cron_delete_users ) ); ?>
283
  </div>
284
  <div style="margin-left:25px;">
285
+ <?php ACUIHTML()->select( array(
286
+ 'options' => ACUI_Helper::get_list_users_with_display_name(),
287
+ 'name' => 'cron-delete-users-assign-posts',
288
+ 'selected' => $cron_delete_users_assign_posts,
289
+ 'show_option_all' => false,
290
+ 'show_option_none' => __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ),
291
+ )); ?>
 
 
 
 
 
 
 
 
 
292
  </select>
293
  <p class="description"><?php _e( 'Administrators will not be deleted anyway. After delete users, we can choose if we want to assign their posts to another user. If you do not choose some user, content will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
294
  </div>
299
  <th scope="row"><label for="cron-change-role-not-present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
300
  <td>
301
  <div style="float:left; margin-top: 10px;">
302
+ <?php ACUIHTML()->checkbox( array( 'name' => 'cron-change-role-not-present', 'compare_value' => $cron_change_role_not_present ) ); ?>
303
  </div>
304
  <div style="margin-left:25px;">
305
+ <?php ACUIHTML()->select( array(
306
+ 'options' => ACUI_Helper::get_editable_roles(),
307
+ 'name' => 'cron-change-role-not-present-role',
308
+ 'selected' => $cron_change_role_not_present_role,
309
+ 'show_option_all' => false,
310
+ 'show_option_none' => false,
311
+ )); ?>
 
312
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
313
  </div>
314
  </td>
380
 
381
  function check_delete_users_checked(){
382
  if( $('#cron-delete-users').is(':checked') ){
383
+ $( '#cron-delete-users-assign-posts' ).prop( 'disabled', false );
384
  $( '#cron-change-role-not-present-role' ).prop( 'disabled', true );
385
  $( '#cron-change-role-not-present' ).prop( 'disabled', true );
386
  } else {
387
+ $( '#cron-delete-users-assign-posts' ).prop( 'disabled', true );
388
  $( '#cron-change-role-not-present-role' ).prop( 'disabled', false );
389
  $( '#cron-change-role-not-present' ).prop( 'disabled', false );
390
  }
391
  }
392
 
393
  $( "[name='cron-delete-users']" ).change(function() {
394
+ if( $ (this ).is( ":checked" ) ) {
395
  var returnVal = confirm("<?php _e( 'Are you sure to delete all users that are not present in the CSV? This action cannot be undone.', 'import-users-from-csv-with-meta' ); ?>");
396
+ $( this ).prop( "checked", returnVal );
 
 
 
 
 
 
397
  }
398
  });
399
 
406
  }
407
  });
408
 
 
 
 
 
409
  <?php if( !$move_file_cron ): ?>
410
  $( '.move-file-cron-cell' ).hide();
411
  <?php endif; ?>
classes/email-options.php CHANGED
@@ -33,10 +33,13 @@ class ACUI_Email_Options{
33
  <span><?php _e( 'User created or edited', 'import-users-from-csv-with-meta' ); ?></span>
34
  </legend>
35
  <label for="automatic_created_edited_wordpress_email">
36
- <select name="automatic_created_edited_wordpress_email" id="automatic_created_edited_wordpress_email">
37
- <option <?php selected( $automatic_created_edited_wordpress_email, "false" ); ?> value="false"><?php _e( "Deactivate WordPress automatic email when an user is created or edited", 'import-users-from-csv-with-meta' ) ;?></option>
38
- <option <?php selected( $automatic_created_edited_wordpress_email, "true" ); ?> value="true"><?php _e( 'Activate WordPress automatic email when an user is created or edited', 'import-users-from-csv-with-meta' ); ?></option>
39
- </select>
 
 
 
40
  <span class="description"><? _e( "When you create or update an user, WordPress prepare and send automatic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
41
  </label>
42
  </fieldset>
@@ -50,10 +53,13 @@ class ACUI_Email_Options{
50
  <span><?php _e( 'Send automatic change password WordPress emails?', 'import-users-from-csv-with-meta' ); ?></span>
51
  </legend>
52
  <label for="automatic_wordpress_email">
53
- <select name="automatic_wordpress_email" id="automatic_wordpress_email">
54
- <option <?php selected( $automatic_wordpress_email, "false" ); ?> value="false"><?php _e( "Deactivate WordPress automatic email when an user is updated or his password is changed", 'import-users-from-csv-with-meta' ) ;?></option>
55
- <option <?php selected( $automatic_wordpress_email, "true" ); ?> value="true"><?php _e( 'Activate WordPress automatic email when an user is updated or his password is changed', 'import-users-from-csv-with-meta' ); ?></option>
56
- </select>
 
 
 
57
  <span class="description"><? _e( "When you update an user or change his password, WordPress prepare and send automatic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
58
  </label>
59
  </fieldset>
@@ -67,7 +73,7 @@ class ACUI_Email_Options{
67
  <span><?php _e( 'Do you want to enable mail templates?', 'import-users-from-csv-with-meta' ); ?></span>
68
  </legend>
69
  <label for="enable_email_templates">
70
- <input id="enable_email_templates" name="enable_email_templates" value="yes" type="checkbox" <?php checked( $enable_email_templates ); ?>>
71
  <span class="description"><? _e( "If you activate it, a new option in the menu will be created to store and manage mail templates, instead of using only the next one.", 'import-users-from-csv-with-meta' ); ?></span>
72
  </label>
73
  </fieldset>
@@ -83,7 +89,7 @@ class ACUI_Email_Options{
83
  <span><?php _e( 'Do you want to disable WP Editor?', 'import-users-from-csv-with-meta' ); ?></span>
84
  </legend>
85
  <label for="disable_wp_editor">
86
- <input id="disable_wp_editor" name="disable_wp_editor" value="yes" type="checkbox" <?php checked( $disable_wp_editor ); ?>>
87
  <span class="description"><?php _e( 'If you want to use email with custom HTML and CSS tags, disable WP Editor', 'import-users-from-csv-with-meta' ); ?></span>
88
  </label>
89
  </fieldset>
@@ -113,7 +119,7 @@ class ACUI_Email_Options{
113
  <fieldset>
114
  <div>
115
  <label for="email_template_attachment_file"><?php _e( 'Attachment', 'import-users-from-csv-with-meta' )?></label><br>
116
- <input type="url" class="large-text" name="email_template_attachment_file" id="email_template_attachment_file" value="<?php echo wp_get_attachment_url( $attachment_id ); ?>" readonly/><br>
117
  <input type="hidden" name="email_template_attachment_id" id="email_template_attachment_id" value="<?php echo $attachment_id ?>"/>
118
  <button type="button" class="button" id="acui_email_option_upload_button"><?php _e( 'Upload file', 'import-users-from-csv-with-meta' )?></button>
119
  <button type="button" class="button" id="acui_email_option_remove_upload_button"><?php _e( 'Remove file', 'import-users-from-csv-with-meta' )?></button>
@@ -154,7 +160,7 @@ class ACUI_Email_Options{
154
  $body_mail = wp_kses_post( stripslashes( $form_data["body_mail"] ) );
155
  $template_id = intval( $form_data["template_id"] );
156
  $email_template_attachment_id = intval( $form_data["email_template_attachment_id"] );
157
- $disable_wp_editor = isset( $form_data['disable_wp_editor'] ) && $form_data['disable_wp_editor'] == 'yes';
158
 
159
  remove_filter( 'wp_kses_allowed_html', array( $this, 'allow_more_post_tags' ), 10, 2 );
160
 
33
  <span><?php _e( 'User created or edited', 'import-users-from-csv-with-meta' ); ?></span>
34
  </legend>
35
  <label for="automatic_created_edited_wordpress_email">
36
+ <?php ACUIHTML()->select( array(
37
+ 'options' => array( 'false' => __( "Deactivate WordPress automatic email when an user is created or edited", 'import-users-from-csv-with-meta' ), 'true' => __( 'Activate WordPress automatic email when an user is created or edited', 'import-users-from-csv-with-meta' ) ),
38
+ 'name' => 'automatic_created_edited_wordpress_email',
39
+ 'selected' => $automatic_created_edited_wordpress_email,
40
+ 'show_option_all' => false,
41
+ 'show_option_none' => false,
42
+ )); ?>
43
  <span class="description"><? _e( "When you create or update an user, WordPress prepare and send automatic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
44
  </label>
45
  </fieldset>
53
  <span><?php _e( 'Send automatic change password WordPress emails?', 'import-users-from-csv-with-meta' ); ?></span>
54
  </legend>
55
  <label for="automatic_wordpress_email">
56
+ <?php ACUIHTML()->select( array(
57
+ 'options' => array( 'false' => __( "Deactivate WordPress automatic email when an user is updated or his password is changed", 'import-users-from-csv-with-meta' ), 'true' => __( 'Activate WordPress automatic email when an user is updated or his password is changed', 'import-users-from-csv-with-meta' ) ),
58
+ 'name' => 'automatic_wordpress_email',
59
+ 'selected' => $automatic_wordpress_email,
60
+ 'show_option_all' => false,
61
+ 'show_option_none' => false,
62
+ )); ?>
63
  <span class="description"><? _e( "When you update an user or change his password, WordPress prepare and send automatic email, you can deactivate it here.", 'import-users-from-csv-with-meta' ); ?></span>
64
  </label>
65
  </fieldset>
73
  <span><?php _e( 'Do you want to enable mail templates?', 'import-users-from-csv-with-meta' ); ?></span>
74
  </legend>
75
  <label for="enable_email_templates">
76
+ <?php ACUIHTML()->checkbox( array( 'name' => 'enable_email_templates', 'compare_value' => $enable_email_templates ) ); ?>
77
  <span class="description"><? _e( "If you activate it, a new option in the menu will be created to store and manage mail templates, instead of using only the next one.", 'import-users-from-csv-with-meta' ); ?></span>
78
  </label>
79
  </fieldset>
89
  <span><?php _e( 'Do you want to disable WP Editor?', 'import-users-from-csv-with-meta' ); ?></span>
90
  </legend>
91
  <label for="disable_wp_editor">
92
+ <?php ACUIHTML()->checkbox( array( 'name' => 'disable_wp_editor', 'compare_value' => $disable_wp_editor ) ); ?>
93
  <span class="description"><?php _e( 'If you want to use email with custom HTML and CSS tags, disable WP Editor', 'import-users-from-csv-with-meta' ); ?></span>
94
  </label>
95
  </fieldset>
119
  <fieldset>
120
  <div>
121
  <label for="email_template_attachment_file"><?php _e( 'Attachment', 'import-users-from-csv-with-meta' )?></label><br>
122
+ <?php ACUIHTML()->text( array( 'type' => 'url', 'name' => 'email_template_attachment_file', 'value' => wp_get_attachment_url( $attachment_id ), 'class' => 'large-text', 'readonly' => true ) ); ?>
123
  <input type="hidden" name="email_template_attachment_id" id="email_template_attachment_id" value="<?php echo $attachment_id ?>"/>
124
  <button type="button" class="button" id="acui_email_option_upload_button"><?php _e( 'Upload file', 'import-users-from-csv-with-meta' )?></button>
125
  <button type="button" class="button" id="acui_email_option_remove_upload_button"><?php _e( 'Remove file', 'import-users-from-csv-with-meta' )?></button>
160
  $body_mail = wp_kses_post( stripslashes( $form_data["body_mail"] ) );
161
  $template_id = intval( $form_data["template_id"] );
162
  $email_template_attachment_id = intval( $form_data["email_template_attachment_id"] );
163
+ $disable_wp_editor = isset( $form_data['disable_wp_editor'] ) && $form_data['disable_wp_editor'] == '1';
164
 
165
  remove_filter( 'wp_kses_allowed_html', array( $this, 'allow_more_post_tags' ), 10, 2 );
166
 
classes/email-templates.php CHANGED
@@ -89,8 +89,8 @@ class ACUI_Email_Template{
89
  }
90
 
91
  function refresh_enable_email_templates(){
92
- check_ajax_referer( 'codection-security', 'security' );
93
- update_option( 'acui_enable_email_templates', ( $_POST[ 'enable' ] == "true" ) );
94
  wp_die();
95
  }
96
 
89
  }
90
 
91
  function refresh_enable_email_templates(){
92
+ check_ajax_referer( 'codection-security', 'security' );
93
+ update_option( 'acui_enable_email_templates', ( $_POST[ 'enable' ] == "true" ) );
94
  wp_die();
95
  }
96
 
classes/export.php CHANGED
@@ -80,7 +80,6 @@ class ACUI_Exporter{
80
  }
81
 
82
  static function admin_gui(){
83
- $roles = ACUI_Helper::get_editable_roles();
84
  ?>
85
  <h3 id="acui_export_users_header"><?php _e( 'Export users', 'import-users-from-csv-with-meta' ); ?></h3>
86
  <form id="acui_exporter">
@@ -89,51 +88,51 @@ class ACUI_Exporter{
89
  <tr id="acui_role_wrapper" valign="top">
90
  <th scope="row"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></th>
91
  <td>
92
- <select name="role">
93
- <option value=''><?php _e( 'All roles', 'import-users-from-csv-with-meta' ); ?></option>
94
- <?php foreach ( $roles as $key => $value ): ?>
95
- <option value='<?php echo $key; ?>'><?php echo $value; ?></option>
96
- <?php endforeach; ?>
97
- </select>
98
  </td>
99
  </tr>
100
  <tr id="acui_user_created_wrapper" valign="top">
101
  <th scope="row"><?php _e( 'User created', 'import-users-from-csv-with-meta' ); ?></th>
102
  <td>
103
- <label for="from">from <input name="from" type="date" value=""/></label>
104
- <label for="to">to <input name="to" type="date" value=""/></label>
105
  </td>
106
  </tr>
107
  <tr id="acui_delimiter_wrapper" valign="top">
108
  <th scope="row"><?php _e( 'Delimiter', 'import-users-from-csv-with-meta' ); ?></th>
109
  <td>
110
- <select name="delimiter">
111
- <option value='COMMA'><?php _e( 'Comma', 'import-users-from-csv-with-meta' ); ?></option>
112
- <option value='COLON'><?php _e( 'Colon', 'import-users-from-csv-with-meta' ); ?></option>
113
- <option value='SEMICOLON'><?php _e( 'Semicolon', 'import-users-from-csv-with-meta' ); ?></option>
114
- <option value='TAB'><?php _e( 'Tab', 'import-users-from-csv-with-meta' ); ?></option>
115
- </select>
116
  </td>
117
  </tr>
118
  <tr id="acui_timestamp_wrapper" valign="top">
119
  <th scope="row"><?php _e( 'Convert timestamp data to date format', 'import-users-from-csv-with-meta' ); ?></th>
120
  <td>
121
- <input type="checkbox" name="convert_timestamp" id="convert_timestamp" value="1" checked="checked">
122
- <input name="datetime_format" id="datetime_format" type="text" value="Y-m-d H:i:s"/>
123
  <span class="description"><a href="https://www.php.net/manual/en/datetime.formats.php"><?php _e( 'accepted formats', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'If you have problems and you get some value exported as a date that should not be converted to date, please deactivate this option. If this option is not activated, datetime format will be ignored.', 'import-users-from-csv-with-meta' ); ?></span>
124
  </td>
125
  </tr>
126
  <tr id="acui_order_fields_alphabetically_wrapper" valign="top">
127
  <th scope="row"><?php _e( 'Order fields alphabetically', 'import-users-from-csv-with-meta' ); ?></th>
128
  <td>
129
- <input type="checkbox" name="order_fields_alphabetically" value="1">
130
  <span class="description"><?php _e( "Order all columns alphabetically to check easier your data. First two columns won't be affected", 'import-users-from-csv-with-meta' ); ?></span>
131
  </td>
132
  </tr>
133
  <tr id="acui_order_fields_double_encapsulate_serialized_values" valign="top">
134
  <th scope="row"><?php _e( 'Double encapsulate serialized values', 'import-users-from-csv-with-meta' ); ?></th>
135
  <td>
136
- <input type="checkbox" name="double_encapsulate_serialized_values" value="1">
137
  <span class="description"><?php _e( "Serialized values sometimes can have problems being displayed in Microsoft Excel or LibreOffice, we can double encapsulate this kind of data but you would not be able to import this data beucase instead of serialized data it would be managed as strings", 'import-users-from-csv-with-meta' ); ?></span>
138
  </td>
139
  </tr>
80
  }
81
 
82
  static function admin_gui(){
 
83
  ?>
84
  <h3 id="acui_export_users_header"><?php _e( 'Export users', 'import-users-from-csv-with-meta' ); ?></h3>
85
  <form id="acui_exporter">
88
  <tr id="acui_role_wrapper" valign="top">
89
  <th scope="row"><?php _e( 'Role', 'import-users-from-csv-with-meta' ); ?></th>
90
  <td>
91
+ <?php ACUIHTML()->select( array(
92
+ 'options' => ACUI_Helper::get_editable_roles(),
93
+ 'name' => 'role',
94
+ 'show_option_all' => false,
95
+ 'show_option_none' => __( 'All roles', 'import-users-from-csv-with-meta' ),
96
+ )); ?>
97
  </td>
98
  </tr>
99
  <tr id="acui_user_created_wrapper" valign="top">
100
  <th scope="row"><?php _e( 'User created', 'import-users-from-csv-with-meta' ); ?></th>
101
  <td>
102
+ <label for="from">from <?php ACUIHTML()->text( array( 'type' => 'date', 'name' => 'from', 'class' => '' ) ); ?></label>
103
+ <label for="to">to <?php ACUIHTML()->text( array( 'type' => 'date', 'name' => 'to', 'class' => '' ) ); ?></label>
104
  </td>
105
  </tr>
106
  <tr id="acui_delimiter_wrapper" valign="top">
107
  <th scope="row"><?php _e( 'Delimiter', 'import-users-from-csv-with-meta' ); ?></th>
108
  <td>
109
+ <?php ACUIHTML()->select( array(
110
+ 'options' => ACUI_Helper::get_csv_delimiters_titles(),
111
+ 'name' => 'delimiter',
112
+ 'show_option_all' => false,
113
+ 'show_option_none' => false,
114
+ )); ?>
115
  </td>
116
  </tr>
117
  <tr id="acui_timestamp_wrapper" valign="top">
118
  <th scope="row"><?php _e( 'Convert timestamp data to date format', 'import-users-from-csv-with-meta' ); ?></th>
119
  <td>
120
+ <?php ACUIHTML()->checkbox( array( 'name' => 'convert_timestamp', 'current' => 0 ) ); ?>
121
+ <?php ACUIHTML()->text( array( 'name' => 'datetime_format', 'value' => 'Y-m-d H:i:s', 'class' => '' ) ); ?>
122
  <span class="description"><a href="https://www.php.net/manual/en/datetime.formats.php"><?php _e( 'accepted formats', 'import-users-from-csv-with-meta' ); ?></a> <?php _e( 'If you have problems and you get some value exported as a date that should not be converted to date, please deactivate this option. If this option is not activated, datetime format will be ignored.', 'import-users-from-csv-with-meta' ); ?></span>
123
  </td>
124
  </tr>
125
  <tr id="acui_order_fields_alphabetically_wrapper" valign="top">
126
  <th scope="row"><?php _e( 'Order fields alphabetically', 'import-users-from-csv-with-meta' ); ?></th>
127
  <td>
128
+ <?php ACUIHTML()->checkbox( array( 'name' => 'order_fields_alphabetically', 'current' => 0 ) ); ?>
129
  <span class="description"><?php _e( "Order all columns alphabetically to check easier your data. First two columns won't be affected", 'import-users-from-csv-with-meta' ); ?></span>
130
  </td>
131
  </tr>
132
  <tr id="acui_order_fields_double_encapsulate_serialized_values" valign="top">
133
  <th scope="row"><?php _e( 'Double encapsulate serialized values', 'import-users-from-csv-with-meta' ); ?></th>
134
  <td>
135
+ <?php ACUIHTML()->checkbox( array( 'name' => 'double_encapsulate_serialized_values', 'current' => 0 ) ); ?>
136
  <span class="description"><?php _e( "Serialized values sometimes can have problems being displayed in Microsoft Excel or LibreOffice, we can double encapsulate this kind of data but you would not be able to import this data beucase instead of serialized data it would be managed as strings", 'import-users-from-csv-with-meta' ); ?></span>
137
  </td>
138
  </tr>
classes/frontend.php CHANGED
@@ -76,22 +76,13 @@ class ACUI_Frontend{
76
  <tr class="form-field form-required">
77
  <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
78
  <td>
79
- <select id="role-frontend" name="role-frontend">
80
- <?php
81
- if( $role == '' )
82
- echo "<option selected='selected' value=''>" . __( 'Disable role assignment in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
83
- else
84
- echo "<option value=''>" . __( 'Disable role assignment in frontend import', 'import-users-from-csv-with-meta' ) . "</option>";
85
-
86
- $list_roles = ACUI_Helper::get_editable_roles();
87
- foreach ($list_roles as $key => $value) {
88
- if($key == $role)
89
- echo "<option selected='selected' value='$key'>$value</option>";
90
- else
91
- echo "<option value='$key'>$value</option>";
92
- }
93
- ?>
94
- </select>
95
  <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
96
  </td>
97
  </tr>
@@ -106,12 +97,10 @@ class ACUI_Frontend{
106
  <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
107
  <td>
108
  <p id="sends_email_wrapper">
109
- <?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
110
- <input type="checkbox" name="send-mail-frontend" value="yes" <?php checked( $send_mail_frontend ); ?>/>
111
  </p>
112
  <p id="send_email_updated_wrapper">
113
- <?php _e( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ); ?>
114
- <input type="checkbox" name="send-mail-updated-frontend" value="yes" <?php checked( $send_mail_updated_frontend ); ?>/>
115
  </p>
116
  </td>
117
  </tr>
@@ -119,7 +108,7 @@ class ACUI_Frontend{
119
  <tr class="form-field form-required">
120
  <th scope="row"><label for=""><?php _e( 'Force users to reset their passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
121
  <td>
122
- <input type="checkbox" name="force_user_reset_password" value="yes" <?php checked( get_option( 'acui_frontend_force_user_reset_password' ) ); ?>/>
123
  <p class="description"><?php _e( 'If a password is set to an user and you activate this option, the user will be forced to reset their password in their first login', 'import-users-from-csv-with-meta' ); ?></p>
124
  </td>
125
  </tr>
@@ -128,10 +117,10 @@ class ACUI_Frontend{
128
  <th scope="row"><label for="send_mail_admin_frontend"><?php _e( 'Send notification to admin when the frontend importer is used?', 'import-users-from-csv-with-meta' ); ?></label></th>
129
  <td>
130
  <div style="float:left; margin-top: 10px;">
131
- <input type="checkbox" id="send_mail_admin_frontend" name="send_mail_admin_frontend" value="yes" <?php checked( $send_mail_admin_frontend ); ?>/>
132
  </div>
133
  <div style="margin-left:25px;">
134
- <input type="text" id="send_mail_admin_frontend_address_list" name="send_mail_admin_frontend_address_list" value="<?php echo $send_mail_admin_adress_list_frontend; ?>" placeholder="<?php _e( 'Include a list of emails where notification will be sent, use commas to separate addresses', 'import-users-from-csv-with-meta' ); ?>"/>
135
  <p class="description"><?php _e( 'If list is empty, the admin email will be used', 'import-users-from-csv-with-meta' ); ?></p>
136
  </div>
137
  </td>
@@ -146,21 +135,26 @@ class ACUI_Frontend{
146
  <tr class="form-field form-required">
147
  <th scope="row"><label><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
148
  <td>
149
- <select name="update_existing_users">
150
- <option value="yes" <?php selected( $update_existing_users, "yes" ); ?>><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
151
- <option value="no" <?php selected( $update_existing_users, "no" ); ?>><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
152
- </select>
 
 
 
153
  </td>
154
  </tr>
155
 
156
  <tr class="form-field form-required">
157
  <th scope="row"><label><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
158
  <td>
159
- <select name="update_roles_existing_users">
160
- <option value="no" <?php selected( $update_roles_existing_users, "no" ); ?>><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
161
- <option value="yes" <?php selected( $update_roles_existing_users, "yes" ); ?>><?php _e( 'Yes, update and override existing roles', 'import-users-from-csv-with-meta' ); ?></option>
162
- <option value="yes_no_override" <?php selected( $update_roles_existing_users, "yes_no_override" ); ?>><?php _e( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ); ?></option>
163
- </select>
 
 
164
  </td>
165
  </tr>
166
  </tbody>
@@ -173,27 +167,17 @@ class ACUI_Frontend{
173
  <tr class="form-field form-required">
174
  <th scope="row"><label for="delete_users_frontend"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
175
  <td>
176
- <div style="float:left; margin-top: 10px;">
177
- <input type="checkbox" name="delete_users_frontend" id="delete_users_frontend" value="yes" <?php if( $delete_users_frontend == true ) echo "checked='checked'"; ?>/>
178
  </div>
179
  <div style="margin-left:25px;">
180
- <select id="delete-users-assign-posts-frontend" name="delete-users-assign-posts-frontend">
181
- <?php
182
- if( $delete_users_assign_posts_frontend == '' )
183
- echo "<option selected='selected' value=''>" . __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) . "</option>";
184
- else
185
- echo "<option value=''>" . __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) . "</option>";
186
-
187
- $blogusers = get_users( array( 'fields' => array( 'ID', 'display_name' ) ) );
188
-
189
- foreach ( $blogusers as $bloguser ) {
190
- if( $bloguser->ID == $delete_users_assign_posts_frontend )
191
- echo "<option selected='selected' value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
192
- else
193
- echo "<option value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
194
- }
195
- ?>
196
- </select>
197
  <p class="description"><?php _e( 'After delete users, we can choose if we want to assign their posts to another user. Please do not delete them or posts will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
198
  </div>
199
  </td>
@@ -203,17 +187,16 @@ class ACUI_Frontend{
203
  <th scope="row"><label for="change_role_not_present_frontend"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
204
  <td>
205
  <div style="float:left; margin-top: 10px;">
206
- <input type="checkbox" name="change_role_not_present_frontend" id="change_role_not_present_frontend" value="yes" <?php checked( $change_role_not_present_frontend ); ?> />
207
  </div>
208
  <div style="margin-left:25px;">
209
- <select name="change_role_not_present_role_frontend" id="change_role_not_present_role_frontend">
210
- <?php
211
- $list_roles = ACUI_Helper::get_editable_roles();
212
- foreach ($list_roles as $key => $value):
213
- ?>
214
- <option value='<?php echo $key; ?>' <?php selected( $change_role_not_present_role_frontend, $key ); ?>><?php echo $value; ?></option>
215
- <?php endforeach; ?>
216
- </select>
217
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
218
  </div>
219
  </td>
76
  <tr class="form-field form-required">
77
  <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
78
  <td>
79
+ <?php ACUIHTML()->select( array(
80
+ 'options' => ACUI_Helper::get_editable_roles(),
81
+ 'name' => 'role-frontend',
82
+ 'selected' => $role,
83
+ 'show_option_all' => false,
84
+ 'show_option_none' => __( 'Disable role assignment in frontend import', 'import-users-from-csv-with-meta' ),
85
+ )); ?>
 
 
 
 
 
 
 
 
 
86
  <p class="description"><?php _e( 'Which role would be used to import users?', 'import-users-from-csv-with-meta' ); ?></p>
87
  </td>
88
  </tr>
97
  <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
98
  <td>
99
  <p id="sends_email_wrapper">
100
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send-mail-frontend', 'label' => __( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ), 'compare_value' => $send_mail_frontend ) ); ?>
 
101
  </p>
102
  <p id="send_email_updated_wrapper">
103
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send-mail-updated-frontend', 'label' => __( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ), 'compare_value' => $send_mail_updated_frontend ) ); ?>
 
104
  </p>
105
  </td>
106
  </tr>
108
  <tr class="form-field form-required">
109
  <th scope="row"><label for=""><?php _e( 'Force users to reset their passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
110
  <td>
111
+ <?php ACUIHTML()->checkbox( array( 'name' => 'force_user_reset_password', 'compare_value' => get_option( 'acui_frontend_force_user_reset_password' ) ) ); ?>
112
  <p class="description"><?php _e( 'If a password is set to an user and you activate this option, the user will be forced to reset their password in their first login', 'import-users-from-csv-with-meta' ); ?></p>
113
  </td>
114
  </tr>
117
  <th scope="row"><label for="send_mail_admin_frontend"><?php _e( 'Send notification to admin when the frontend importer is used?', 'import-users-from-csv-with-meta' ); ?></label></th>
118
  <td>
119
  <div style="float:left; margin-top: 10px;">
120
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send_mail_admin_frontend', 'compare_value' => $send_mail_admin_frontend ) ); ?>
121
  </div>
122
  <div style="margin-left:25px;">
123
+ <?php ACUIHTML()->text( array( 'name' => 'send_mail_admin_frontend_address_list', 'value' => $send_mail_admin_adress_list_frontend, 'class' => '', 'placeholder' => __( 'Include a list of emails where notification will be sent, use commas to separate addresses', 'import-users-from-csv-with-meta' ) ) ); ?>
124
  <p class="description"><?php _e( 'If list is empty, the admin email will be used', 'import-users-from-csv-with-meta' ); ?></p>
125
  </div>
126
  </td>
135
  <tr class="form-field form-required">
136
  <th scope="row"><label><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
137
  <td>
138
+ <?php ACUIHTML()->select( array(
139
+ 'options' => array( 'yes' => __( 'Yes', 'import-users-from-csv-with-meta' ), 'no' => __( 'No', 'import-users-from-csv-with-meta' ) ),
140
+ 'name' => 'update_existing_users',
141
+ 'selected' => $update_existing_users,
142
+ 'show_option_all' => false,
143
+ 'show_option_none' => false,
144
+ )); ?>
145
  </td>
146
  </tr>
147
 
148
  <tr class="form-field form-required">
149
  <th scope="row"><label><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
150
  <td>
151
+ <?php ACUIHTML()->select( array(
152
+ 'options' => array( 'yes' => __( 'Yes', 'import-users-from-csv-with-meta' ), 'no' => __( 'No', 'import-users-from-csv-with-meta' ), 'yes_no_override' => __( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ) ),
153
+ 'name' => 'update_roles_existing_users',
154
+ 'selected' => $update_roles_existing_users,
155
+ 'show_option_all' => false,
156
+ 'show_option_none' => false,
157
+ )); ?>
158
  </td>
159
  </tr>
160
  </tbody>
167
  <tr class="form-field form-required">
168
  <th scope="row"><label for="delete_users_frontend"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
169
  <td>
170
+ <div style="float:left; margin-top: 10px;">
171
+ <?php ACUIHTML()->checkbox( array( 'name' => 'delete_users_frontend', 'compare_value' => $delete_users_frontend ) ); ?>
172
  </div>
173
  <div style="margin-left:25px;">
174
+ <?php ACUIHTML()->select( array(
175
+ 'options' => ACUI_Helper::get_list_users_with_display_name(),
176
+ 'name' => 'delete-users-assign-posts-frontend',
177
+ 'selected' => $delete_users_assign_posts_frontend,
178
+ 'show_option_all' => false,
179
+ 'show_option_none' => __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ),
180
+ )); ?>
 
 
 
 
 
 
 
 
 
 
181
  <p class="description"><?php _e( 'After delete users, we can choose if we want to assign their posts to another user. Please do not delete them or posts will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
182
  </div>
183
  </td>
187
  <th scope="row"><label for="change_role_not_present_frontend"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
188
  <td>
189
  <div style="float:left; margin-top: 10px;">
190
+ <?php ACUIHTML()->checkbox( array( 'name' => 'change_role_not_present_frontend', 'compare_value' => $change_role_not_present_frontend ) ); ?>
191
  </div>
192
  <div style="margin-left:25px;">
193
+ <?php ACUIHTML()->select( array(
194
+ 'options' => ACUI_Helper::get_editable_roles(),
195
+ 'name' => 'change_role_not_present_role_frontend',
196
+ 'selected' => $change_role_not_present_role_frontend,
197
+ 'show_option_all' => false,
198
+ 'show_option_none' => false,
199
+ )); ?>
 
200
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
201
  </div>
202
  </td>
classes/helper.php CHANGED
@@ -51,6 +51,35 @@ class ACUI_Helper{
51
  return $list_editable_roles;
52
  }
53
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  static function get_errors_by_row( $errors, $row, $type = 'error' ){
55
  $errors_found = array();
56
 
51
  return $list_editable_roles;
52
  }
53
 
54
+ static function get_csv_delimiters_titles(){
55
+ return array(
56
+ 'COMMA' => __( 'Comma', 'import-users-from-csv-with-meta' ),
57
+ 'COLON' => __( 'Colon', 'import-users-from-csv-with-meta' ),
58
+ 'SEMICOLON' => __( 'Semicolon', 'import-users-from-csv-with-meta' ),
59
+ 'TAB' => __( 'Tab', 'import-users-from-csv-with-meta' ),
60
+ );
61
+ }
62
+
63
+ static function get_list_users_with_display_name(){
64
+ $blogusers = get_users( array( 'fields' => array( 'ID', 'display_name' ) ) );
65
+ $result = array();
66
+
67
+ foreach ( $blogusers as $bloguser )
68
+ $result[ $bloguser->ID ] = $bloguser->display_name;
69
+
70
+ return $result;
71
+ }
72
+
73
+ static function get_loaded_periods(){
74
+ $loaded_periods = wp_get_schedules();
75
+ $result = array();
76
+
77
+ foreach ( $loaded_periods as $key => $value )
78
+ $result[ $key ] = $value['display'];
79
+
80
+ return $result;
81
+ }
82
+
83
  static function get_errors_by_row( $errors, $row, $type = 'error' ){
84
  $errors_found = array();
85
 
classes/homepage.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit;
 
3
 
4
  class ACUI_Homepage{
5
  function __construct(){
@@ -38,7 +39,7 @@ class ACUI_Homepage{
38
  <div style="clear:both;"></div>
39
 
40
  <div id="acui_form_wrapper" class="main_bar">
41
- <form method="POST" enctype="multipart/form-data" action="" accept-charset="utf-8" onsubmit="return check();">
42
  <h2 id="acui_file_header"><?php _e( 'File', 'import-users-from-csv-with-meta'); ?></h2>
43
  <table id="acui_file_wrapper" class="form-table">
44
  <tbody>
@@ -66,14 +67,9 @@ class ACUI_Homepage{
66
  <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
67
  <td>
68
  <?php
69
- foreach ( ACUI_Helper::get_editable_roles() as $key => $value ){
70
- if( in_array( $key, $last_roles_used ) )
71
- echo "<label id='$key' style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
72
- else
73
- echo "<label id='$key' style='margin-right:5px;'><input name='role[]' type='checkbox' value='$key'/>$value</label>";
74
- }
75
- ?>
76
-
77
  <p class="description"><?php _e( 'You can also import roles from a CSV column. Please read documentation tab to see how it can be done. If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
78
  </td>
79
  </tr>
@@ -83,13 +79,15 @@ class ACUI_Homepage{
83
  <h2 id="acui_options_header"><?php _e( 'Options', 'import-users-from-csv-with-meta'); ?></h2>
84
  <table id="acui_options_wrapper" class="form-table">
85
  <tbody>
86
- <tr id="acui_empty_cell_wrapper" class="form-field form-required">
87
  <th scope="row"><label for="empty_cell_action"><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
88
  <td>
89
- <select name="empty_cell_action">
90
- <option value="leave"><?php _e( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ); ?></option>
91
- <option value="delete"><?php _e( 'Delete the metadata', 'import-users-from-csv-with-meta' ); ?></option>
92
- </select>
 
 
93
  </td>
94
  </tr>
95
 
@@ -97,12 +95,10 @@ class ACUI_Homepage{
97
  <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
98
  <td>
99
  <p id="sends_email_wrapper">
100
- <?php _e( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ); ?>
101
- <input type="checkbox" name="sends_email" value="yes" <?php if( get_option( 'acui_manually_send_mail' ) ): ?> checked="checked" <?php endif; ?>>
102
  </p>
103
  <p id="send_email_updated_wrapper">
104
- <?php _e( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ); ?>
105
- <input type="checkbox" name="send_email_updated" value="yes" <?php if( get_option( 'acui_manually_send_mail_updated' ) ): ?> checked="checked" <?php endif; ?>>
106
  </p>
107
  </td>
108
  </tr>
@@ -110,8 +106,7 @@ class ACUI_Homepage{
110
  <tr class="form-field form-required">
111
  <th scope="row"><label for=""><?php _e( 'Force users to reset their passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
112
  <td>
113
- <input type="checkbox" name="force_user_reset_password" value="yes" <?php checked( get_option( 'acui_manually_force_user_reset_password' ) ); ?>/>
114
- <p class="description"><?php _e( 'If a password is set to an user and you activate this option, the user will be forced to reset their password in their first login', 'import-users-from-csv-with-meta' ); ?></p>
115
  </td>
116
  </tr>
117
  </tbody>
@@ -124,21 +119,24 @@ class ACUI_Homepage{
124
  <tr id="acui_update_existing_users_wrapper" class="form-field form-required">
125
  <th scope="row"><label for="update_existing_users"><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
126
  <td>
127
- <select name="update_existing_users">
128
- <option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
129
- <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
130
- </select>
 
 
131
  </td>
132
  </tr>
133
 
134
  <tr id="acui_update_emails_existing_users_wrapper" class="form-field form-required">
135
  <th scope="row"><label for="update_emails_existing_users"><?php _e( 'Update emails?', 'import-users-from-csv-with-meta' ); ?></label></th>
136
  <td>
137
- <select name="update_emails_existing_users">
138
- <option value="yes"><?php _e( 'Yes', 'import-users-from-csv-with-meta' ); ?></option>
139
- <option value="create"><?php _e( 'No, but create a new user with a prefix in the username', 'import-users-from-csv-with-meta' ); ?></option>
140
- <option value="no"><?php _e( 'No, skip this user', 'import-users-from-csv-with-meta' ); ?></option>
141
- </select>
 
142
  <p class="description"><?php _e( 'What the plugin should do if the plugin find an user, identified by their username, with a different email', 'import-users-from-csv-with-meta' ); ?></p>
143
  </td>
144
  </tr>
@@ -146,21 +144,24 @@ class ACUI_Homepage{
146
  <tr id="acui_update_roles_existing_users_wrapper" class="form-field form-required">
147
  <th scope="row"><label for="update_roles_existing_users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
148
  <td>
149
- <select name="update_roles_existing_users">
150
- <option value="no"><?php _e( 'No', 'import-users-from-csv-with-meta' ); ?></option>
151
- <option value="yes"><?php _e( 'Yes, update and override existing roles', 'import-users-from-csv-with-meta' ); ?></option>
152
- <option value="yes_no_override"><?php _e( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ); ?></option>
153
- </select>
 
154
  </td>
155
  </tr>
156
 
157
  <tr id="acui_update_allow_update_passwords_wrapper" class="form-field form-required">
158
  <th scope="row"><label for="update_allow_update_passwords"><?php _e( 'Never update passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
159
  <td>
160
- <select name="update_allow_update_passwords">
161
- <option value="yes"><?php _e( 'Update passwords as it is described in documentation', 'import-users-from-csv-with-meta' ); ?></option>
162
- <option value="no"><?php _e( 'Never update passwords when updating a user', 'import-users-from-csv-with-meta' ); ?></option>
163
- </select>
 
 
164
  </td>
165
  </tr>
166
  </tbody>
@@ -175,12 +176,15 @@ class ACUI_Homepage{
175
  <th scope="row"><label for="delete_users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
176
  <td>
177
  <div style="float:left; margin-top: 10px;">
178
- <input type="checkbox" name="delete_users" id="delete_users" value="yes"/>
179
  </div>
180
  <div style="margin-left:25px;">
181
- <select id="delete_users_assign_posts" name="delete_users_assign_posts">
182
- <option value=""><?php _e( 'Delete posts of deleted users without assigning to any user or type to search a user', 'import-users-from-csv-with-meta' ) ?></option>
183
- </select>
 
 
 
184
  <p class="description"><?php _e( 'Administrators will not be deleted anyway. After delete users, we can choose if we want to assign their posts to another user. If you do not choose some user, content will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
185
  </div>
186
  </td>
@@ -190,14 +194,15 @@ class ACUI_Homepage{
190
  <th scope="row"><label for="change_role_not_present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
191
  <td>
192
  <div style="float:left; margin-top: 10px;">
193
- <input type="checkbox" name="change_role_not_present" id="change_role_not_present" value="yes"/>
194
  </div>
195
  <div style="margin-left:25px;">
196
- <select id="change_role_not_present_role" name="change_role_not_present_role">
197
- <?php foreach ( ACUI_Helper::get_editable_roles() as $key => $value ): ?>
198
- <option value='<?php echo $key; ?>'><?php echo $value; ?></option>
199
- <?php endforeach; ?>
200
- </select>
 
201
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
202
  </div>
203
  </td>
@@ -244,21 +249,21 @@ class ACUI_Homepage{
244
 
245
  </div>
246
  <script type="text/javascript">
247
- function check(){
248
- if(document.getElementById( 'uploadfile' ).value == "" && jQuery( '#upload_file' ).is( ':visible' ) ) {
249
- alert("<?php _e( 'Please choose a file', 'import-users-from-csv-with-meta' ); ?>");
250
- return false;
251
- }
252
-
253
- if( jQuery( '#path_to_file' ).val() == "" && jQuery( '#introduce_path' ).is( ':visible' ) ) {
254
- alert("<?php _e( 'Please enter a path to the file', 'import-users-from-csv-with-meta' ); ?>");
255
- return false;
256
- }
257
- }
258
-
259
  jQuery( document ).ready( function( $ ){
260
  check_delete_users_checked();
261
 
 
 
 
 
 
 
 
 
 
 
 
 
262
  $( '#delete_users' ).on( 'click', function() {
263
  check_delete_users_checked();
264
  });
1
  <?php
2
+ if ( ! defined( 'ABSPATH' ) )
3
+ exit;
4
 
5
  class ACUI_Homepage{
6
  function __construct(){
39
  <div style="clear:both;"></div>
40
 
41
  <div id="acui_form_wrapper" class="main_bar">
42
+ <form method="POST" id="acui_form" enctype="multipart/form-data" action="" accept-charset="utf-8">
43
  <h2 id="acui_file_header"><?php _e( 'File', 'import-users-from-csv-with-meta'); ?></h2>
44
  <table id="acui_file_wrapper" class="form-table">
45
  <tbody>
67
  <th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
68
  <td>
69
  <?php
70
+ foreach ( ACUI_Helper::get_editable_roles() as $key => $value )
71
+ ACUIHTML()->checkbox( array( 'label' => $value, 'name' => 'role[]', 'compare_value' => $last_roles_used, 'current' => $key, 'array' => true, 'class' => 'roles' ) );
72
+ ?>
 
 
 
 
 
73
  <p class="description"><?php _e( 'You can also import roles from a CSV column. Please read documentation tab to see how it can be done. If you choose more than one role, the roles would be assigned correctly but you should use some plugin like <a href="https://wordpress.org/plugins/user-role-editor/">User Role Editor</a> to manage them.', 'import-users-from-csv-with-meta' ); ?></p>
74
  </td>
75
  </tr>
79
  <h2 id="acui_options_header"><?php _e( 'Options', 'import-users-from-csv-with-meta'); ?></h2>
80
  <table id="acui_options_wrapper" class="form-table">
81
  <tbody>
82
+ <tr id="acui_empty_cell_wrapper" class="form-field form-required">
83
  <th scope="row"><label for="empty_cell_action"><?php _e( 'What should the plugin do with empty cells?', 'import-users-from-csv-with-meta' ); ?></label></th>
84
  <td>
85
+ <?php ACUIHTML()->select( array(
86
+ 'options' => array( 'leave' => __( 'Leave the old value for this metadata', 'import-users-from-csv-with-meta' ), 'delete' => __( 'Delete the metadata', 'import-users-from-csv-with-meta' ) ),
87
+ 'name' => 'empty_cell_action',
88
+ 'show_option_all' => false,
89
+ 'show_option_none' => false,
90
+ )); ?>
91
  </td>
92
  </tr>
93
 
95
  <th scope="row"><label for="user_login"><?php _e( 'Send mail', 'import-users-from-csv-with-meta' ); ?></label></th>
96
  <td>
97
  <p id="sends_email_wrapper">
98
+ <?php ACUIHTML()->checkbox( array( 'name' => 'sends_email', 'label' => __( 'Do you wish to send a mail with credentials and other data?', 'import-users-from-csv-with-meta' ), 'current' => 'yes', 'compare_value' => get_option( 'acui_manually_send_mail' ) ) ); ?>
 
99
  </p>
100
  <p id="send_email_updated_wrapper">
101
+ <?php ACUIHTML()->checkbox( array( 'name' => 'send_email_updated', 'label' => __( 'Do you wish to send this mail also to users that are being updated? (not only to the one which are being created)', 'import-users-from-csv-with-meta' ), 'current' => 'yes', 'compare_value' => get_option( 'acui_manually_send_mail_updated' ) ) ); ?>
 
102
  </p>
103
  </td>
104
  </tr>
106
  <tr class="form-field form-required">
107
  <th scope="row"><label for=""><?php _e( 'Force users to reset their passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
108
  <td>
109
+ <?php ACUIHTML()->checkbox( array( 'name' => 'force_user_reset_password', 'label' => __( 'If a password is set to an user and you activate this option, the user will be forced to reset their password in their first login', 'import-users-from-csv-with-meta' ), 'current' => 'yes', 'compare_value' => get_option( 'acui_manually_force_user_reset_password' ) ) ); ?>
 
110
  </td>
111
  </tr>
112
  </tbody>
119
  <tr id="acui_update_existing_users_wrapper" class="form-field form-required">
120
  <th scope="row"><label for="update_existing_users"><?php _e( 'Update existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
121
  <td>
122
+ <?php ACUIHTML()->select( array(
123
+ 'options' => array( 'yes' => __( 'Yes', 'import-users-from-csv-with-meta' ), 'no' => __( 'No', 'import-users-from-csv-with-meta' ) ),
124
+ 'name' => 'update_existing_users',
125
+ 'show_option_all' => false,
126
+ 'show_option_none' => false,
127
+ )); ?>
128
  </td>
129
  </tr>
130
 
131
  <tr id="acui_update_emails_existing_users_wrapper" class="form-field form-required">
132
  <th scope="row"><label for="update_emails_existing_users"><?php _e( 'Update emails?', 'import-users-from-csv-with-meta' ); ?></label></th>
133
  <td>
134
+ <?php ACUIHTML()->select( array(
135
+ 'options' => array( 'yes' => __( 'Yes', 'import-users-from-csv-with-meta' ), 'create' => __( 'No, but create a new user with a prefix in the username', 'import-users-from-csv-with-meta' ), 'no' => __( 'No', 'import-users-from-csv-with-meta' ) ),
136
+ 'name' => 'update_emails_existing_users',
137
+ 'show_option_all' => false,
138
+ 'show_option_none' => false,
139
+ )); ?>
140
  <p class="description"><?php _e( 'What the plugin should do if the plugin find an user, identified by their username, with a different email', 'import-users-from-csv-with-meta' ); ?></p>
141
  </td>
142
  </tr>
144
  <tr id="acui_update_roles_existing_users_wrapper" class="form-field form-required">
145
  <th scope="row"><label for="update_roles_existing_users"><?php _e( 'Update roles for existing users?', 'import-users-from-csv-with-meta' ); ?></label></th>
146
  <td>
147
+ <?php ACUIHTML()->select( array(
148
+ 'options' => array( 'no' => __( 'No', 'import-users-from-csv-with-meta' ), 'yes' => __( 'Yes, update and override existing roles', 'import-users-from-csv-with-meta' ), 'yes_no_override' => __( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ) ),
149
+ 'name' => 'update_roles_existing_users',
150
+ 'show_option_all' => false,
151
+ 'show_option_none' => false,
152
+ )); ?>
153
  </td>
154
  </tr>
155
 
156
  <tr id="acui_update_allow_update_passwords_wrapper" class="form-field form-required">
157
  <th scope="row"><label for="update_allow_update_passwords"><?php _e( 'Never update passwords?', 'import-users-from-csv-with-meta' ); ?></label></th>
158
  <td>
159
+ <?php ACUIHTML()->select( array(
160
+ 'options' => array( 'yes' => __( 'Update passwords as it is described in documentation', 'import-users-from-csv-with-meta' ), 'no' => __( 'Never update passwords when updating a user', 'import-users-from-csv-with-meta' ), 'yes_no_override' => __( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ) ),
161
+ 'name' => 'update_allow_update_passwords',
162
+ 'show_option_all' => false,
163
+ 'show_option_none' => false,
164
+ )); ?>
165
  </td>
166
  </tr>
167
  </tbody>
176
  <th scope="row"><label for="delete_users"><?php _e( 'Delete users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
177
  <td>
178
  <div style="float:left; margin-top: 10px;">
179
+ <?php ACUIHTML()->checkbox( array( 'name' => 'delete_users', 'current' => 'yes' ) ); ?>
180
  </div>
181
  <div style="margin-left:25px;">
182
+ <?php ACUIHTML()->select( array(
183
+ 'options' => array( 'no' => __( 'Never update passwords when updating a user', 'import-users-from-csv-with-meta' ), 'yes_no_override' => __( 'Yes, add new roles and not override existing ones', 'import-users-from-csv-with-meta' ) ),
184
+ 'name' => 'delete_users_assign_posts',
185
+ 'show_option_all' => false,
186
+ 'show_option_none' => __( 'Delete posts of deleted users without assigning to any user or type to search a user', 'import-users-from-csv-with-meta' ),
187
+ )); ?>
188
  <p class="description"><?php _e( 'Administrators will not be deleted anyway. After delete users, we can choose if we want to assign their posts to another user. If you do not choose some user, content will be deleted.', 'import-users-from-csv-with-meta' ); ?></p>
189
  </div>
190
  </td>
194
  <th scope="row"><label for="change_role_not_present"><?php _e( 'Change role of users that are not present in the CSV?', 'import-users-from-csv-with-meta' ); ?></label></th>
195
  <td>
196
  <div style="float:left; margin-top: 10px;">
197
+ <?php ACUIHTML()->checkbox( array( 'name' => 'change_role_not_present', 'current' => 'yes' ) ); ?>
198
  </div>
199
  <div style="margin-left:25px;">
200
+ <?php ACUIHTML()->select( array(
201
+ 'options' => ACUI_Helper::get_editable_roles(),
202
+ 'name' => 'change_role_not_present_role',
203
+ 'show_option_all' => false,
204
+ 'show_option_none' => false,
205
+ )); ?>
206
  <p class="description"><?php _e( 'After import users which is not present in the CSV and can be changed to a different role.', 'import-users-from-csv-with-meta' ); ?></p>
207
  </div>
208
  </td>
249
 
250
  </div>
251
  <script type="text/javascript">
 
 
 
 
 
 
 
 
 
 
 
 
252
  jQuery( document ).ready( function( $ ){
253
  check_delete_users_checked();
254
 
255
+ $( '#acui_form' ).submit( function(){
256
+ if( $( '#uploadfile' ).val() == "" && $( '#upload_file' ).is( ':visible' ) ) {
257
+ alert("<?php _e( 'Please choose a file', 'import-users-from-csv-with-meta' ); ?>");
258
+ return false;
259
+ }
260
+
261
+ if( $( '#path_to_file' ).val() == "" && $( '#introduce_path' ).is( ':visible' ) ) {
262
+ alert("<?php _e( 'Please enter a path to the file', 'import-users-from-csv-with-meta' ); ?>");
263
+ return false;
264
+ }
265
+ } );
266
+
267
  $( '#delete_users' ).on( 'click', function() {
268
  check_delete_users_checked();
269
  });
classes/html.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) exit;
3
+
4
+ class ACUI_HTML{
5
+ private static $instance;
6
+ var $settings;
7
+
8
+ function __construct(){
9
+ $settings = array(
10
+ 'common' => array(
11
+ 'default_role',
12
+
13
+ )
14
+ );
15
+ }
16
+
17
+ private static function is_instantiated() {
18
+ if ( ! empty( self::$instance ) && ( self::$instance instanceof ACUI_HTML ) ) {
19
+ return true;
20
+ }
21
+
22
+ return false;
23
+ }
24
+
25
+ private static function setup_instance() {
26
+ self::$instance = new ACUI_HTML;
27
+ }
28
+
29
+ static function instance() {
30
+ if ( self::is_instantiated() ) {
31
+ return self::$instance;
32
+ }
33
+
34
+ self::setup_instance();
35
+
36
+ return self::$instance;
37
+ }
38
+
39
+
40
+ function sanitize_key( $key ) {
41
+ $raw_key = $key;
42
+ return preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
43
+ }
44
+
45
+ function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
46
+ $current = date( 'Y' );
47
+ $start_year = $current - absint( $years_before );
48
+ $end_year = $current + absint( $years_after );
49
+ $selected = empty( $selected ) ? date( 'Y' ) : $selected;
50
+ $options = array();
51
+
52
+ while ( $start_year <= $end_year ) {
53
+ $options[ absint( $start_year ) ] = $start_year;
54
+ $start_year++;
55
+ }
56
+
57
+ $output = $this->select( array(
58
+ 'name' => $name,
59
+ 'selected' => $selected,
60
+ 'options' => $options,
61
+ 'show_option_all' => false,
62
+ 'show_option_none' => false
63
+ ) );
64
+
65
+ return $output;
66
+ }
67
+
68
+ function month_dropdown( $name = 'month', $selected = 0 ) {
69
+ $month = 1;
70
+ $options = array();
71
+ $selected = empty( $selected ) ? date( 'n' ) : $selected;
72
+
73
+ while ( $month <= 12 ) {
74
+ $options[ absint( $month ) ] = edd_month_num_to_name( $month );
75
+ $month++;
76
+ }
77
+
78
+ $output = $this->select( array(
79
+ 'name' => $name,
80
+ 'selected' => $selected,
81
+ 'options' => $options,
82
+ 'show_option_all' => false,
83
+ 'show_option_none' => false
84
+ ) );
85
+
86
+ return $output;
87
+ }
88
+
89
+ function select( $args = array() ) {
90
+ $defaults = array(
91
+ 'echo' => true,
92
+ 'options' => array(),
93
+ 'name' => null,
94
+ 'class' => '',
95
+ 'id' => '',
96
+ 'selected' => array(),
97
+ 'chosen' => false,
98
+ 'placeholder' => null,
99
+ 'multiple' => false,
100
+ 'show_option_all' => _x( 'All', 'all dropdown items', 'import-users-from-csv-with-meta' ),
101
+ 'show_option_none' => _x( 'None', 'no dropdown items', 'import-users-from-csv-with-meta' ),
102
+ 'data' => array(),
103
+ 'readonly' => false,
104
+ 'disabled' => false,
105
+ );
106
+
107
+ $args = wp_parse_args( $args, $defaults );
108
+
109
+ if( empty( $args['id'] ) )
110
+ $args['id'] = $args['name'];
111
+
112
+ $data_elements = '';
113
+ foreach ( $args['data'] as $key => $value ) {
114
+ $data_elements .= ' data-' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
115
+ }
116
+
117
+ if( $args['multiple'] ) {
118
+ $multiple = ' MULTIPLE';
119
+ } else {
120
+ $multiple = '';
121
+ }
122
+
123
+ if( $args['placeholder'] ) {
124
+ $placeholder = $args['placeholder'];
125
+ } else {
126
+ $placeholder = '';
127
+ }
128
+
129
+ if ( isset( $args['readonly'] ) && $args['readonly'] ) {
130
+ $readonly = ' readonly="readonly"';
131
+ } else {
132
+ $readonly = '';
133
+ }
134
+
135
+ if ( isset( $args['disabled'] ) && $args['disabled'] ) {
136
+ $disabled = ' disabled="disabled"';
137
+ } else {
138
+ $disabled = '';
139
+ }
140
+
141
+ $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
142
+ $output = '<select' . $disabled . $readonly . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $this->sanitize_key( $args['id'] ) ) . '" class="acui-select ' . $class . '"' . $multiple . ' data-placeholder="' . $placeholder . '"'. $data_elements . '>';
143
+
144
+ if ( ! isset( $args['selected'] ) || ( is_array( $args['selected'] ) && empty( $args['selected'] ) ) || ! $args['selected'] ) {
145
+ $selected = "";
146
+ }
147
+
148
+ if ( $args['show_option_all'] ) {
149
+ if ( $args['multiple'] && ! empty( $args['selected'] ) ) {
150
+ $selected = selected( true, in_array( 0, (array) $args['selected'] ), false );
151
+ } else {
152
+ $selected = selected( $args['selected'], 0, false );
153
+ }
154
+ $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
155
+ }
156
+
157
+ if ( ! empty( $args['options'] ) ) {
158
+ if ( $args['show_option_none'] ) {
159
+ if ( $args['multiple'] ) {
160
+ $selected = selected( true, in_array( "", $args['selected'] ), false );
161
+ } elseif ( isset( $args['selected'] ) && ! is_array( $args['selected'] ) && ! empty( $args['selected'] ) ) {
162
+ $selected = selected( $args['selected'], "", false );
163
+ }
164
+ $output .= '<option value=""' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
165
+ }
166
+
167
+ foreach ( $args['options'] as $key => $option ) {
168
+ if ( $args['multiple'] && is_array( $args['selected'] ) ) {
169
+ $selected = selected( true, in_array( (string) $key, $args['selected'] ), false );
170
+ } elseif ( isset( $args['selected'] ) && ! is_array( $args['selected'] ) ) {
171
+ $selected = selected( $args['selected'], $key, false );
172
+ }
173
+
174
+ $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
175
+ }
176
+ }
177
+
178
+ $output .= '</select>';
179
+
180
+ if( $args['echo'] )
181
+ echo $output;
182
+
183
+ return $output;
184
+ }
185
+
186
+ function checkbox( $args = array() ) {
187
+ $defaults = array(
188
+ 'label' => '',
189
+ 'echo' => true,
190
+ 'array' => false,
191
+ 'compare_value' => 1,
192
+ 'name' => null,
193
+ 'current' => 1,
194
+ 'class' => '',
195
+ 'options' => array(
196
+ 'disabled' => false,
197
+ 'readonly' => false
198
+ )
199
+ );
200
+
201
+ $args = wp_parse_args( $args, $defaults );
202
+ $output = '';
203
+
204
+ $class = 'acui-checkbox ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
205
+ $options = '';
206
+ if ( ! empty( $args['options']['disabled'] ) ) {
207
+ $options .= ' disabled="disabled"';
208
+ } elseif ( ! empty( $args['options']['readonly'] ) ) {
209
+ $options .= ' readonly';
210
+ }
211
+
212
+ if( !empty( $args['label'] ) ){
213
+ $output .= '<label class="' . $class . '"';
214
+
215
+ if( !$args['array'] )
216
+ $output .= ' for="' . esc_attr( $args['name'] ) . '"';
217
+
218
+ $output .= '>' . esc_attr( $args['label'] );
219
+ }
220
+
221
+ if( $args['array'] )
222
+ $output .= '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" class="' . $class . '" value="' . $args['current'] .'" ' . checked( in_array( $args['current'], $args['compare_value'] ), 1, false ) . ' />';
223
+ else
224
+ $output .= '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $class . '" value="' . $args['current'] . '" ' . checked( $args['compare_value'], $args['current'], false ) . ' />';
225
+
226
+ if( !empty( $args['label'] ) )
227
+ $output .= '</label>';
228
+
229
+ if( $args['echo'] )
230
+ echo $output;
231
+
232
+ return $output;
233
+ }
234
+
235
+ function text( $args = array() ) {
236
+ $defaults = array(
237
+ 'echo' => true,
238
+ 'id' => '',
239
+ 'name' => isset( $name ) ? $name : 'text',
240
+ 'value' => isset( $value ) ? $value : null,
241
+ 'label' => isset( $label ) ? $label : null,
242
+ 'desc' => isset( $desc ) ? $desc : null,
243
+ 'placeholder' => '',
244
+ 'class' => 'regular-text',
245
+ 'disabled' => false,
246
+ 'autocomplete' => '',
247
+ 'data' => false,
248
+ 'type' => 'text',
249
+ 'readonly' => false,
250
+ );
251
+
252
+ $args = wp_parse_args( $args, $defaults );
253
+
254
+ if( empty( $args['id'] ) )
255
+ $args['id'] = $args['name'];
256
+
257
+ if ( isset( $args['readonly'] ) && $args['readonly'] ) {
258
+ $readonly = ' readonly="readonly"';
259
+ } else {
260
+ $readonly = '';
261
+ }
262
+
263
+ $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
264
+ $disabled = '';
265
+ if( $args['disabled'] ) {
266
+ $disabled = ' disabled="disabled"';
267
+ }
268
+
269
+ $data = '';
270
+ if ( ! empty( $args['data'] ) ) {
271
+ foreach ( $args['data'] as $key => $value ) {
272
+ $data .= 'data-' . $this->sanitize_key( $key ) . '="' . esc_attr( $value ) . '" ';
273
+ }
274
+ }
275
+
276
+ $output = '<span id="acui-' . $this->sanitize_key( $args['name'] ) . '-wrap">';
277
+ if ( ! empty( $args['label'] ) ) {
278
+ $output .= '<label class="acui-label" for="' . $this->sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
279
+ }
280
+
281
+ if ( ! empty( $args['desc'] ) ) {
282
+ $output .= '<span class="acui-description">' . esc_html( $args['desc'] ) . '</span>';
283
+ }
284
+
285
+ $output .= '<input type="' . esc_attr( $args['type'] ) . '" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . '' . $disabled . '' . $readonly . '/>';
286
+
287
+ $output .= '</span>';
288
+
289
+ if( $args['echo'] )
290
+ echo $output;
291
+
292
+ return $output;
293
+ }
294
+
295
+ function textarea( $args = array() ) {
296
+ $defaults = array(
297
+ 'name' => 'textarea',
298
+ 'value' => null,
299
+ 'label' => null,
300
+ 'desc' => null,
301
+ 'class' => 'large-text',
302
+ 'disabled' => false
303
+ );
304
+
305
+ $args = wp_parse_args( $args, $defaults );
306
+
307
+ $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) );
308
+ $disabled = '';
309
+ if( $args['disabled'] ) {
310
+ $disabled = ' disabled="disabled"';
311
+ }
312
+
313
+ $output = '<span id="acui-' . $this->sanitize_key( $args['name'] ) . '-wrap">';
314
+
315
+ if ( ! empty( $args['label'] ) ) {
316
+ $output .= '<label class="acui-label" for="' . $this->sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
317
+ }
318
+
319
+ $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . $this->sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
320
+
321
+ if ( ! empty( $args['desc'] ) ) {
322
+ $output .= '<span class="acui-description">' . esc_html( $args['desc'] ) . '</span>';
323
+ }
324
+
325
+ $output .= '</span>';
326
+
327
+ return $output;
328
+ }
329
+ }
330
+
331
+ function ACUIHTML(){
332
+ return ACUI_HTML::instance();
333
+ }
classes/import.php CHANGED
@@ -1,12 +1,17 @@
1
  <?php
2
 
3
  class ACUI_Import{
4
- public function show(){
 
 
 
5
  if ( !current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) ) {
6
  wp_die( __( 'You are not allowed to see this content.', 'import-users-from-csv-with-meta' ));
7
  }
8
 
9
  $tab = ( isset ( $_GET['tab'] ) ) ? $_GET['tab'] : 'homepage';
 
 
10
 
11
  if( isset( $_POST ) && !empty( $_POST ) ):
12
  if ( !wp_verify_nonce( $_POST['security'], 'codection-security' ) ) {
@@ -40,7 +45,8 @@ class ACUI_Import{
40
  }
41
  endif;
42
 
43
- ACUI_Import::admin_tabs( $tab );
 
44
 
45
  switch ( $tab ){
46
  case 'homepage' :
@@ -88,12 +94,12 @@ class ACUI_Import{
88
  break;
89
 
90
  default:
91
- do_action( 'acui_tab_action_' . $tab );
92
  break;
93
  }
94
  }
95
 
96
- static function admin_tabs( $current = 'homepage' ) {
97
  $tabs = array(
98
  'homepage' => __( 'Import', 'import-users-from-csv-with-meta' ),
99
  'export' => __( 'Export', 'import-users-from-csv-with-meta' ),
@@ -131,6 +137,57 @@ class ACUI_Import{
131
  echo '</h2>';
132
  }
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  function fileupload_process( $form_data, $is_cron = false, $is_frontend = false ) {
135
  if ( !defined( 'DOING_CRON' ) && ( !isset( $form_data['security'] ) || !wp_verify_nonce( $form_data['security'], 'codection-security' ) ) ){
136
  wp_die( __( 'Nonce check failed', 'import-users-from-csv-with-meta' ) );
1
  <?php
2
 
3
  class ACUI_Import{
4
+ function __construct(){
5
+ }
6
+
7
+ function show(){
8
  if ( !current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) ) {
9
  wp_die( __( 'You are not allowed to see this content.', 'import-users-from-csv-with-meta' ));
10
  }
11
 
12
  $tab = ( isset ( $_GET['tab'] ) ) ? $_GET['tab'] : 'homepage';
13
+ $sections = $this->get_sections_from_tab( $tab );
14
+ $section = isset( $_GET['section'] ) ? sanitize_text_field( $_GET['section'] ) : 'main';
15
 
16
  if( isset( $_POST ) && !empty( $_POST ) ):
17
  if ( !wp_verify_nonce( $_POST['security'], 'codection-security' ) ) {
45
  }
46
  endif;
47
 
48
+ $this->admin_tabs( $tab );
49
+ $this->secondary_admin_tabs( $tab, $section, $sections );
50
 
51
  switch ( $tab ){
52
  case 'homepage' :
94
  break;
95
 
96
  default:
97
+ do_action( 'acui_tab_action_' . $tab, $section );
98
  break;
99
  }
100
  }
101
 
102
+ function admin_tabs( $current = 'homepage' ) {
103
  $tabs = array(
104
  'homepage' => __( 'Import', 'import-users-from-csv-with-meta' ),
105
  'export' => __( 'Export', 'import-users-from-csv-with-meta' ),
137
  echo '</h2>';
138
  }
139
 
140
+ static function secondary_admin_tabs( $active_tab = '', $section = '', $sections = array() ){
141
+ if( empty( $sections ) )
142
+ return;
143
+
144
+ $links = array();
145
+
146
+ foreach ( $sections as $section_id => $section_name ) {
147
+ $tab_url = add_query_arg(
148
+ array(
149
+ 'page' => 'acui',
150
+ 'tab' => $active_tab,
151
+ 'section' => $section_id,
152
+ ),
153
+ admin_url( 'tools.php' )
154
+ );
155
+
156
+ $class = ( $section === $section_id ) ? 'current' : '';
157
+ $links[ $section_id ] = '<li class="' . esc_attr( $class ) . '"><a class="' . esc_attr( $class ) . '" href="' . esc_url( $tab_url ) . '">' . esc_html( $section_name ) . '</a><li>';
158
+ } ?>
159
+
160
+ <div class="wp-clearfix">
161
+ <ul class="acui-subsubsub">
162
+ <?php echo implode( '', $links ); ?>
163
+ </ul>
164
+ </div>
165
+
166
+ <?php
167
+ }
168
+
169
+ function get_sections_from_tab( $tab ){
170
+ switch ( $tab ){
171
+ case 'homepage':
172
+ case 'export':
173
+ case 'frontend':
174
+ case 'columns':
175
+ case 'meta-keys':
176
+ case 'doc':
177
+ case 'mail-options':
178
+ case 'cron':
179
+ case 'donate':
180
+ case 'help':
181
+ case 'new_features':
182
+ return array();
183
+ break;
184
+
185
+ default:
186
+ return apply_filters( 'acui_tab_section_' . $tab, array() );
187
+ break;
188
+ }
189
+ }
190
+
191
  function fileupload_process( $form_data, $is_cron = false, $is_frontend = false ) {
192
  if ( !defined( 'DOING_CRON' ) && ( !isset( $form_data['security'] ) || !wp_verify_nonce( $form_data['security'], 'codection-security' ) ) ){
193
  wp_die( __( 'Nonce check failed', 'import-users-from-csv-with-meta' ) );
classes/options.php CHANGED
@@ -88,14 +88,14 @@ class ACUI_Options{
88
  elseif( $is_frontend ){
89
  $form_data["send_mail_admin_frontend_address_list"] = isset( $form_data["send_mail_admin_frontend_address_list"] ) ? $form_data["send_mail_admin_frontend_address_list"] : '';
90
 
91
- update_option( "acui_frontend_send_mail", isset( $form_data["send-mail-frontend"] ) && $form_data["send-mail-frontend"] == "yes" );
92
- update_option( "acui_frontend_send_mail_updated", isset( $form_data["send-mail-updated-frontend"] ) && $form_data["send-mail-updated-frontend"] == "yes" );
93
- update_option( "acui_frontend_mail_admin", isset( $form_data["send_mail_admin_frontend"] ) && $form_data["send_mail_admin_frontend"] == "yes" );
94
- update_option( "acui_frontend_force_user_reset_password", isset( $form_data["force_user_reset_password"] ) && $form_data["force_user_reset_password"] == "yes" );
95
  update_option( "acui_frontend_send_mail_admin_address_list", sanitize_text_field( $form_data["send_mail_admin_frontend_address_list"] ) );
96
- update_option( "acui_frontend_delete_users", isset( $form_data["delete_users_frontend"] ) && $form_data["delete_users_frontend"] == "yes" );
97
  update_option( "acui_frontend_delete_users_assign_posts", sanitize_text_field( $form_data["delete-users-assign-posts-frontend"] ) );
98
- update_option( "acui_frontend_change_role_not_present", isset( $form_data["change_role_not_present_frontend"] ) && $form_data["change_role_not_present_frontend"] == "yes" );
99
  update_option( "acui_frontend_change_role_not_present_role", sanitize_text_field( $form_data["change_role_not_present_role_frontend"] ) );
100
  update_option( "acui_frontend_activate_users_wp_members", isset( $form_data["activate-users-wp-members-frontend"] ) ? sanitize_text_field( $form_data["activate-users-wp-members-frontend"] ) : 'no_activate' );
101
 
88
  elseif( $is_frontend ){
89
  $form_data["send_mail_admin_frontend_address_list"] = isset( $form_data["send_mail_admin_frontend_address_list"] ) ? $form_data["send_mail_admin_frontend_address_list"] : '';
90
 
91
+ update_option( "acui_frontend_send_mail", isset( $form_data["send-mail-frontend"] ) && $form_data["send-mail-frontend"] == "1" );
92
+ update_option( "acui_frontend_send_mail_updated", isset( $form_data["send-mail-updated-frontend"] ) && $form_data["send-mail-updated-frontend"] == "1" );
93
+ update_option( "acui_frontend_mail_admin", isset( $form_data["send_mail_admin_frontend"] ) && $form_data["send_mail_admin_frontend"] == "1" );
94
+ update_option( "acui_frontend_force_user_reset_password", isset( $form_data["force_user_reset_password"] ) && $form_data["force_user_reset_password"] == "1" );
95
  update_option( "acui_frontend_send_mail_admin_address_list", sanitize_text_field( $form_data["send_mail_admin_frontend_address_list"] ) );
96
+ update_option( "acui_frontend_delete_users", isset( $form_data["delete_users_frontend"] ) && $form_data["delete_users_frontend"] == "1" );
97
  update_option( "acui_frontend_delete_users_assign_posts", sanitize_text_field( $form_data["delete-users-assign-posts-frontend"] ) );
98
+ update_option( "acui_frontend_change_role_not_present", isset( $form_data["change_role_not_present_frontend"] ) && $form_data["change_role_not_present_frontend"] == "1" );
99
  update_option( "acui_frontend_change_role_not_present_role", sanitize_text_field( $form_data["change_role_not_present_role_frontend"] ) );
100
  update_option( "acui_frontend_activate_users_wp_members", isset( $form_data["activate-users-wp-members-frontend"] ) ? sanitize_text_field( $form_data["activate-users-wp-members-frontend"] ) : 'no_activate' );
101
 
import-users-from-csv-with-meta.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
- Version: 1.18.4.4
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
@@ -11,10 +11,11 @@ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
 
14
  if ( ! defined( 'ABSPATH' ) )
15
  exit;
16
 
17
- define( 'ACUI_VERSION', '1.18.4.4' );
18
 
19
  class ImportExportUsersCustomers{
20
  var $file;
3
  Plugin Name: Import and export users and customers
4
  Plugin URI: https://www.codection.com
5
  Description: Using this plugin you will be able to import and export users or customers choosing many options and interacting with lots of other plugins
6
+ Version: 1.19
7
  Author: codection
8
  Author URI: https://codection.com
9
  License: GPL2
11
  Text Domain: import-users-from-csv-with-meta
12
  Domain Path: /languages
13
  */
14
+
15
  if ( ! defined( 'ABSPATH' ) )
16
  exit;
17
 
18
+ define( 'ACUI_VERSION', '1.19' );
19
 
20
  class ImportExportUsersCustomers{
21
  var $file;
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: carazo, hornero
3
  Donate link: https://codection.com/go/donate-import-users-from-csv-with-meta/
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
- Tested up to: 5.8.1
7
- Stable tag: 1.18.4.4
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -103,6 +103,11 @@ Plugin will automatically detect:
103
 
104
  == Changelog ==
105
 
 
 
 
 
 
106
  = 1.18.4.4 =
107
  * Force version update
108
 
3
  Donate link: https://codection.com/go/donate-import-users-from-csv-with-meta/
4
  Tags: csv, import, importer, meta data, meta, user, users, user meta, editor, profile, custom, fields, delimiter, update, insert
5
  Requires at least: 3.4
6
+ Tested up to: 5.8.2
7
+ Stable tag: 1.19
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
103
 
104
  == Changelog ==
105
 
106
+ = 1.19 =
107
+ * New class to create diffent HTML elements to standarize plugin code
108
+ * Different fixes in export function to avoid errors
109
+ * New secondary tab section prepared
110
+
111
  = 1.18.4.4 =
112
  * Force version update
113