Version Description
- Fixed problem importing ACF multiple select field type, thanks to @lpointet
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.17.3.6 |
Comparing to | |
See all releases |
Code changes from version 1.17.3.5 to 1.17.3.6
- addons/advanced-custom-fields.php +9 -51
- classes/helper.php +43 -0
- import-users-from-csv-with-meta.php +1 -1
- readme.txt +4 -1
addons/advanced-custom-fields.php
CHANGED
@@ -43,7 +43,6 @@ class ACUI_ACF{
|
|
43 |
function import( $headers, $row, $user_id ){
|
44 |
$fields_positions = array();
|
45 |
$types = $this->get_user_fields_types();
|
46 |
-
$types_multiple = array( 'select', 'checkbox', 'radio', 'button_group' );
|
47 |
|
48 |
foreach ( $types as $key => $type ) {
|
49 |
$pos = array_search( $key, $headers );
|
@@ -62,14 +61,14 @@ class ACUI_ACF{
|
|
62 |
}*/
|
63 |
|
64 |
// slugs in relationship
|
65 |
-
if( $types[ $key ]
|
66 |
$data = explode( ',', $row[ $pos ] );
|
67 |
|
68 |
foreach ( $data as $it => $slug ) {
|
69 |
$data[ $it ] = $this->get_post_id_by_slug( $slug );
|
70 |
}
|
71 |
}
|
72 |
-
elseif(
|
73 |
$data = explode( ',', $row[ $pos ] );
|
74 |
array_filter( $data, function( $value ){ return $value !== ''; } );
|
75 |
}
|
@@ -123,64 +122,23 @@ class ACUI_ACF{
|
|
123 |
function get_user_fields_types(){
|
124 |
$fields = $this->get_user_fields();
|
125 |
$fields_keys = array();
|
|
|
126 |
|
127 |
if( empty( $fields ) )
|
128 |
return array();
|
129 |
|
130 |
foreach ( $fields as $group => $fields_of_group ){
|
131 |
foreach ( $fields_of_group as $field ){
|
132 |
-
$fields_keys[ $field['name'] ] =
|
|
|
|
|
|
|
|
|
133 |
}
|
134 |
}
|
135 |
|
136 |
return $fields_keys;
|
137 |
}
|
138 |
-
|
139 |
-
function get_post_id_by_slug( $slug ){
|
140 |
-
global $wpdb;
|
141 |
-
|
142 |
-
$page_path = rawurlencode( urldecode( $slug ) );
|
143 |
-
$page_path = str_replace( '%2F', '/', $page_path );
|
144 |
-
$page_path = str_replace( '%20', ' ', $page_path );
|
145 |
-
$parts = explode( '/', trim( $page_path, '/' ) );
|
146 |
-
$parts = array_map( 'sanitize_title_for_query', $parts );
|
147 |
-
$escaped_parts = esc_sql( $parts );
|
148 |
-
|
149 |
-
$in_string = "'" . implode( "','", $escaped_parts ) . "'";
|
150 |
-
|
151 |
-
$sql = "SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts WHERE post_name IN ($in_string)";
|
152 |
-
|
153 |
-
$pages = $wpdb->get_results( $sql, OBJECT_K );
|
154 |
-
|
155 |
-
$revparts = array_reverse( $parts );
|
156 |
-
|
157 |
-
$foundid = 0;
|
158 |
-
|
159 |
-
foreach ( (array) $pages as $page ) {
|
160 |
-
if ( $page->post_name == $revparts[0] ) {
|
161 |
-
$count = 0;
|
162 |
-
$p = $page;
|
163 |
-
|
164 |
-
while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
|
165 |
-
$count++;
|
166 |
-
$parent = $pages[ $p->post_parent ];
|
167 |
-
if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
|
168 |
-
break;
|
169 |
-
}
|
170 |
-
$p = $parent;
|
171 |
-
}
|
172 |
-
|
173 |
-
if ( 0 == $p->post_parent && count( $revparts ) == $count + 1 && $p->post_name == $revparts[ $count ] ) {
|
174 |
-
$foundid = $page->ID;
|
175 |
-
if ( $page->post_type == $post_type ) {
|
176 |
-
break;
|
177 |
-
}
|
178 |
-
}
|
179 |
-
}
|
180 |
-
}
|
181 |
-
|
182 |
-
return $foundid;
|
183 |
-
}
|
184 |
}
|
185 |
|
186 |
-
new ACUI_ACF();
|
43 |
function import( $headers, $row, $user_id ){
|
44 |
$fields_positions = array();
|
45 |
$types = $this->get_user_fields_types();
|
|
|
46 |
|
47 |
foreach ( $types as $key => $type ) {
|
48 |
$pos = array_search( $key, $headers );
|
61 |
}*/
|
62 |
|
63 |
// slugs in relationship
|
64 |
+
if( $types[ $key ][ 'type' ] == 'relationship' ){
|
65 |
$data = explode( ',', $row[ $pos ] );
|
66 |
|
67 |
foreach ( $data as $it => $slug ) {
|
68 |
$data[ $it ] = $this->get_post_id_by_slug( $slug );
|
69 |
}
|
70 |
}
|
71 |
+
elseif( $types[ $key ][ 'multiple' ] ){
|
72 |
$data = explode( ',', $row[ $pos ] );
|
73 |
array_filter( $data, function( $value ){ return $value !== ''; } );
|
74 |
}
|
122 |
function get_user_fields_types(){
|
123 |
$fields = $this->get_user_fields();
|
124 |
$fields_keys = array();
|
125 |
+
$types_multiple = array( 'select', 'checkbox', 'radio', 'button_group' );
|
126 |
|
127 |
if( empty( $fields ) )
|
128 |
return array();
|
129 |
|
130 |
foreach ( $fields as $group => $fields_of_group ){
|
131 |
foreach ( $fields_of_group as $field ){
|
132 |
+
$fields_keys[ $field['name'] ] = [
|
133 |
+
'type' => $field['type'],
|
134 |
+
// 'select' type has a 'multiple' key which can be 0 or 1
|
135 |
+
'multiple' => !empty( $field['multiple'] ) || ( !isset( $field['multiple'] ) && in_array( $field['type'], $types_multiple ) ),
|
136 |
+
];
|
137 |
}
|
138 |
}
|
139 |
|
140 |
return $fields_keys;
|
141 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
+
new ACUI_ACF();
|
classes/helper.php
CHANGED
@@ -176,6 +176,49 @@ class ACUI_Helper{
|
|
176 |
return false;
|
177 |
}
|
178 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
function print_table_header_footer( $headers ){
|
180 |
?>
|
181 |
<h3><?php echo apply_filters( 'acui_log_inserting_updating_data_title', __( 'Inserting and updating data', 'import-users-from-csv-with-meta' ) ); ?></h3>
|
176 |
return false;
|
177 |
}
|
178 |
|
179 |
+
static function get_post_id_by_slug( $slug ){
|
180 |
+
global $wpdb;
|
181 |
+
|
182 |
+
$page_path = rawurlencode( urldecode( $slug ) );
|
183 |
+
$page_path = str_replace( '%2F', '/', $page_path );
|
184 |
+
$page_path = str_replace( '%20', ' ', $page_path );
|
185 |
+
$parts = explode( '/', trim( $page_path, '/' ) );
|
186 |
+
$parts = array_map( 'sanitize_title_for_query', $parts );
|
187 |
+
$escaped_parts = esc_sql( $parts );
|
188 |
+
|
189 |
+
$in_string = "'" . implode( "','", $escaped_parts ) . "'";
|
190 |
+
|
191 |
+
$pages = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_name, post_parent, post_type FROM $wpdb->posts WHERE post_name IN (%s)", $in_string ), OBJECT_K );
|
192 |
+
$revparts = array_reverse( $parts );
|
193 |
+
|
194 |
+
$foundid = 0;
|
195 |
+
|
196 |
+
foreach ( (array) $pages as $page ) {
|
197 |
+
if ( $page->post_name == $revparts[0] ) {
|
198 |
+
$count = 0;
|
199 |
+
$p = $page;
|
200 |
+
|
201 |
+
while ( 0 != $p->post_parent && isset( $pages[ $p->post_parent ] ) ) {
|
202 |
+
$count++;
|
203 |
+
$parent = $pages[ $p->post_parent ];
|
204 |
+
if ( ! isset( $revparts[ $count ] ) || $parent->post_name != $revparts[ $count ] ) {
|
205 |
+
break;
|
206 |
+
}
|
207 |
+
$p = $parent;
|
208 |
+
}
|
209 |
+
|
210 |
+
if ( 0 == $p->post_parent && count( $revparts ) == $count + 1 && $p->post_name == $revparts[ $count ] ) {
|
211 |
+
$foundid = $page->ID;
|
212 |
+
if ( $page->post_type == $p->post_type ) {
|
213 |
+
break;
|
214 |
+
}
|
215 |
+
}
|
216 |
+
}
|
217 |
+
}
|
218 |
+
|
219 |
+
return $foundid;
|
220 |
+
}
|
221 |
+
|
222 |
function print_table_header_footer( $headers ){
|
223 |
?>
|
224 |
<h3><?php echo apply_filters( 'acui_log_inserting_updating_data_title', __( 'Inserting and updating data', 'import-users-from-csv-with-meta' ) ); ?></h3>
|
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.17.3.
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
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.17.3.6
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
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.7
|
7 |
-
Stable tag: 1.17.3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -103,6 +103,9 @@ Plugin will automatically detect:
|
|
103 |
|
104 |
== Changelog ==
|
105 |
|
|
|
|
|
|
|
106 |
= 1.17.3.5 =
|
107 |
* Fixed warning on export
|
108 |
|
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.7
|
7 |
+
Stable tag: 1.17.3.6
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
103 |
|
104 |
== Changelog ==
|
105 |
|
106 |
+
= 1.17.3.6 =
|
107 |
+
* Fixed problem importing ACF multiple select field type, thanks to @lpointet
|
108 |
+
|
109 |
= 1.17.3.5 =
|
110 |
* Fixed warning on export
|
111 |
|