Version Description
- New tab with a list of all meta keys found in the database, with the type of it and an example to be able to use it in your imports
Download this release
Release Info
Developer | carazo |
Plugin | Import users from CSV with meta |
Version | 1.15.1 |
Comparing to | |
See all releases |
Code changes from version 1.15.0.1 to 1.15.1
- classes/meta-keys.php +126 -0
- import-users-from-csv-with-meta.php +3 -1
- importer.php +4 -0
- readme.txt +4 -1
classes/meta-keys.php
ADDED
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( ! defined( 'ABSPATH' ) ) exit;
|
4 |
+
|
5 |
+
if ( ! class_exists( 'WP_List_Table' ) ) {
|
6 |
+
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
|
7 |
+
}
|
8 |
+
|
9 |
+
class ACUI_MetaKeys{
|
10 |
+
public static function admin_gui(){
|
11 |
+
$customers_obj = new Customers_List();
|
12 |
+
?>
|
13 |
+
<style type="text/css">
|
14 |
+
.tablenav.top{
|
15 |
+
display: none;
|
16 |
+
}
|
17 |
+
</style>
|
18 |
+
<h3><?php _e( 'Meta keys used in your database for users', 'import-users-from-csv-with-meta' ); ?></h3>
|
19 |
+
<div id="poststuff">
|
20 |
+
<div id="post-body" class="metabox-holder columns-2">
|
21 |
+
<div id="post-body-content">
|
22 |
+
<div class="meta-box-sortables ui-sortable">
|
23 |
+
<form method="post">
|
24 |
+
<?php
|
25 |
+
$customers_obj->prepare_items();
|
26 |
+
$customers_obj->display(); ?>
|
27 |
+
</form>
|
28 |
+
</div>
|
29 |
+
</div>
|
30 |
+
</div>
|
31 |
+
<br class="clear">
|
32 |
+
</div>
|
33 |
+
<?php
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
class Customers_List extends WP_List_Table {
|
38 |
+
public function __construct() {
|
39 |
+
parent::__construct( [
|
40 |
+
'singular' => 'Meta key',
|
41 |
+
'plural' => 'Meta keys',
|
42 |
+
'ajax' => false,
|
43 |
+
] );
|
44 |
+
}
|
45 |
+
|
46 |
+
function get_columns() {
|
47 |
+
$columns = [
|
48 |
+
'meta_key' => 'Meta key',
|
49 |
+
'type' => 'Type',
|
50 |
+
'example' => 'Example'
|
51 |
+
];
|
52 |
+
|
53 |
+
return $columns;
|
54 |
+
}
|
55 |
+
|
56 |
+
public static function get_meta_keys() {
|
57 |
+
global $wpdb;
|
58 |
+
|
59 |
+
$meta_keys = array();
|
60 |
+
|
61 |
+
$select = "SELECT distinct $wpdb->usermeta.meta_key FROM $wpdb->usermeta ORDER BY $wpdb->usermeta.meta_key";
|
62 |
+
$usermeta = $wpdb->get_results( $select, ARRAY_A );
|
63 |
+
|
64 |
+
foreach ($usermeta as $key => $value) {
|
65 |
+
$meta_key = array();
|
66 |
+
$meta_key['meta_key'] = $value["meta_key"];
|
67 |
+
$meta_key['type'] = "";
|
68 |
+
$meta_key['example'] = "";
|
69 |
+
|
70 |
+
$meta_keys[] = $meta_key;
|
71 |
+
}
|
72 |
+
|
73 |
+
return $meta_keys;
|
74 |
+
}
|
75 |
+
|
76 |
+
public static function record_count() {
|
77 |
+
global $wpdb;
|
78 |
+
|
79 |
+
$select = "SELECT distinct $wpdb->usermeta.meta_key FROM $wpdb->usermeta";
|
80 |
+
$usermeta = $wpdb->get_results( $select );
|
81 |
+
|
82 |
+
return count( $usermeta );
|
83 |
+
}
|
84 |
+
|
85 |
+
public function no_items() {
|
86 |
+
_e( 'No meta keys availale.', 'sp' );
|
87 |
+
}
|
88 |
+
|
89 |
+
public function column_default( $item, $column_name ) {
|
90 |
+
switch ( $column_name ) {
|
91 |
+
case 'meta_key':
|
92 |
+
return $item['meta_key'];
|
93 |
+
|
94 |
+
case 'type':
|
95 |
+
return $this->get_type( $item['meta_key'] );
|
96 |
+
|
97 |
+
case 'example':
|
98 |
+
return $this->get_example( $item['meta_key'] );
|
99 |
+
}
|
100 |
+
}
|
101 |
+
|
102 |
+
public function get_example( $meta_key ){
|
103 |
+
global $wpdb;
|
104 |
+
$select = $wpdb->prepare( "SELECT $wpdb->usermeta.meta_value FROM $wpdb->usermeta WHERE meta_key = %s AND meta_value IS NOT NULL AND meta_value <> '' LIMIT 1", $meta_key );
|
105 |
+
$usermeta = $wpdb->get_results( $select, ARRAY_A);
|
106 |
+
|
107 |
+
$usermeta = reset( $usermeta );
|
108 |
+
|
109 |
+
return $usermeta['meta_value'];
|
110 |
+
}
|
111 |
+
|
112 |
+
public function get_type( $meta_key ){
|
113 |
+
return is_serialized( $this->get_example( $meta_key ) ) ? 'Serialized' : 'Non serialized';
|
114 |
+
}
|
115 |
+
|
116 |
+
function column_name( $item ) {
|
117 |
+
return '<strong>' . $item['name'] . '</strong>';
|
118 |
+
}
|
119 |
+
|
120 |
+
public function prepare_items() {
|
121 |
+
$columns = $this->get_columns();
|
122 |
+
$this->_column_headers = array( $columns, array(), array() );
|
123 |
+
|
124 |
+
$this->items = self::get_meta_keys();
|
125 |
+
}
|
126 |
+
}
|
import-users-from-csv-with-meta.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: Import users from CSV with meta
|
4 |
Plugin URI: https://www.codection.com
|
5 |
Description: This plugins allows to import users using CSV files to WP database automatically
|
6 |
-
Version: 1.15.
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
@@ -25,6 +25,7 @@ require_once( "classes/email-templates.php" );
|
|
25 |
require_once( "classes/homepage.php" );
|
26 |
require_once( "classes/export.php" );
|
27 |
require_once( "classes/columns.php" );
|
|
|
28 |
require_once( "classes/frontend.php" );
|
29 |
require_once( "classes/doc.php" );
|
30 |
require_once( "classes/email-options.php" );
|
@@ -275,6 +276,7 @@ function acui_admin_tabs( $current = 'homepage' ) {
|
|
275 |
'frontend' => __( 'Frontend', 'import-users-from-csv-with-meta' ),
|
276 |
'cron' => __( 'Cron import', 'import-users-from-csv-with-meta' ),
|
277 |
'columns' => __( 'Extra profile fields', 'import-users-from-csv-with-meta' ),
|
|
|
278 |
'mail-options' => __( 'Mail options', 'import-users-from-csv-with-meta' ),
|
279 |
'doc' => __( 'Documentation', 'import-users-from-csv-with-meta' ),
|
280 |
'donate' => __( 'Donate/Patreon', 'import-users-from-csv-with-meta' ),
|
3 |
Plugin Name: Import users from CSV with meta
|
4 |
Plugin URI: https://www.codection.com
|
5 |
Description: This plugins allows to import users using CSV files to WP database automatically
|
6 |
+
Version: 1.15.1
|
7 |
Author: codection
|
8 |
Author URI: https://codection.com
|
9 |
License: GPL2
|
25 |
require_once( "classes/homepage.php" );
|
26 |
require_once( "classes/export.php" );
|
27 |
require_once( "classes/columns.php" );
|
28 |
+
require_once( "classes/meta-keys.php" );
|
29 |
require_once( "classes/frontend.php" );
|
30 |
require_once( "classes/doc.php" );
|
31 |
require_once( "classes/email-options.php" );
|
276 |
'frontend' => __( 'Frontend', 'import-users-from-csv-with-meta' ),
|
277 |
'cron' => __( 'Cron import', 'import-users-from-csv-with-meta' ),
|
278 |
'columns' => __( 'Extra profile fields', 'import-users-from-csv-with-meta' ),
|
279 |
+
'meta-keys' => __( 'Meta keys', 'import-users-from-csv-with-meta' ),
|
280 |
'mail-options' => __( 'Mail options', 'import-users-from-csv-with-meta' ),
|
281 |
'doc' => __( 'Documentation', 'import-users-from-csv-with-meta' ),
|
282 |
'donate' => __( 'Donate/Patreon', 'import-users-from-csv-with-meta' ),
|
importer.php
CHANGED
@@ -774,6 +774,10 @@ function acui_options(){
|
|
774 |
ACUI_Columns::admin_gui();
|
775 |
break;
|
776 |
|
|
|
|
|
|
|
|
|
777 |
case 'doc':
|
778 |
ACUI_Doc::message();
|
779 |
break;
|
774 |
ACUI_Columns::admin_gui();
|
775 |
break;
|
776 |
|
777 |
+
case 'meta-keys':
|
778 |
+
ACUI_MetaKeys::admin_gui();
|
779 |
+
break;
|
780 |
+
|
781 |
case 'doc':
|
782 |
ACUI_Doc::message();
|
783 |
break;
|
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.3.2
|
7 |
-
Stable tag: 1.15.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -91,6 +91,9 @@ Plugin will automatically detect:
|
|
91 |
|
92 |
== Changelog ==
|
93 |
|
|
|
|
|
|
|
94 |
= 1.15.0.1 =
|
95 |
* Only users who can create users, can export them
|
96 |
|
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.3.2
|
7 |
+
Stable tag: 1.15.1
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
91 |
|
92 |
== Changelog ==
|
93 |
|
94 |
+
= 1.15.1 =
|
95 |
+
* New tab with a list of all meta keys found in the database, with the type of it and an example to be able to use it in your imports
|
96 |
+
|
97 |
= 1.15.0.1 =
|
98 |
* Only users who can create users, can export them
|
99 |
|