Version Description
- Problem solved converting data that has a format date but that is not wanted to be converted, to timestamps when exporting
- Fixed problems in standard import, in very big databases, there was a problem creating the list of users to assign deleted posts, now this list is created and managed using select2 and AJAX to improve performance and usability
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.18.3 |
Comparing to | |
See all releases |
Code changes from version 1.18.2.3 to 1.18.3
- classes/batch_exporter.php +14 -12
- classes/export.php +1 -10
- classes/helper.php +1 -4
- classes/homepage.php +134 -31
- classes/import.php +1 -1
- import-users-from-csv-with-meta.php +2 -54
- readme.txt +5 -1
classes/batch_exporter.php
CHANGED
@@ -31,7 +31,6 @@ class ACUI_Batch_Exporter{
|
|
31 |
protected $other_non_date_keys;
|
32 |
|
33 |
function __construct() {
|
34 |
-
add_filter( 'acui_export_non_date_keys', array( $this, 'get_non_date_keys' ), 1, 1 );
|
35 |
add_filter( 'acui_export_columns', array( $this, 'maybe_order_columns_alphabetacally' ), 10, 2 );
|
36 |
add_filter( 'acui_export_get_key_user_data', array( $this, 'filter_key_user_id' ) );
|
37 |
add_filter( 'acui_export_columns', array( $this, 'maybe_order_columns_filtered_columns_parameter' ), 11, 2 );
|
@@ -46,8 +45,8 @@ class ACUI_Batch_Exporter{
|
|
46 |
$this->total_rows = $this->get_total_rows();
|
47 |
}
|
48 |
|
49 |
-
function get_non_date_keys(
|
50 |
-
return array_merge( $non_date_keys, $this->user_data, $this->woocommerce_default_user_meta_keys, $this->other_non_date_keys );
|
51 |
}
|
52 |
|
53 |
function maybe_order_columns_alphabetacally( $row, $args ){
|
@@ -591,27 +590,30 @@ class ACUI_Batch_Exporter{
|
|
591 |
|
592 |
function prepare( $key, $value, $datetime_format, $user = 0 ){
|
593 |
$timestamp_keys = apply_filters( 'acui_export_timestamp_keys', array( 'wc_last_active' ) );
|
594 |
-
$non_date_keys = apply_filters( 'acui_export_non_date_keys', array() );
|
595 |
$original_value = $value;
|
|
|
|
|
|
|
|
|
|
|
596 |
|
597 |
if( $key == 'role' ){
|
598 |
return implode( ',', ACUI_Helper::get_roles_by_user_id( $user ) );
|
599 |
}
|
|
|
600 |
if( is_array( $value ) || is_object( $value ) ){
|
601 |
return serialize( $value );
|
602 |
}
|
603 |
-
|
|
|
604 |
return $this->clean_bad_characters_formulas( $value );
|
605 |
}
|
606 |
-
|
607 |
-
|
608 |
-
}
|
609 |
-
elseif( $this->get_convert_timestamp() && is_int( $value ) && ( ( $this->is_valid_timestamp( $value ) && strlen( $value ) > 4 ) || in_array( $key, $timestamp_keys) ) ){ // dates in timestamp format
|
610 |
return date( $datetime_format, $value );
|
611 |
}
|
612 |
-
|
613 |
-
|
614 |
-
}
|
615 |
}
|
616 |
|
617 |
function clean_bad_characters_formulas( $value ){
|
31 |
protected $other_non_date_keys;
|
32 |
|
33 |
function __construct() {
|
|
|
34 |
add_filter( 'acui_export_columns', array( $this, 'maybe_order_columns_alphabetacally' ), 10, 2 );
|
35 |
add_filter( 'acui_export_get_key_user_data', array( $this, 'filter_key_user_id' ) );
|
36 |
add_filter( 'acui_export_columns', array( $this, 'maybe_order_columns_filtered_columns_parameter' ), 11, 2 );
|
45 |
$this->total_rows = $this->get_total_rows();
|
46 |
}
|
47 |
|
48 |
+
function get_non_date_keys(){
|
49 |
+
return apply_filters( 'acui_export_non_date_keys', array_merge( $this->non_date_keys, $this->user_data, $this->woocommerce_default_user_meta_keys, $this->other_non_date_keys ) );
|
50 |
}
|
51 |
|
52 |
function maybe_order_columns_alphabetacally( $row, $args ){
|
590 |
|
591 |
function prepare( $key, $value, $datetime_format, $user = 0 ){
|
592 |
$timestamp_keys = apply_filters( 'acui_export_timestamp_keys', array( 'wc_last_active' ) );
|
|
|
593 |
$original_value = $value;
|
594 |
+
$value = $this->clean_bad_characters_formulas( $value );
|
595 |
+
|
596 |
+
if( has_filter( 'acui_export_prepare' ) ){
|
597 |
+
return apply_filters( 'acui_export_prepare', $value, $original_value );
|
598 |
+
}
|
599 |
|
600 |
if( $key == 'role' ){
|
601 |
return implode( ',', ACUI_Helper::get_roles_by_user_id( $user ) );
|
602 |
}
|
603 |
+
|
604 |
if( is_array( $value ) || is_object( $value ) ){
|
605 |
return serialize( $value );
|
606 |
}
|
607 |
+
|
608 |
+
if( in_array( $key, $this->get_non_date_keys() ) || empty( $datetime_format ) ){
|
609 |
return $this->clean_bad_characters_formulas( $value );
|
610 |
}
|
611 |
+
|
612 |
+
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
|
|
|
|
|
613 |
return date( $datetime_format, $value );
|
614 |
}
|
615 |
+
|
616 |
+
return $value;
|
|
|
617 |
}
|
618 |
|
619 |
function clean_bad_characters_formulas( $value ){
|
classes/export.php
CHANGED
@@ -3,19 +3,10 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
3 |
|
4 |
class ACUI_Exporter{
|
5 |
private $path_csv;
|
6 |
-
private $user_data;
|
7 |
-
private $accepted_order_by;
|
8 |
-
private $woocommerce_default_user_meta_keys;
|
9 |
-
private $other_non_date_keys;
|
10 |
|
11 |
function __construct(){
|
12 |
$upload_dir = wp_upload_dir();
|
13 |
-
|
14 |
$this->path_csv = $upload_dir['basedir'] . "/export-users.csv";
|
15 |
-
$this->user_data = array( "user_login", "user_email", "source_user_id", "user_pass", "user_nicename", "user_url", "user_registered", "display_name" );
|
16 |
-
$this->accepted_order_by = array( 'ID', 'display_name', 'name', 'user_name', 'login', 'user_login', 'nicename', 'user_nicename', 'email', 'user_email', 'url', 'user_url', 'registered', 'user_registered', 'post_count' );
|
17 |
-
$this->woocommerce_default_user_meta_keys = array( 'billing_first_name', 'billing_last_name', 'billing_email', 'billing_phone', 'billing_country', 'billing_address_1', 'billing_city', 'billing_state', 'billing_postcode', 'shipping_first_name', 'shipping_last_name', 'shipping_country', 'shipping_address_1', 'shipping_address_2', 'shipping_city', 'shipping_state', 'shipping_postcode' );
|
18 |
-
$this->other_non_date_keys = array( 'shipping_phone' );
|
19 |
|
20 |
add_action( 'init', array( $this, 'download_export_file' ) );
|
21 |
add_action( 'admin_init', array( $this, 'download_export_file' ) );
|
@@ -186,7 +177,7 @@ class ACUI_Exporter{
|
|
186 |
}
|
187 |
|
188 |
function download_export_file() {
|
189 |
-
if
|
190 |
$exporter = new ACUI_Batch_Exporter();
|
191 |
|
192 |
if ( !empty( $_GET['filename'] ) ){
|
3 |
|
4 |
class ACUI_Exporter{
|
5 |
private $path_csv;
|
|
|
|
|
|
|
|
|
6 |
|
7 |
function __construct(){
|
8 |
$upload_dir = wp_upload_dir();
|
|
|
9 |
$this->path_csv = $upload_dir['basedir'] . "/export-users.csv";
|
|
|
|
|
|
|
|
|
10 |
|
11 |
add_action( 'init', array( $this, 'download_export_file' ) );
|
12 |
add_action( 'admin_init', array( $this, 'download_export_file' ) );
|
177 |
}
|
178 |
|
179 |
function download_export_file() {
|
180 |
+
if( current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) && isset( $_GET['action'], $_GET['nonce'] ) && wp_verify_nonce( wp_unslash( $_GET['nonce'] ), 'codection-security' ) && 'download_user_csv' === wp_unslash( $_GET['action'] ) ) {
|
181 |
$exporter = new ACUI_Batch_Exporter();
|
182 |
|
183 |
if ( !empty( $_GET['filename'] ) ){
|
classes/helper.php
CHANGED
@@ -137,12 +137,9 @@ class ACUI_Helper{
|
|
137 |
|
138 |
static function get_attachment_id_by_url( $url ) {
|
139 |
$wp_upload_dir = wp_upload_dir();
|
140 |
-
// Strip out protocols, so it doesn't fail because searching for http: in https: dir.
|
141 |
$dir = set_url_scheme( trailingslashit( $wp_upload_dir['baseurl'] ), 'relative' );
|
142 |
|
143 |
-
|
144 |
-
if ( false !== strpos( $url, $dir ) ) {
|
145 |
-
|
146 |
$file = basename( $url );
|
147 |
|
148 |
$query_args = array(
|
137 |
|
138 |
static function get_attachment_id_by_url( $url ) {
|
139 |
$wp_upload_dir = wp_upload_dir();
|
|
|
140 |
$dir = set_url_scheme( trailingslashit( $wp_upload_dir['baseurl'] ), 'relative' );
|
141 |
|
142 |
+
if ( false !== strpos( $url, $dir ) ) {
|
|
|
|
|
143 |
$file = basename( $url );
|
144 |
|
145 |
$query_args = array(
|
classes/homepage.php
CHANGED
@@ -3,9 +3,24 @@ if ( ! defined( 'ABSPATH' ) ) exit;
|
|
3 |
|
4 |
class ACUI_Homepage{
|
5 |
function __construct(){
|
6 |
-
add_action( 'acui_homepage_start', array( $this, 'maybe_remove_old_csv' ) );
|
7 |
}
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
static function admin_gui(){
|
10 |
$last_roles_used = empty( get_option( 'acui_last_roles_used' ) ) ? array( 'subscriber' ) : get_option( 'acui_last_roles_used' );
|
11 |
?>
|
@@ -51,9 +66,7 @@ class ACUI_Homepage{
|
|
51 |
<th scope="row"><label for="role"><?php _e( 'Default role', 'import-users-from-csv-with-meta' ); ?></label></th>
|
52 |
<td>
|
53 |
<?php
|
54 |
-
|
55 |
-
|
56 |
-
foreach ($list_roles as $key => $value) {
|
57 |
if( in_array( $key, $last_roles_used ) )
|
58 |
echo "<label id='$key' style='margin-right:5px;'><input name='role[]' type='checkbox' checked='checked' value='$key'/>$value</label>";
|
59 |
else
|
@@ -166,14 +179,7 @@ class ACUI_Homepage{
|
|
166 |
</div>
|
167 |
<div style="margin-left:25px;">
|
168 |
<select id="delete_users_assign_posts" name="delete_users_assign_posts">
|
169 |
-
|
170 |
-
<?php
|
171 |
-
$blogusers = get_users( array( 'fields' => array( 'ID', 'display_name' ) ) );
|
172 |
-
|
173 |
-
foreach ( $blogusers as $bloguser ) {
|
174 |
-
echo "<option value='{$bloguser->ID}'>{$bloguser->display_name}</option>";
|
175 |
-
}
|
176 |
-
?>
|
177 |
</select>
|
178 |
<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>
|
179 |
</div>
|
@@ -188,13 +194,9 @@ class ACUI_Homepage{
|
|
188 |
</div>
|
189 |
<div style="margin-left:25px;">
|
190 |
<select id="change_role_not_present_role" name="change_role_not_present_role">
|
191 |
-
<?php
|
192 |
-
|
193 |
-
|
194 |
-
foreach ($list_roles as $key => $value) {
|
195 |
-
echo "<option value='$key'>$value</option>";
|
196 |
-
}
|
197 |
-
?>
|
198 |
</select>
|
199 |
<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>
|
200 |
</div>
|
@@ -243,12 +245,12 @@ class ACUI_Homepage{
|
|
243 |
</div>
|
244 |
<script type="text/javascript">
|
245 |
function check(){
|
246 |
-
if(document.getElementById(
|
247 |
alert("<?php _e( 'Please choose a file', 'import-users-from-csv-with-meta' ); ?>");
|
248 |
return false;
|
249 |
}
|
250 |
|
251 |
-
if( jQuery(
|
252 |
alert("<?php _e( 'Please enter a path to the file', 'import-users-from-csv-with-meta' ); ?>");
|
253 |
return false;
|
254 |
}
|
@@ -261,7 +263,7 @@ class ACUI_Homepage{
|
|
261 |
check_delete_users_checked();
|
262 |
});
|
263 |
|
264 |
-
$(
|
265 |
var answer = confirm( "<?php _e( 'Are you sure to delete this file?', 'import-users-from-csv-with-meta' ); ?>" );
|
266 |
if( answer ){
|
267 |
var data = {
|
@@ -281,7 +283,7 @@ class ACUI_Homepage{
|
|
281 |
}
|
282 |
});
|
283 |
|
284 |
-
$(
|
285 |
var answer = confirm( "<?php _e( 'Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins.', 'import-users-from-csv-with-meta' ); ?>" );
|
286 |
if( answer ){
|
287 |
var data = {
|
@@ -300,22 +302,48 @@ class ACUI_Homepage{
|
|
300 |
}
|
301 |
});
|
302 |
|
303 |
-
$(
|
304 |
e.preventDefault();
|
305 |
-
|
306 |
-
$("#upload_file,#introduce_path").toggle();
|
307 |
} );
|
308 |
|
309 |
-
$(
|
310 |
-
var win=window.open(
|
311 |
win.focus();
|
312 |
-
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
|
314 |
function check_delete_users_checked(){
|
315 |
-
if( $('#delete_users').is(':checked') ){
|
|
|
316 |
$( '#change_role_not_present' ).prop( 'disabled', true );
|
317 |
$( '#change_role_not_present_role' ).prop( 'disabled', true );
|
318 |
} else {
|
|
|
319 |
$( '#change_role_not_present' ).prop( 'disabled', false );
|
320 |
$( '#change_role_not_present_role' ).prop( 'disabled', false );
|
321 |
}
|
@@ -358,4 +386,79 @@ class ACUI_Homepage{
|
|
358 |
</div>
|
359 |
<?php endif;
|
360 |
}
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
class ACUI_Homepage{
|
5 |
function __construct(){
|
|
|
6 |
}
|
7 |
|
8 |
+
function hooks(){
|
9 |
+
add_action( 'admin_enqueue_scripts', array( $this, 'load_scripts' ), 10, 1 );
|
10 |
+
add_action( 'acui_homepage_start', array( $this, 'maybe_remove_old_csv' ) );
|
11 |
+
add_action( 'wp_ajax_acui_delete_attachment', array( $this, 'delete_attachment' ) );
|
12 |
+
add_action( 'wp_ajax_acui_bulk_delete_attachment', array( $this, 'bulk_delete_attachment' ) );
|
13 |
+
add_action( 'wp_ajax_acui_delete_users_assign_posts_data', array( $this, 'delete_users_assign_posts_data' ) );
|
14 |
+
}
|
15 |
+
|
16 |
+
function load_scripts( $hook ){
|
17 |
+
if( $hook != 'tools_page_acui' || isset( $_GET['tab'] ) )
|
18 |
+
return;
|
19 |
+
|
20 |
+
wp_enqueue_style( 'select2-css', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css' );
|
21 |
+
wp_enqueue_script( 'select2-js', '//cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js' );
|
22 |
+
}
|
23 |
+
|
24 |
static function admin_gui(){
|
25 |
$last_roles_used = empty( get_option( 'acui_last_roles_used' ) ) ? array( 'subscriber' ) : get_option( 'acui_last_roles_used' );
|
26 |
?>
|
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
|
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>
|
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>
|
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 |
}
|
263 |
check_delete_users_checked();
|
264 |
});
|
265 |
|
266 |
+
$( '.delete_attachment' ).click( function(){
|
267 |
var answer = confirm( "<?php _e( 'Are you sure to delete this file?', 'import-users-from-csv-with-meta' ); ?>" );
|
268 |
if( answer ){
|
269 |
var data = {
|
283 |
}
|
284 |
});
|
285 |
|
286 |
+
$( '#bulk_delete_attachment' ).click( function(){
|
287 |
var answer = confirm( "<?php _e( 'Are you sure to delete ALL CSV files uploaded? There can be CSV files from other plugins.', 'import-users-from-csv-with-meta' ); ?>" );
|
288 |
if( answer ){
|
289 |
var data = {
|
302 |
}
|
303 |
});
|
304 |
|
305 |
+
$( '.toggle_upload_path' ).click( function( e ){
|
306 |
e.preventDefault();
|
307 |
+
$( '#upload_file,#introduce_path' ).toggle();
|
|
|
308 |
} );
|
309 |
|
310 |
+
$( '#vote_us' ).click( function(){
|
311 |
+
var win=window.open( 'http://wordpress.org/support/view/plugin-reviews/import-users-from-csv-with-meta?free-counter?rate=5#postform', '_blank');
|
312 |
win.focus();
|
313 |
+
} );
|
314 |
+
|
315 |
+
$( '#change_role_not_present_role' ).select2();
|
316 |
+
|
317 |
+
$( '#delete_users_assign_posts' ).select2({
|
318 |
+
ajax: {
|
319 |
+
url: '<?php echo admin_url( 'admin-ajax.php' ) ?>',
|
320 |
+
cache: true,
|
321 |
+
dataType: 'json',
|
322 |
+
minimumInputLength: 3,
|
323 |
+
allowClear: true,
|
324 |
+
placeholder: { id: '', title: '<?php _e( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) ?>' },
|
325 |
+
data: function( params ) {
|
326 |
+
if (params.term.trim().length < 3)
|
327 |
+
throw false;
|
328 |
+
|
329 |
+
var query = {
|
330 |
+
search: params.term,
|
331 |
+
_wpnonce: '<?php echo wp_create_nonce( 'codection-security' ); ?>',
|
332 |
+
action: 'acui_delete_users_assign_posts_data',
|
333 |
+
}
|
334 |
+
|
335 |
+
return query;
|
336 |
+
}
|
337 |
+
}
|
338 |
+
});
|
339 |
|
340 |
function check_delete_users_checked(){
|
341 |
+
if( $( '#delete_users' ).is( ':checked' ) ){
|
342 |
+
$( '#delete_users_assign_posts' ).prop( 'disabled', false );
|
343 |
$( '#change_role_not_present' ).prop( 'disabled', true );
|
344 |
$( '#change_role_not_present_role' ).prop( 'disabled', true );
|
345 |
} else {
|
346 |
+
$( '#delete_users_assign_posts' ).prop( 'disabled', true );
|
347 |
$( '#change_role_not_present' ).prop( 'disabled', false );
|
348 |
$( '#change_role_not_present_role' ).prop( 'disabled', false );
|
349 |
}
|
386 |
</div>
|
387 |
<?php endif;
|
388 |
}
|
389 |
+
|
390 |
+
function delete_attachment() {
|
391 |
+
check_ajax_referer( 'codection-security', 'security' );
|
392 |
+
|
393 |
+
if( ! current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) )
|
394 |
+
wp_die( __( 'Only users who are able to create users can delete CSV attachments.', 'import-users-from-csv-with-meta' ) );
|
395 |
+
|
396 |
+
$attach_id = absint( $_POST['attach_id'] );
|
397 |
+
$mime_type = (string) get_post_mime_type( $attach_id );
|
398 |
+
|
399 |
+
if( $mime_type != 'text/csv' )
|
400 |
+
_e('This plugin only can delete the type of file it manages, CSV files.', 'import-users-from-csv-with-meta' );
|
401 |
+
|
402 |
+
$result = wp_delete_attachment( $attach_id, true );
|
403 |
+
|
404 |
+
if( $result === false )
|
405 |
+
_e( 'There were problems deleting the file, please check file permissions', 'import-users-from-csv-with-meta' );
|
406 |
+
else
|
407 |
+
echo 1;
|
408 |
+
|
409 |
+
wp_die();
|
410 |
+
}
|
411 |
+
|
412 |
+
function bulk_delete_attachment(){
|
413 |
+
check_ajax_referer( 'codection-security', 'security' );
|
414 |
+
|
415 |
+
if( ! current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) )
|
416 |
+
wp_die( __( 'Only users who are able to create users can bulk delete CSV attachments.', 'import-users-from-csv-with-meta' ) );
|
417 |
+
|
418 |
+
$args_old_csv = array( 'post_type'=> 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1 );
|
419 |
+
$old_csv_files = new WP_Query( $args_old_csv );
|
420 |
+
$result = 1;
|
421 |
+
|
422 |
+
while($old_csv_files->have_posts()) :
|
423 |
+
$old_csv_files->the_post();
|
424 |
+
|
425 |
+
$mime_type = (string) get_post_mime_type( get_the_ID() );
|
426 |
+
if( $mime_type != 'text/csv' )
|
427 |
+
wp_die( __('This plugin only can delete the type of file it manages, CSV files.', 'import-users-from-csv-with-meta' ) );
|
428 |
+
|
429 |
+
if( wp_delete_attachment( get_the_ID(), true ) === false )
|
430 |
+
$result = 0;
|
431 |
+
endwhile;
|
432 |
+
|
433 |
+
wp_reset_postdata();
|
434 |
+
|
435 |
+
echo $result;
|
436 |
+
|
437 |
+
wp_die();
|
438 |
+
}
|
439 |
+
|
440 |
+
function delete_users_assign_posts_data(){
|
441 |
+
check_ajax_referer( 'codection-security', 'security' );
|
442 |
+
|
443 |
+
if( ! current_user_can( apply_filters( 'acui_capability', 'create_users' ) ) )
|
444 |
+
wp_die( __( 'Only users who are able to create users can manage this option.', 'import-users-from-csv-with-meta' ) );
|
445 |
+
|
446 |
+
$results = array( array( 'id' => '', 'value' => __( 'Delete posts of deleted users without assigning to any user', 'import-users-from-csv-with-meta' ) ) );
|
447 |
+
$search = sanitize_text_field( $_GET['search'] );
|
448 |
+
|
449 |
+
if( strlen( $search ) >= 3 ){
|
450 |
+
$blogusers = get_users( array( 'fields' => array( 'ID', 'display_name' ), 'search' => '*' . $search . '*' ) );
|
451 |
+
|
452 |
+
foreach ( $blogusers as $bloguser ) {
|
453 |
+
$results[] = array( 'id' => $bloguser->ID, 'text' => $bloguser->display_name );
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
echo json_encode( array( 'results' => $results, 'more' => 'false' ) );
|
458 |
+
|
459 |
+
wp_die();
|
460 |
+
}
|
461 |
+
}
|
462 |
+
|
463 |
+
$acui_homepage = new ACUI_Homepage();
|
464 |
+
$acui_homepage->hooks();
|
classes/import.php
CHANGED
@@ -135,7 +135,7 @@ class ACUI_Import{
|
|
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' ) );
|
137 |
}
|
138 |
-
|
139 |
if( empty( $_FILES['uploadfile']['name'] ) || $is_frontend ):
|
140 |
$path_to_file = wp_normalize_path( $form_data["path_to_file"] );
|
141 |
|
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' ) );
|
137 |
}
|
138 |
+
|
139 |
if( empty( $_FILES['uploadfile']['name'] ) || $is_frontend ):
|
140 |
$path_to_file = wp_normalize_path( $form_data["path_to_file"] );
|
141 |
|
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.
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
@@ -14,7 +14,7 @@ Domain Path: /languages
|
|
14 |
if ( ! defined( 'ABSPATH' ) )
|
15 |
exit;
|
16 |
|
17 |
-
define( 'ACUI_VERSION', '1.18.
|
18 |
|
19 |
class ImportExportUsersCustomers{
|
20 |
var $file;
|
@@ -43,8 +43,6 @@ class ImportExportUsersCustomers{
|
|
43 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 10, 1 );
|
44 |
add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
|
45 |
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
46 |
-
add_action( 'wp_ajax_acui_delete_attachment', array( $this, 'delete_attachment' ) );
|
47 |
-
add_action( 'wp_ajax_acui_bulk_delete_attachment', array( $this, 'bulk_delete_attachment' ) );
|
48 |
add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), PHP_INT_MAX, 4 );
|
49 |
|
50 |
if( is_plugin_active( 'buddypress/bp-loader.php' ) && file_exists( plugin_dir_path( __DIR__ ) . 'buddypress/bp-xprofile/classes/class-bp-xprofile-group.php' ) ){
|
@@ -123,56 +121,6 @@ class ImportExportUsersCustomers{
|
|
123 |
return $links;
|
124 |
}
|
125 |
|
126 |
-
function delete_attachment() {
|
127 |
-
check_ajax_referer( 'codection-security', 'security' );
|
128 |
-
|
129 |
-
if( ! current_user_can( 'manage_options' ) )
|
130 |
-
wp_die( __('You are not an adminstrator', 'import-users-from-csv-with-meta' ) );
|
131 |
-
|
132 |
-
$attach_id = absint( $_POST['attach_id'] );
|
133 |
-
$mime_type = (string) get_post_mime_type( $attach_id );
|
134 |
-
|
135 |
-
if( $mime_type != 'text/csv' )
|
136 |
-
_e('This plugin only can delete the type of file it manages, CSV files.', 'import-users-from-csv-with-meta' );
|
137 |
-
|
138 |
-
$result = wp_delete_attachment( $attach_id, true );
|
139 |
-
|
140 |
-
if( $result === false )
|
141 |
-
_e( 'There were problems deleting the file, please check file permissions', 'import-users-from-csv-with-meta' );
|
142 |
-
else
|
143 |
-
echo 1;
|
144 |
-
|
145 |
-
wp_die();
|
146 |
-
}
|
147 |
-
|
148 |
-
function bulk_delete_attachment(){
|
149 |
-
check_ajax_referer( 'codection-security', 'security' );
|
150 |
-
|
151 |
-
if( ! current_user_can( 'manage_options' ) )
|
152 |
-
wp_die( __('You are not an adminstrator', 'import-users-from-csv-with-meta' ) );
|
153 |
-
|
154 |
-
$args_old_csv = array( 'post_type'=> 'attachment', 'post_mime_type' => 'text/csv', 'post_status' => 'inherit', 'posts_per_page' => -1 );
|
155 |
-
$old_csv_files = new WP_Query( $args_old_csv );
|
156 |
-
$result = 1;
|
157 |
-
|
158 |
-
while($old_csv_files->have_posts()) :
|
159 |
-
$old_csv_files->the_post();
|
160 |
-
|
161 |
-
$mime_type = (string) get_post_mime_type( get_the_ID() );
|
162 |
-
if( $mime_type != 'text/csv' )
|
163 |
-
wp_die( __('This plugin only can delete the type of file it manages, CSV files.', 'import-users-from-csv-with-meta' ) );
|
164 |
-
|
165 |
-
if( wp_delete_attachment( get_the_ID(), true ) === false )
|
166 |
-
$result = 0;
|
167 |
-
endwhile;
|
168 |
-
|
169 |
-
wp_reset_postdata();
|
170 |
-
|
171 |
-
echo $result;
|
172 |
-
|
173 |
-
wp_die();
|
174 |
-
}
|
175 |
-
|
176 |
function wp_check_filetype_and_ext( $values, $file, $filename, $mimes ) {
|
177 |
if ( extension_loaded( 'fileinfo' ) ) {
|
178 |
// with the php-extension, a CSV file is issues type text/plain so we fix that back to
|
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.3
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
14 |
if ( ! defined( 'ABSPATH' ) )
|
15 |
exit;
|
16 |
|
17 |
+
define( 'ACUI_VERSION', '1.18.3' );
|
18 |
|
19 |
class ImportExportUsersCustomers{
|
20 |
var $file;
|
43 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ), 10, 1 );
|
44 |
add_filter( 'plugin_action_links', array( $this, 'action_links' ), 10, 2 );
|
45 |
add_filter( 'plugin_row_meta', array( $this, 'plugin_row_meta' ), 10, 2 );
|
|
|
|
|
46 |
add_filter( 'wp_check_filetype_and_ext', array( $this, 'wp_check_filetype_and_ext' ), PHP_INT_MAX, 4 );
|
47 |
|
48 |
if( is_plugin_active( 'buddypress/bp-loader.php' ) && file_exists( plugin_dir_path( __DIR__ ) . 'buddypress/bp-xprofile/classes/class-bp-xprofile-group.php' ) ){
|
121 |
return $links;
|
122 |
}
|
123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
function wp_check_filetype_and_ext( $values, $file, $filename, $mimes ) {
|
125 |
if ( extension_loaded( 'fileinfo' ) ) {
|
126 |
// with the php-extension, a CSV file is issues type text/plain so we fix that back to
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ 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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -103,6 +103,10 @@ Plugin will automatically detect:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
|
|
106 |
= 1.18.2.3 =
|
107 |
* Problem solved converting timestamps when exporting
|
108 |
* If an error raise in the server while exporting, instead only showing the error in the console, we throws an alert to improve user experience
|
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.3
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.18.3 =
|
107 |
+
* Problem solved converting data that has a format date but that is not wanted to be converted, to timestamps when exporting
|
108 |
+
* Fixed problems in standard import, in very big databases, there was a problem creating the list of users to assign deleted posts, now this list is created and managed using select2 and AJAX to improve performance and usability
|
109 |
+
|
110 |
= 1.18.2.3 =
|
111 |
* Problem solved converting timestamps when exporting
|
112 |
* If an error raise in the server while exporting, instead only showing the error in the console, we throws an alert to improve user experience
|