Export User Data - Version 2.2.6

Version Description

Download this release

Release Info

Developer qlstudio
Plugin Icon wp plugin Export User Data
Version 2.2.6
Comparing to
See all releases

Code changes from version 2.2.5 to 2.2.6

CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
  ## Changelog ##
2
 
3
- *** 2.2.5 ***
4
 
5
  * New: WordPress Security release
6
 
1
  ## Changelog ##
2
 
3
+ *** 2.2.6 ***
4
 
5
  * New: WordPress Security release
6
 
export-user-data.php CHANGED
@@ -12,7 +12,7 @@
12
  * Plugin Name: Export User Data
13
  * Plugin URI: http://qstudio.us/releases/export-user-data
14
  * Description: Export User data and metadata.
15
- * Version: 2.2.5
16
  * Author: Q Studio
17
  * Author URI: https://qstudio.us
18
  * License: GPL-2.0+
12
  * Plugin Name: Export User Data
13
  * Plugin URI: http://qstudio.us/releases/export-user-data
14
  * Description: Export User data and metadata.
15
+ * Version: 2.2.6
16
  * Author: Q Studio
17
  * Author URI: https://qstudio.us
18
  * License: GPL-2.0+
library/admin/render.php CHANGED
@@ -7,7 +7,6 @@ use q\eud;
7
  use q\eud\plugin;
8
  use q\eud\core\helper as h;
9
  use q\eud\core\user as user;
10
- // use q\eud\core\buddypress as buddypress;
11
  use q\eud\api\admin as api_admin;
12
 
13
  class render {
@@ -74,28 +73,15 @@ class render {
74
 
75
  }
76
 
77
- // clean up $save_export ##
78
- // $save_export = \sanitize_text_field( $save_export );
79
-
80
  // Build array of $options to save and save them ##
81
  if ( isset( $save_export ) ) {
82
 
83
- // h::log( 'user_fields: '. $_POST['user_fields'] );
84
-
85
  // prepare all array values ##
86
  $usermeta =
87
  isset( $_POST['usermeta'] ) ?
88
  array_map( 'sanitize_text_field',
89
  $_POST['usermeta'] ) :
90
  '';
91
- // $bp_fields =
92
- // isset( $_POST['bp_fields'] ) ?
93
- // array_map( 'sanitize_text_field', $_POST['bp_fields'] ) :
94
- // '' ;
95
- // $bp_fields_update =
96
- // isset( $_POST['bp_fields_update_time'] ) ?
97
- // array_map( 'sanitize_text_field', $_POST['bp_fields_update_time'] ) :
98
- // '' ;
99
  $format =
100
  isset( $_POST['format'] ) ?
101
  \sanitize_text_field( $_POST['format'] ) :
@@ -136,16 +122,10 @@ class render {
136
  isset( $_POST['updated_since_date'] ) ?
137
  \sanitize_text_field( $_POST['updated_since_date'] ) :
138
  '' ;
139
- $field_updated_since =
140
- isset( $_POST['bp_field_updated_since'] ) ?
141
- array_map( 'sanitize_text_field', $_POST['bp_field_updated_since'] ) :
142
- '';
143
 
144
  // assign all values to an array ##
145
  $save_array = array (
146
  'usermeta_saved_fields' => $usermeta,
147
- // 'bp_fields_saved_fields' => $bp_fields,
148
- // 'bp_fields_update_time_saved_fields' => $bp_fields_update,
149
  'role' => $role,
150
  'roles' => $roles,
151
  'user_fields' => $user_fields,
@@ -155,7 +135,6 @@ class render {
155
  'limit_offset' => $limit_offset,
156
  'limit_total' => $limit_total,
157
  'updated_since_date' => $updated_since_date,
158
- 'field_updated_since' => $field_updated_since,
159
  'format' => $format
160
  );
161
 
@@ -217,7 +196,6 @@ class render {
217
  $_limit_total = $this->plugin->get( '_limit_total' );
218
  $_updated_since_date = $this->plugin->get( '_updated_since_date' );
219
  $_format = $this->plugin->get( '_format' );
220
- $_field_updated_since = $this->plugin->get( '_field_updated_since' );
221
  $_updated_since_date = $this->plugin->get( '_updated_since_date' );
222
 
223
  ?>
@@ -238,11 +216,8 @@ class render {
238
  // run Query ##
239
  $meta_keys = $wpdb->get_results( $meta_keys_sql );
240
 
241
- // filterable sort ##
242
- // \apply_filters(
243
- // 'q/eud/admin/sort',
244
- asort( $meta_keys );
245
- // );
246
 
247
  // get meta_key value from object ##
248
  $meta_keys = \wp_list_pluck( $meta_keys, 'meta_key' );
@@ -250,10 +225,6 @@ class render {
250
  // allow array to be filtered ##
251
  $meta_keys_common = \apply_filters( 'q/eud/admin/meta_keys_common', [] );
252
 
253
- // test array ##
254
- #helper::log( $meta_keys );
255
- #helper::log( $meta_keys_common );
256
-
257
  // check if we got anything ? ##
258
  if ( $meta_keys ) {
259
 
@@ -282,18 +253,12 @@ class render {
282
 
283
  foreach ( $meta_keys_common as $drop ) {
284
 
285
- #helper::log( 'Checking: '.$drop );
286
-
287
  if ( strpos( $key, $drop ) !== false ) {
288
 
289
- #helper::log( 'Checking: '.$key );
290
-
291
  // https://wordpress.org/support/topic/bugfix-numbers-in-export-headers?replies=1
292
  // removed $key = assignment, as not required ##
293
  if ( ( array_search( $key, $meta_keys ) ) !== false ) {
294
 
295
- #helper::log( 'Found: '.$key );
296
-
297
  $usermeta_class = 'common';
298
 
299
  }
@@ -323,91 +288,6 @@ class render {
323
 
324
  } // meta_keys found ##
325
 
326
- ?>
327
- <?php
328
-
329
- /*
330
- // buddypress x profile data ##
331
- if ( $bp_fields = buddypress::get_fields() ) {
332
-
333
- ?>
334
- <tr valign="top">
335
- <th scope="row">
336
- <label for="q_eud_xprofile"><?php \_e( 'BP xProfile Fields', 'q-export-user-data' ); ?></label>
337
- <p class="filter" style="margin: 10px 0 0;">
338
- <?php \_e('Select', 'q-export-user-data'); ?>: <a href="#" class="select-all"><?php \_e('All', 'q-export-user-data'); ?></a> | <a href="#" class="select-none"><?php \_e('None', 'q-export-user-data'); ?></a>
339
- </p>
340
- </th>
341
- <td>
342
- <select multiple="multiple" id="bp_fields" name="bp_fields[]">
343
- <?php
344
-
345
- foreach ( $bp_fields as $key ) {
346
-
347
- // print key ##
348
- echo "<option value='".\esc_attr( $key )."' title='".\esc_attr( $key )."'>$key</option>";
349
-
350
- }
351
-
352
- ?>
353
- </select>
354
- <p class="description"><?php
355
- printf(
356
- \__( 'Select the BuddyPress XProfile keys to export', 'q-export-user-data' )
357
- );
358
- ?></p>
359
- </td>
360
- </tr>
361
- <?php
362
-
363
- // allow export of update times ##
364
-
365
- ?>
366
- <tr valign="top" class="toggleable">
367
- <th scope="row">
368
- <label for="q_eud_xprofile"><?php \_e( 'BP xProfile Fields Update Time', 'q-export-user-data' ); ?></label>
369
- <p class="filter" style="margin: 10px 0 0;">
370
- <?php \_e('Select', 'q-export-user-data'); ?>: <a href="#" class="select-all"><?php \_e('All', 'q-export-user-data'); ?></a> | <a href="#" class="select-none"><?php _e('None', 'q-export-user-data'); ?></a>
371
- </p>
372
- </th>
373
- <td>
374
- <select multiple="multiple" id="bp_fields_update_time" name="bp_fields_update_time[]">
375
- <?php
376
-
377
- foreach ( $bp_fields as $key ) {
378
-
379
- echo "<option value='".\esc_attr( $key )."' title='".\esc_attr( $key )."'>$key</option>";
380
-
381
- }
382
-
383
- ?>
384
- </select>
385
- <p class="description"><?php
386
- printf(
387
- \__( 'Select the BuddyPress XProfile keys updated dates to export', 'q-export-user-data' )
388
- );
389
- ?></p>
390
- </td>
391
- </tr>
392
-
393
- <tr valign="top" class="toggleable">
394
- <th scope="row"><label for="groups"><?php \_e( 'BP User Groups', 'q-export-user-data' ); ?></label></th>
395
- <td>
396
- <input id='groups' type='checkbox' name='groups' value='1' <?php \checked( isset ( $_groups ) ? intval ( $_groups ) : '', 1 ); ?> />
397
- <p class="description"><?php
398
- printf(
399
- \__( 'Include BuddyPress Group Data. <a href="%s" target="_blank">%s</a>', 'q-export-user-data' )
400
- , \esc_html('https://codex.buddypress.org/buddypress-components-and-features/groups/')
401
- , 'Codex'
402
- );
403
- ?></p>
404
- </td>
405
- </tr>
406
- <?php
407
-
408
- } // BP installed and active ##
409
- */
410
-
411
  ?>
412
  <tr valign="top" class="toggleable">
413
  <th scope="row"><label for="user_fields"><?php \_e( 'Standard User Fields', 'q-export-user-data' ); ?></label></th>
@@ -415,8 +295,6 @@ class render {
415
  <input id='user_fields' type='checkbox' name='user_fields' value='1' <?php \checked( isset ( $_user_fields ) ? intval ( $_user_fields ) : '', 1 ); ?> />
416
  <p class="description"><?php
417
 
418
- #h::log( 'user_fields: '.$_user_fields );
419
-
420
  printf(
421
  \__( 'Include Standard user profile fields, such as user_login. <a href="%s" target="_blank">%s</a>', 'q-export-user-data' )
422
  , \esc_url('https://codex.wordpress.org/Database_Description#Table:_wp_users')
@@ -506,64 +384,23 @@ class render {
506
  ?></p>
507
  </td>
508
  </tr>
509
- <?php
510
 
511
- // buddypress x profile data ##
512
- /*
513
- if ( $bp_fields = buddypress::get_fields() ) {
514
-
515
- ?>
516
- <tr valign="top" class="toggleable">
517
- <th scope="row"><label><?php \_e( 'Updated Since', 'q-export-user-data' ); ?></label></th>
518
- <td>
519
- <input type="text" id="q_eud_updated_since_date" name="updated_since_date" value="<?php echo $_updated_since_date; ?>" class="updated-datepicker" />
520
- <select id="bp_field_updated_since" name="bp_field_updated_since">
521
- <?php
522
 
523
- foreach ( $bp_fields as $key ) {
524
-
525
- if ( $_field_updated_since == $key ) {
526
-
527
- echo "<option value='".\esc_attr( $key )."' title='".\esc_attr( $key )."' selected>$key</option>";
528
-
529
- } else {
530
-
531
- echo "<option value='".\esc_attr( $key )."' title='".\esc_attr( $key )."'>$key</option>";
532
-
533
- }
534
 
535
- }
536
 
537
- ?>
538
- </select>
539
 
540
- <p class="description"><?php
541
- printf(
542
- \__( 'Limit the results to users who have updated this extended profile field after this date.', 'q-export-user-data' )
543
- );
544
- ?></p>
545
- </td>
546
- </tr>
547
- <?php
548
-
549
- } // bp date ##
550
- */
551
-
552
- // pull in extra export options from api ##
553
- if ( $api_fields = \apply_filters( 'q/eud/api/admin/fields', [] ) ) {
554
-
555
- // create api instance #
556
- $api_admin = new \q\eud\api\admin();
557
-
558
- foreach( $api_fields as $field ) {
559
-
560
- $api_admin->render( $field );
561
-
562
- }
563
-
564
- }
565
-
566
- ?>
567
  <tr valign="top">
568
  <th scope="row"><label for="q_eud_users_format"><?php \_e( 'Format', 'q-export-user-data' ); ?></label></th>
569
  <td>
@@ -740,7 +577,6 @@ class render {
740
  if ( ! is_array( $_usermeta_saved_fields ) ) {
741
  $_usermeta_saved_fields = [];
742
  }
743
- // h::log( $_usermeta_saved_fields );
744
 
745
  ?>
746
  <script>
@@ -820,7 +656,7 @@ class render {
820
 
821
  if ( ! q_eud_save_options_new_export || q_eud_save_options_new_export == '' ) {
822
 
823
- e.preventDefault(); // stop things here ##
824
  jQuery('#q_eud_save_options_new_export').addClass("error");
825
 
826
  }
@@ -841,7 +677,6 @@ class render {
841
  // get date format from WP settings #
842
  $date_format = 'yy-mm-dd' ; // get_option('date_format') ? get_option('date_format') : 'yy-mm-dd' ;
843
  $start_of_week = \get_option('start_of_week') ? \get_option('start_of_week') : 'yy-mm-dd' ;
844
- #self::log( 'Date format: '.$date_format );
845
 
846
  ?>
847
  // start date picker ##
7
  use q\eud\plugin;
8
  use q\eud\core\helper as h;
9
  use q\eud\core\user as user;
 
10
  use q\eud\api\admin as api_admin;
11
 
12
  class render {
73
 
74
  }
75
 
 
 
 
76
  // Build array of $options to save and save them ##
77
  if ( isset( $save_export ) ) {
78
 
 
 
79
  // prepare all array values ##
80
  $usermeta =
81
  isset( $_POST['usermeta'] ) ?
82
  array_map( 'sanitize_text_field',
83
  $_POST['usermeta'] ) :
84
  '';
 
 
 
 
 
 
 
 
85
  $format =
86
  isset( $_POST['format'] ) ?
87
  \sanitize_text_field( $_POST['format'] ) :
122
  isset( $_POST['updated_since_date'] ) ?
123
  \sanitize_text_field( $_POST['updated_since_date'] ) :
124
  '' ;
 
 
 
 
125
 
126
  // assign all values to an array ##
127
  $save_array = array (
128
  'usermeta_saved_fields' => $usermeta,
 
 
129
  'role' => $role,
130
  'roles' => $roles,
131
  'user_fields' => $user_fields,
135
  'limit_offset' => $limit_offset,
136
  'limit_total' => $limit_total,
137
  'updated_since_date' => $updated_since_date,
 
138
  'format' => $format
139
  );
140
 
196
  $_limit_total = $this->plugin->get( '_limit_total' );
197
  $_updated_since_date = $this->plugin->get( '_updated_since_date' );
198
  $_format = $this->plugin->get( '_format' );
 
199
  $_updated_since_date = $this->plugin->get( '_updated_since_date' );
200
 
201
  ?>
216
  // run Query ##
217
  $meta_keys = $wpdb->get_results( $meta_keys_sql );
218
 
219
+ // sort ##
220
+ asort( $meta_keys );
 
 
 
221
 
222
  // get meta_key value from object ##
223
  $meta_keys = \wp_list_pluck( $meta_keys, 'meta_key' );
225
  // allow array to be filtered ##
226
  $meta_keys_common = \apply_filters( 'q/eud/admin/meta_keys_common', [] );
227
 
 
 
 
 
228
  // check if we got anything ? ##
229
  if ( $meta_keys ) {
230
 
253
 
254
  foreach ( $meta_keys_common as $drop ) {
255
 
 
 
256
  if ( strpos( $key, $drop ) !== false ) {
257
 
 
 
258
  // https://wordpress.org/support/topic/bugfix-numbers-in-export-headers?replies=1
259
  // removed $key = assignment, as not required ##
260
  if ( ( array_search( $key, $meta_keys ) ) !== false ) {
261
 
 
 
262
  $usermeta_class = 'common';
263
 
264
  }
288
 
289
  } // meta_keys found ##
290
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  ?>
292
  <tr valign="top" class="toggleable">
293
  <th scope="row"><label for="user_fields"><?php \_e( 'Standard User Fields', 'q-export-user-data' ); ?></label></th>
295
  <input id='user_fields' type='checkbox' name='user_fields' value='1' <?php \checked( isset ( $_user_fields ) ? intval ( $_user_fields ) : '', 1 ); ?> />
296
  <p class="description"><?php
297
 
 
 
298
  printf(
299
  \__( 'Include Standard user profile fields, such as user_login. <a href="%s" target="_blank">%s</a>', 'q-export-user-data' )
300
  , \esc_url('https://codex.wordpress.org/Database_Description#Table:_wp_users')
384
  ?></p>
385
  </td>
386
  </tr>
387
+ <?php
388
 
389
+ // pull in extra export options from api ##
390
+ if ( $api_fields = \apply_filters( 'q/eud/api/admin/fields', [] ) ) {
 
 
 
 
 
 
 
 
 
391
 
392
+ // create api instance #
393
+ $api_admin = new \q\eud\api\admin();
394
+
395
+ foreach( $api_fields as $field ) {
396
+
397
+ $api_admin->render( $field );
 
 
 
 
 
398
 
399
+ }
400
 
401
+ }
 
402
 
403
+ ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
404
  <tr valign="top">
405
  <th scope="row"><label for="q_eud_users_format"><?php \_e( 'Format', 'q-export-user-data' ); ?></label></th>
406
  <td>
577
  if ( ! is_array( $_usermeta_saved_fields ) ) {
578
  $_usermeta_saved_fields = [];
579
  }
 
580
 
581
  ?>
582
  <script>
656
 
657
  if ( ! q_eud_save_options_new_export || q_eud_save_options_new_export == '' ) {
658
 
659
+ e.preventDefault();
660
  jQuery('#q_eud_save_options_new_export').addClass("error");
661
 
662
  }
677
  // get date format from WP settings #
678
  $date_format = 'yy-mm-dd' ; // get_option('date_format') ? get_option('date_format') : 'yy-mm-dd' ;
679
  $start_of_week = \get_option('start_of_week') ? \get_option('start_of_week') : 'yy-mm-dd' ;
 
680
 
681
  ?>
682
  // start date picker ##
library/api/admin.php CHANGED
@@ -32,24 +32,17 @@ class admin {
32
  || ! is_array( $array )
33
  ) {
34
 
35
- #h::log( 'No fields found' );
36
-
37
  return false;
38
 
39
  }
40
 
41
- #h::log( $array );
42
-
43
  // check that we have all required arrays ##
44
  if (
45
  ! $array['title'] // string ##
46
  || ! $array['label'] // lowercase string ##
47
  || ! $array['type']
48
- #|| ! $array['description']
49
  ) {
50
 
51
- #h::log( 'Missing data' );
52
-
53
  return false;
54
 
55
  }
@@ -60,13 +53,9 @@ class admin {
60
  // keep labels formatted nicely ##
61
  $array['label'] = \sanitize_key( $array['label'] );
62
 
63
- #h::log( $array['options'] );
64
-
65
  // build out options ##
66
  if ( ! self::has_options( $array ) ) {
67
 
68
- #h::log( 'Missing options for: '.$array['label'] );
69
-
70
  return false;
71
 
72
  }
@@ -126,8 +115,6 @@ class admin {
126
  || ! isset( $array['type'] )
127
  ) {
128
 
129
- #h::log( 'Error building options for: '.$array['label'] );
130
-
131
  return false;
132
 
133
  }
@@ -163,14 +150,10 @@ class admin {
163
  || ! isset( $array['label_select'] )
164
  ) {
165
 
166
- #h::log( 'Error building select options for: '.$array['label'] );
167
-
168
  return false;
169
 
170
  }
171
 
172
- #h::log( 'Building select options for: '.$array['label'] );
173
-
174
  // is this a multiselect ? ##
175
  $multiselect = isset( $array['multiselect'] ) ? ' multiple="multiple"' : '' ;
176
 
32
  || ! is_array( $array )
33
  ) {
34
 
 
 
35
  return false;
36
 
37
  }
38
 
 
 
39
  // check that we have all required arrays ##
40
  if (
41
  ! $array['title'] // string ##
42
  || ! $array['label'] // lowercase string ##
43
  || ! $array['type']
 
44
  ) {
45
 
 
 
46
  return false;
47
 
48
  }
53
  // keep labels formatted nicely ##
54
  $array['label'] = \sanitize_key( $array['label'] );
55
 
 
 
56
  // build out options ##
57
  if ( ! self::has_options( $array ) ) {
58
 
 
 
59
  return false;
60
 
61
  }
115
  || ! isset( $array['type'] )
116
  ) {
117
 
 
 
118
  return false;
119
 
120
  }
150
  || ! isset( $array['label_select'] )
151
  ) {
152
 
 
 
153
  return false;
154
 
155
  }
156
 
 
 
157
  // is this a multiselect ? ##
158
  $multiselect = isset( $array['multiselect'] ) ? ' multiple="multiple"' : '' ;
159
 
library/core/buddypress.php DELETED
@@ -1,87 +0,0 @@
1
- <?php
2
-
3
- namespace q\eud\core;
4
-
5
- // import classes ##
6
- use q\eud;
7
- use q\eud\plugin as plugin;
8
- use q\eud\core\helper as h;
9
-
10
- class buddypress {
11
-
12
- private $plugin;
13
-
14
- function __construct(){
15
-
16
- $this->plugin = plugin::get_instance();
17
-
18
- }
19
-
20
- /**
21
- * Get BP fields from DB, if BuddyPress is installed and active
22
- *
23
- * @since 2.0.0
24
- */
25
- public static function get_fields(){
26
-
27
- // buddypress support deprecated for now ##
28
- return false;
29
-
30
- if ( ! function_exists ('bp_is_active') ) {
31
-
32
- return false;
33
-
34
- }
35
-
36
- // introduce global class object ##
37
- global $wpdb;
38
-
39
- // grab all buddypress x profile fields ##
40
- $bp_fields = $wpdb->get_results( "SELECT distinct(name) FROM ".$wpdb->base_prefix."bp_xprofile_fields WHERE parent_id = 0" );
41
-
42
- // get name value from object ##
43
- $bp_fields = \wp_list_pluck( $bp_fields, 'name' );
44
-
45
- // test array ##
46
- #helper::log( $bp_fields );
47
-
48
- // allow array to be filtered ##
49
- $bp_fields = \apply_filters( 'export_user_data_bp_fields', $bp_fields );
50
-
51
- // kick it back ##
52
- return $bp_fields;
53
-
54
- }
55
-
56
- /**
57
- * Load up saved exports for this user
58
- * Set to public as hooked into action
59
- *
60
- * @since 0.9.6
61
- * @return Array of saved exports
62
- */
63
- public static function load(){
64
-
65
- // do we have a bp object in the globals ##
66
- if (
67
- \is_plugin_active( 'buddypress/bp-loader.php' ) // plugin active
68
- && function_exists ( 'buddypress' ) // loader function exists ##
69
- && ! isset( $GLOBALS['bp'] ) // but global unavailble ##
70
- ) {
71
-
72
- h::log( 'BP not loaded - calling buddypress()' );
73
-
74
- // call BP
75
- \buddypress();
76
-
77
- return true;
78
-
79
- }
80
-
81
- #self::log( 'BP loaded' );
82
-
83
- return true;
84
-
85
- }
86
-
87
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
library/core/config.php CHANGED
@@ -53,17 +53,10 @@ class config {
53
  ]
54
  ];
55
 
56
- // test it ##
57
- #self::log( $array );
58
-
59
  // filter and return ##
60
  apply_filters( 'q/eud/api/admin_fields', $array );
61
 
62
- // test it ##
63
- // h::log( $array );
64
-
65
  // add to static property ##
66
- // self::$api_admin_fields = $array;
67
  $this->plugin->set( '_api_admin_fields', $array );
68
 
69
  // kick back true ##
53
  ]
54
  ];
55
 
 
 
 
56
  // filter and return ##
57
  apply_filters( 'q/eud/api/admin_fields', $array );
58
 
 
 
 
59
  // add to static property ##
 
60
  $this->plugin->set( '_api_admin_fields', $array );
61
 
62
  // kick back true ##
library/core/export.php CHANGED
@@ -34,8 +34,6 @@ class export {
34
  ! isset( $_POST['_wpnonce-q-eud-admin-page'] )
35
  ){
36
 
37
- // h::log( 'No nonce set' );
38
-
39
  return;
40
 
41
  }
@@ -47,8 +45,6 @@ class export {
47
  || isset( $_POST['delete_export'] ) )
48
  {
49
 
50
- // h::log( 'Not exporting, so return...' );
51
-
52
  return;
53
 
54
  }
@@ -80,9 +76,6 @@ class export {
80
  $args['offset'] = $limit_offset;
81
  $args['number'] = $limit_total; // number - Limit the total number of users returned ##
82
 
83
- // test it ##
84
- // h::log( $args );
85
-
86
  }
87
 
88
  }
@@ -90,8 +83,6 @@ class export {
90
  // add custom args via filters ##
91
  $args = \apply_filters( 'q/eud/export/args', $args );
92
 
93
- // h::log( $args );
94
-
95
  // pre_user query ##
96
  \add_action( 'pre_user_query', [ $this, 'pre_user_query' ] );
97
 
@@ -101,9 +92,6 @@ class export {
101
  // remove pre_user_query again ##
102
  \remove_action( 'pre_user_query', [ $this, 'pre_user_query' ] );
103
 
104
- // test args ##
105
- // h::log ( $users );
106
-
107
  // no users found, so chuck an error into the args array and exit the export ##
108
  if ( ! $users ) {
109
 
@@ -188,63 +176,20 @@ class export {
188
 
189
  }
190
 
191
-
192
  // check for selected usermeta fields ##
193
  $usermeta_fields =
194
  isset( $_POST['usermeta'] ) && is_array( $_POST['usermeta'] ) ?
195
  array_map( 'sanitize_text_field', $_POST['usermeta'] ) :
196
  [];
197
- // h::log( $usermeta_fields );
198
-
199
- // check for selected x profile fields ##
200
- /*
201
- $bp_fields = isset( $_POST['bp_fields'] ) ? $_POST['bp_fields'] : '';
202
- $bp_fields_passed = array();
203
- if ( $bp_fields && is_array( $bp_fields ) ) {
204
-
205
- foreach( $bp_fields as $field ) {
206
-
207
- // reverse tidy ##
208
- $field = str_replace( '__', ' ', \sanitize_text_field ( $field ) );
209
-
210
- // add to array ##
211
- $bp_fields_passed[] = $field;
212
-
213
- }
214
-
215
- }
216
-
217
- // cwjordan: check for x profile fields we want update time for ##
218
- $bp_fields_update = isset( $_POST['bp_fields_update_time'] ) ? $_POST['bp_fields_update_time'] : '';
219
- $bp_fields_update_passed = array();
220
- if ( $bp_fields_update && is_array( $bp_fields_update ) ) {
221
-
222
- foreach( $bp_fields_update as $field ) {
223
-
224
- // reverse tidy ##
225
- $field = str_replace( '__', ' ', \sanitize_text_field ( $field ) );
226
-
227
- // add to array ##
228
- $bp_fields_update_passed[] = $field . " Update Date";
229
-
230
- }
231
-
232
- }
233
- */
234
 
235
  // global wpdb object ##
236
  global $wpdb;
237
 
238
- // debug ##
239
- #h::log( 'merging array' );
240
-
241
  // compile final fields list ##
242
  $fields = array_merge(
243
  get::user_fields() // standard wp_user fields ##
244
  , get::special_fields() // 'special' fields - which are controlled via dedicated checks ##
245
  , $usermeta_fields // wp_user_meta fields ##
246
- // , $bp_fields_passed // selected buddypress fields ##
247
- // , $bp_fields_update_passed // update date for buddypress fields ##
248
  );
249
 
250
  // test field array ##
@@ -263,8 +208,6 @@ class export {
263
  // grab fields to exclude from exports - filterable ##
264
  if ( in_array( $fields[$key], get::exclude_fields() ) ) {
265
 
266
- #h::log( 'Dump Field: '. $fields[$key] );
267
-
268
  // ditch 'em ##
269
  unset( $fields[$key] );
270
 
@@ -272,15 +215,7 @@ class export {
272
 
273
  } else {
274
 
275
- // if ( $is_csv ) {
276
-
277
- // $headers[] = '"' . $field . '"';
278
-
279
- // } else {
280
-
281
- $headers[] = $field;
282
-
283
- // }
284
 
285
  }
286
 
@@ -288,7 +223,6 @@ class export {
288
 
289
  // quick check ##
290
  #h::log( $fields );
291
- #h::log( $bp_fields_passed );
292
 
293
  // no more buffering while spitting back the export data ##
294
  if( ob_get_level() > 0 ) ob_end_flush();
@@ -361,93 +295,12 @@ class export {
361
  // open up a new empty array ##
362
  $data = [];
363
 
364
- // BP loaded ? ##
365
- /*
366
- if (
367
- ! $this->plugin->get( '_bp_data_available' )
368
- && function_exists ( 'bp_is_active' )
369
- && \bp_is_active( 'xprofile' )
370
- && class_exists( 'BP_XProfile_ProfileData' )
371
- && method_exists( 'BP_XProfile_ProfileData', 'get_all_for_user' )
372
- && is_callable ( array( 'BP_XProfile_ProfileData', 'get_all_for_user' ) )
373
- ) {
374
-
375
- // h::log( 'XProfile Accessible' );
376
- $this->plugin->set( '_bp_data_available', true ); // we only need to check for BP once ##
377
-
378
- }
379
- */
380
-
381
- // grab all user data ##
382
- /*
383
- if (
384
- $this->plugin->get( '_bp_data_available' )
385
- && ! $bp_data = \BP_XProfile_ProfileData::get_all_for_user( $user->ID )
386
- ) {
387
-
388
- // null the data to be sure ##
389
- $bp_data = false;
390
-
391
- // h::log( 'XProfile returned no data ID#: '.$user->ID );
392
-
393
- }
394
- */
395
-
396
  // single query method - get all user_meta data ##
397
  $get_user_meta = (array)\get_user_meta( $user->ID );
398
- #h::log( $get_user_meta );
399
 
400
  // loop over each field ##
401
  foreach ( $fields as $field ) {
402
 
403
- /*
404
- // check if this is a BP field ##
405
- if (
406
- isset( $bp_data )
407
- && isset( $bp_data[$field] )
408
- && in_array( $field, $bp_fields_passed )
409
- ){
410
-
411
- // old way from single BP query ##
412
- $value = $bp_data[$field];
413
-
414
- if ( is_array( $value ) ) {
415
-
416
- $value = \maybe_unserialize( $value['field_data'] ); // suggested by @grexican ##
417
- #$value = $value['field_data'];
418
-
419
- if ( is_array( $value ) ) {
420
- $value = implode( "::", $value );
421
- }
422
-
423
- }
424
-
425
- // sanitize ##
426
- #$value = $this->sanitize($value);
427
-
428
- // check if this is a BP field we want the updated date for ##
429
- } elseif ( in_array( $field, $bp_fields_update_passed ) ) {
430
-
431
- global $bp;
432
-
433
- $real_field = str_replace(" Update Date", "", $field);
434
- $field_id = \xprofile_get_field_id_from_name( $real_field );
435
- $value = $wpdb->get_var (
436
- $wpdb->prepare(
437
- "
438
- SELECT last_updated
439
- FROM {$bp->profile->table_name_data}
440
- WHERE user_id = %d AND field_id = %d
441
- "
442
- , $user->ID
443
- , $field_id
444
- )
445
- );
446
-
447
- // include the user's role in the export ##
448
- } else
449
- */
450
-
451
  if ( isset( $_POST['roles'] ) && '1' == $_POST['roles'] && $field == 'roles' ) {
452
 
453
  // empty array ##
@@ -472,56 +325,6 @@ class export {
472
  h::json_encode( $user_roles ) /*implode( '|', $user_roles )*/ :
473
  '';
474
 
475
- // include the user's BP group in the export ##
476
- /*
477
- } elseif ( isset( $_POST['groups'] ) && '1' == $_POST['groups'] && $field == 'groups' ) {
478
-
479
- if ( function_exists( 'groups_get_user_groups' ) ) {
480
-
481
- // check if user is a member of any groups ##
482
- $group_ids = \groups_get_user_groups( $user->ID );
483
-
484
- #h::log( $group_ids );
485
-
486
- if ( ! $group_ids || $group_ids == '' ) {
487
-
488
- $value = '';
489
-
490
- } else {
491
-
492
- // new empty array ##
493
- $groups = [];
494
-
495
- // loop over all groups ##
496
- foreach( $group_ids["groups"] as $group_id ) {
497
-
498
- $groups[] = \groups_get_group( array( 'group_id' => $group_id )) -> name . ( end( $group_ids["groups"] ) == $group_id ? '' : '' );
499
-
500
- }
501
-
502
- // implode it ##
503
- // $value = implode( $groups, '|' );
504
- $value = h::json_encode( $groups );
505
-
506
- }
507
-
508
- } else {
509
-
510
- $value = '';
511
-
512
- }
513
-
514
- */
515
- /*
516
- } elseif (
517
- ( $field == 'bp_latest_update' && function_exists( 'bp_get_user_last_activity' ) )
518
- || $field == 'last_activity'
519
- ){
520
-
521
- // https://bpdevel.wordpress.com/2014/02/21/user-last_activity-data-and-buddypress-2-0/ ##
522
- $value = \bp_get_user_last_activity( $user->ID );
523
- */
524
-
525
  // user or usermeta field ##
526
  } else {
527
 
@@ -555,17 +358,11 @@ class export {
555
  || is_object ( $value )
556
  ){
557
 
558
- // h::log( 'is_array || is_object' );
559
- // h::log( $value );
560
-
561
  // json_encode value to string ##
562
  $value = h::json_encode( $value );
563
 
564
  }
565
 
566
- // sanitize string value ##
567
- // $value = h::sanitize( $value );
568
-
569
  // apply generic filter to value ##
570
  if( has_filter( 'q/eud/export/value' ) ){
571
 
@@ -606,17 +403,21 @@ class export {
606
 
607
  // close doc wrapper..
608
  \esc_html_e( $doc_end );
 
 
 
609
 
610
  } else {
611
 
612
  // xss: all column headers and data values have been escaped previously ##
613
- echo $writer->writeToString();
 
 
 
 
614
 
615
  }
616
 
617
- // stop PHP, so file can export correctly ##
618
- exit;
619
-
620
  }
621
 
622
  /**
@@ -649,31 +450,6 @@ class export {
649
 
650
  }
651
 
652
- // search by last update time of BP extended fields ##
653
- /*
654
- if (
655
- class_exists( 'BP_Xprofile_Field' )
656
- && ( isset ($_POST['updated_since_date'] ) && $_POST['updated_since_date'] != '' )
657
- && (isset ($_POST['bp_field_updated_since'] ) && $_POST['bp_field_updated_since'] != '' )
658
- ) {
659
-
660
- // get last update string ##
661
- $last_updated_date = new \DateTime( \sanitize_text_field ( $_POST['updated_since_date'] ) . ' 00:00:00' );
662
-
663
- // set date ##
664
- $this->plugin->set( '_updated_since_date', $last_updated_date->format( 'Y-m-d H:i:s' ) );
665
-
666
- // set field ##
667
- $this->plugin->set( '_field_updated_since', \sanitize_text_field ( $_POST['bp_field_updated_since'] ) );
668
- $field_updated_since_id = \BP_Xprofile_Field::get_id_from_name( $this->plugin->get( '_field_updated_since' ) );
669
- $user_search->query_from .= " JOIN `wp_bp_xprofile_data` XP ON XP.user_id = wp_users.ID ";
670
-
671
- // set where string ##
672
- $where .= $wpdb->prepare( " AND XP.field_id = %s AND XP.last_updated >= %s", $field_updated_since_id, $this->plugin->get( '_updated_since_date' ) );
673
-
674
- }
675
- */
676
-
677
  if ( ! empty( $where ) ) {
678
 
679
  $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 $where", $user_search->query_where );
34
  ! isset( $_POST['_wpnonce-q-eud-admin-page'] )
35
  ){
36
 
 
 
37
  return;
38
 
39
  }
45
  || isset( $_POST['delete_export'] ) )
46
  {
47
 
 
 
48
  return;
49
 
50
  }
76
  $args['offset'] = $limit_offset;
77
  $args['number'] = $limit_total; // number - Limit the total number of users returned ##
78
 
 
 
 
79
  }
80
 
81
  }
83
  // add custom args via filters ##
84
  $args = \apply_filters( 'q/eud/export/args', $args );
85
 
 
 
86
  // pre_user query ##
87
  \add_action( 'pre_user_query', [ $this, 'pre_user_query' ] );
88
 
92
  // remove pre_user_query again ##
93
  \remove_action( 'pre_user_query', [ $this, 'pre_user_query' ] );
94
 
 
 
 
95
  // no users found, so chuck an error into the args array and exit the export ##
96
  if ( ! $users ) {
97
 
176
 
177
  }
178
 
 
179
  // check for selected usermeta fields ##
180
  $usermeta_fields =
181
  isset( $_POST['usermeta'] ) && is_array( $_POST['usermeta'] ) ?
182
  array_map( 'sanitize_text_field', $_POST['usermeta'] ) :
183
  [];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
184
 
185
  // global wpdb object ##
186
  global $wpdb;
187
 
 
 
 
188
  // compile final fields list ##
189
  $fields = array_merge(
190
  get::user_fields() // standard wp_user fields ##
191
  , get::special_fields() // 'special' fields - which are controlled via dedicated checks ##
192
  , $usermeta_fields // wp_user_meta fields ##
 
 
193
  );
194
 
195
  // test field array ##
208
  // grab fields to exclude from exports - filterable ##
209
  if ( in_array( $fields[$key], get::exclude_fields() ) ) {
210
 
 
 
211
  // ditch 'em ##
212
  unset( $fields[$key] );
213
 
215
 
216
  } else {
217
 
218
+ $headers[] = $field;
 
 
 
 
 
 
 
 
219
 
220
  }
221
 
223
 
224
  // quick check ##
225
  #h::log( $fields );
 
226
 
227
  // no more buffering while spitting back the export data ##
228
  if( ob_get_level() > 0 ) ob_end_flush();
295
  // open up a new empty array ##
296
  $data = [];
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  // single query method - get all user_meta data ##
299
  $get_user_meta = (array)\get_user_meta( $user->ID );
 
300
 
301
  // loop over each field ##
302
  foreach ( $fields as $field ) {
303
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  if ( isset( $_POST['roles'] ) && '1' == $_POST['roles'] && $field == 'roles' ) {
305
 
306
  // empty array ##
325
  h::json_encode( $user_roles ) /*implode( '|', $user_roles )*/ :
326
  '';
327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
  // user or usermeta field ##
329
  } else {
330
 
358
  || is_object ( $value )
359
  ){
360
 
 
 
 
361
  // json_encode value to string ##
362
  $value = h::json_encode( $value );
363
 
364
  }
365
 
 
 
 
366
  // apply generic filter to value ##
367
  if( has_filter( 'q/eud/export/value' ) ){
368
 
403
 
404
  // close doc wrapper..
405
  \esc_html_e( $doc_end );
406
+
407
+ // stop PHP, so file can export correctly ##
408
+ exit;
409
 
410
  } else {
411
 
412
  // xss: all column headers and data values have been escaped previously ##
413
+ // echo $writer->writeToString();
414
+ $writer->writeToStdOut();
415
+
416
+ // stop PHP, so file can export correctly ##
417
+ exit(0);
418
 
419
  }
420
 
 
 
 
421
  }
422
 
423
  /**
450
 
451
  }
452
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
453
  if ( ! empty( $where ) ) {
454
 
455
  $user_search->query_where = str_replace( 'WHERE 1=1', "WHERE 1=1 $where", $user_search->query_where );
library/core/filters.php CHANGED
@@ -24,8 +24,6 @@ class filters {
24
  */
25
  public static function display_key( $string = null ){
26
 
27
- #helper::log( 'string from filter: '.$string );
28
-
29
  if ( is_null( $string ) ) {
30
 
31
  return;
24
  */
25
  public static function display_key( $string = null ){
26
 
 
 
27
  if ( is_null( $string ) ) {
28
 
29
  return;
library/core/get.php CHANGED
@@ -17,28 +17,20 @@ class get {
17
  // standard wp_users fields ##
18
  if ( isset( $_POST['user_fields'] ) && '1' == $_POST['user_fields'] ) {
19
 
20
- // debug ##
21
- #h::log( 'full' );
22
-
23
  // exportable user data ##
24
  $user_fields = array(
25
  'ID'
26
  , 'user_login'
27
- #, 'user_pass'
28
  , 'user_nicename'
29
  , 'user_email'
30
  , 'user_url'
31
  , 'user_registered'
32
- #, 'user_activation_key'
33
  , 'user_status'
34
  , 'display_name'
35
  );
36
 
37
  } else {
38
 
39
- // debug ##
40
- #h::log( 'reduced' );
41
-
42
  // just return the user ID
43
  $user_fields = array(
44
  'ID'
@@ -57,10 +49,7 @@ class get {
57
  public static function special_fields(){
58
 
59
  // exportable user data ##
60
- $special_fields = array(
61
- # 'roles' // list of WP Roles
62
- #, 'groups' // BP Groups
63
- );
64
 
65
  // should we allow groups ##
66
  if ( isset( $_POST['groups'] ) && '1' == $_POST['groups'] ) {
@@ -89,7 +78,6 @@ class get {
89
  $exclude_fields = array (
90
  'user_pass'
91
  , 'q_eud_exports'
92
- #, 'user_activation_key'
93
  );
94
 
95
  // kick back array via filter ##
@@ -113,15 +101,13 @@ class get {
113
  // query user table for oldest and newest registration ##
114
  $range =
115
  $wpdb->get_results (
116
- #$wpdb->prepare (
117
- "
118
- SELECT
119
- MIN( user_registered ) AS first,
120
- MAX( user_registered ) AS last
121
- FROM
122
- {$wpdb->users}
123
- "
124
- #)
125
  );
126
 
127
  return $range;
17
  // standard wp_users fields ##
18
  if ( isset( $_POST['user_fields'] ) && '1' == $_POST['user_fields'] ) {
19
 
 
 
 
20
  // exportable user data ##
21
  $user_fields = array(
22
  'ID'
23
  , 'user_login'
 
24
  , 'user_nicename'
25
  , 'user_email'
26
  , 'user_url'
27
  , 'user_registered'
 
28
  , 'user_status'
29
  , 'display_name'
30
  );
31
 
32
  } else {
33
 
 
 
 
34
  // just return the user ID
35
  $user_fields = array(
36
  'ID'
49
  public static function special_fields(){
50
 
51
  // exportable user data ##
52
+ $special_fields = [];
 
 
 
53
 
54
  // should we allow groups ##
55
  if ( isset( $_POST['groups'] ) && '1' == $_POST['groups'] ) {
78
  $exclude_fields = array (
79
  'user_pass'
80
  , 'q_eud_exports'
 
81
  );
82
 
83
  // kick back array via filter ##
101
  // query user table for oldest and newest registration ##
102
  $range =
103
  $wpdb->get_results (
104
+ "
105
+ SELECT
106
+ MIN( user_registered ) AS first,
107
+ MAX( user_registered ) AS last
108
+ FROM
109
+ {$wpdb->users}
110
+ "
 
 
111
  );
112
 
113
  return $range;
library/core/helper.php CHANGED
@@ -178,13 +178,11 @@ class helper {
178
 
179
  // self::log( $unserialized );
180
 
181
- #$value = 'UNSERIALIZED_'.$unserialized;
182
  $value = $unserialized;
183
 
184
  } else {
185
 
186
  // failed to unserialize - data potentially corrupted in db ##
187
- #$value = 'NOT_SERIALIZED_'.$value;
188
  $value = $value;
189
 
190
  }
@@ -223,27 +221,6 @@ class helper {
223
 
224
  }
225
 
226
- // if value is a JSON_ENCODE'd string, then do not sanitize ##
227
- // if( self::is_json( $value ) ){
228
-
229
- // do we need to apply some escpaping ?? ##
230
-
231
- // return $value;
232
-
233
- // }
234
-
235
- // sanitize ##
236
- // $value = self::sanitize( $value );
237
-
238
- // if no filter is added, apply default sanitiziation ##
239
- // if( ! has_filter( 'q/eud/export/value' ) ){
240
-
241
-
242
-
243
- // }
244
-
245
- // self::log( $value );
246
-
247
  // kick it back via a filter to allow custom formatting ##
248
  return $value;
249
 
@@ -271,8 +248,6 @@ class helper {
271
  // encode and escape ##
272
  $value = json_encode( $value, JSON_FORCE_OBJECT );
273
 
274
- // self::log( $value );
275
-
276
  // kick back JSON encoded string ##
277
  return $value;
278
 
@@ -321,15 +296,13 @@ class helper {
321
  // query user table for oldest and newest registration ##
322
  $range =
323
  $wpdb->get_results (
324
- #$wpdb->prepare (
325
- "
326
- SELECT
327
- MIN( user_registered ) AS first,
328
- MAX( user_registered ) AS last
329
- FROM
330
- {$wpdb->users}
331
- "
332
- #)
333
  );
334
 
335
  return $range;
@@ -344,17 +317,6 @@ class helper {
344
  */
345
  public static function sanitize_value( $value ){
346
 
347
- // if value is a JSON_ENCODE'd string, then do not sanitize ##
348
- // if( self::is_json( $value ) ){
349
-
350
- // // do we need to apply some escpaping ?? ##
351
-
352
- // return $value;
353
-
354
- // }
355
-
356
- // self::log( 'sanitize: '.$value );
357
-
358
  if( has_filter( 'q/eud/export/value' ) ){
359
 
360
  $value = \apply_filters( 'q/eud/export/value', $value );
@@ -366,14 +328,6 @@ class helper {
366
 
367
  }
368
 
369
- // remove line breaks ##
370
- // $value = str_replace("\r", '', $value);
371
- // $value = str_replace("\n", '', $value);
372
- // $value = str_replace("\t", '', $value);
373
-
374
- // with wp_kses ##
375
- // $value = \wp_kses( $value, self::get_allowed_tags() );
376
-
377
  // return value ##
378
  return $value;
379
 
@@ -407,14 +361,10 @@ class helper {
407
 
408
  if ( json_last_error() === JSON_ERROR_NONE ){
409
 
410
- // self::log( 'is_json: '.$string );
411
-
412
  return true;
413
 
414
  }
415
 
416
- // self::log( 'is not json: '.$string );
417
-
418
  return false;
419
 
420
  }
178
 
179
  // self::log( $unserialized );
180
 
 
181
  $value = $unserialized;
182
 
183
  } else {
184
 
185
  // failed to unserialize - data potentially corrupted in db ##
 
186
  $value = $value;
187
 
188
  }
221
 
222
  }
223
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
224
  // kick it back via a filter to allow custom formatting ##
225
  return $value;
226
 
248
  // encode and escape ##
249
  $value = json_encode( $value, JSON_FORCE_OBJECT );
250
 
 
 
251
  // kick back JSON encoded string ##
252
  return $value;
253
 
296
  // query user table for oldest and newest registration ##
297
  $range =
298
  $wpdb->get_results (
299
+ "
300
+ SELECT
301
+ MIN( user_registered ) AS first,
302
+ MAX( user_registered ) AS last
303
+ FROM
304
+ {$wpdb->users}
305
+ "
 
 
306
  );
307
 
308
  return $range;
317
  */
318
  public static function sanitize_value( $value ){
319
 
 
 
 
 
 
 
 
 
 
 
 
320
  if( has_filter( 'q/eud/export/value' ) ){
321
 
322
  $value = \apply_filters( 'q/eud/export/value', $value );
328
 
329
  }
330
 
 
 
 
 
 
 
 
 
331
  // return value ##
332
  return $value;
333
 
361
 
362
  if ( json_last_error() === JSON_ERROR_NONE ){
363
 
 
 
364
  return true;
365
 
366
  }
367
 
 
 
368
  return false;
369
 
370
  }
library/core/user.php CHANGED
@@ -38,14 +38,8 @@ class user {
38
  // add to user meta, as they do not have any stored values ##
39
  \add_user_meta( \get_current_user_id(), 'q_eud_exports', $old_data );
40
 
41
- // delete old data ---? perhaps better to leave it, even if it redundant?
42
- // \delete_user_meta( \get_current_user_id(), 'q_eud_exports' );
43
-
44
  }
45
 
46
- // test #
47
- // h::log( \get_user_meta( \get_current_user_id(), 'q_eud_exports', true ) );
48
-
49
  // get array ##
50
  $array =
51
  \get_user_meta( \get_current_user_id(), 'q_eud_exports' ) ?
@@ -82,9 +76,6 @@ class user {
82
 
83
  }
84
 
85
- // test the array of saved exports ##
86
- #h::log( $_q_eud_exports );
87
-
88
  // start with an empty array ##
89
  $exports = [];
90
 
@@ -123,10 +114,7 @@ class user {
123
  if ( isset( $_q_eud_exports[$export] ) ) {
124
 
125
  $_usermeta_saved_fields = $_q_eud_exports[$export]['usermeta_saved_fields'];
126
- // $_bp_fields_saved_fields = $_q_eud_exports[$export]['bp_fields_saved_fields'];
127
- // $_bp_fields_update_time_saved_fields = $_q_eud_exports[$export]['bp_fields_update_time_saved_fields'];
128
  $_updated_since_date = $_q_eud_exports[$export]['updated_since_date'] ?? null ;
129
- $_field_updated_since = $_q_eud_exports[$export]['field_updated_since'] ?? null ;
130
  $_role = $_q_eud_exports[$export]['role'];
131
  $_roles = $_q_eud_exports[$export]['roles'];
132
  $_groups = $_q_eud_exports[$export]['groups'];
@@ -140,10 +128,7 @@ class user {
140
  } else {
141
 
142
  $_usermeta_saved_fields = [];
143
- // $_bp_fields_saved_fields = [];
144
- // $_bp_fields_update_time_saved_fields = [];
145
  $_updated_since_date = '';
146
- $_field_updated_since = '';
147
  $_role = '';
148
  $_user_fields = '1';
149
  $_roles = '1';
@@ -158,10 +143,7 @@ class user {
158
 
159
  // set props ##
160
  $this->plugin->set( '_usermeta_saved_fields', $_usermeta_saved_fields );
161
- // $this->plugin->set( '_bp_fields_saved_fields', $_bp_fields_saved_fields );
162
- // $this->plugin->set( '_bp_fields_update_time_saved_fields', $_bp_fields_update_time_saved_fields );
163
  $this->plugin->set( '_updated_since_date', $_updated_since_date );
164
- $this->plugin->set( '_field_updated_since', $_field_updated_since );
165
  $this->plugin->set( '_role', $_role );
166
  $this->plugin->set( '_user_fields', $_user_fields );
167
  $this->plugin->set( '_roles', $_roles );
@@ -193,20 +175,9 @@ class user {
193
 
194
  }
195
 
196
- // h::log( $key );
197
- // h::log( $options );
198
-
199
  // get prop ##
200
  $_q_eud_exports = $this->plugin->get( '_q_eud_exports' );
201
 
202
- // for now, I'm simply allowing keys to be resaved - but this is not so logical ##
203
- // if ( array_key_exists( $key, $_q_eud_exports ) ) {
204
-
205
- #h::log( 'key exists, skipping save' );
206
- #return false;
207
-
208
- // }
209
-
210
  if ( isset( $options ) && is_array( $options ) ) {
211
 
212
  // update_option sanitizes the option name but not the option value ##
@@ -270,9 +241,6 @@ class user {
270
  // clean it up ##
271
  $key = \sanitize_text_field( $key );
272
 
273
- // check it out ##
274
- #h::log( $key );
275
-
276
  // drop the array by it's key name from the class property ##
277
  unset( $_q_eud_exports[$key] );
278
 
38
  // add to user meta, as they do not have any stored values ##
39
  \add_user_meta( \get_current_user_id(), 'q_eud_exports', $old_data );
40
 
 
 
 
41
  }
42
 
 
 
 
43
  // get array ##
44
  $array =
45
  \get_user_meta( \get_current_user_id(), 'q_eud_exports' ) ?
76
 
77
  }
78
 
 
 
 
79
  // start with an empty array ##
80
  $exports = [];
81
 
114
  if ( isset( $_q_eud_exports[$export] ) ) {
115
 
116
  $_usermeta_saved_fields = $_q_eud_exports[$export]['usermeta_saved_fields'];
 
 
117
  $_updated_since_date = $_q_eud_exports[$export]['updated_since_date'] ?? null ;
 
118
  $_role = $_q_eud_exports[$export]['role'];
119
  $_roles = $_q_eud_exports[$export]['roles'];
120
  $_groups = $_q_eud_exports[$export]['groups'];
128
  } else {
129
 
130
  $_usermeta_saved_fields = [];
 
 
131
  $_updated_since_date = '';
 
132
  $_role = '';
133
  $_user_fields = '1';
134
  $_roles = '1';
143
 
144
  // set props ##
145
  $this->plugin->set( '_usermeta_saved_fields', $_usermeta_saved_fields );
 
 
146
  $this->plugin->set( '_updated_since_date', $_updated_since_date );
 
147
  $this->plugin->set( '_role', $_role );
148
  $this->plugin->set( '_user_fields', $_user_fields );
149
  $this->plugin->set( '_roles', $_roles );
175
 
176
  }
177
 
 
 
 
178
  // get prop ##
179
  $_q_eud_exports = $this->plugin->get( '_q_eud_exports' );
180
 
 
 
 
 
 
 
 
 
181
  if ( isset( $options ) && is_array( $options ) ) {
182
 
183
  // update_option sanitizes the option name but not the option value ##
241
  // clean it up ##
242
  $key = \sanitize_text_field( $key );
243
 
 
 
 
244
  // drop the array by it's key name from the class property ##
245
  unset( $_q_eud_exports[$key] );
246
 
plugin.php CHANGED
@@ -27,7 +27,7 @@ final class plugin {
27
  public static
28
 
29
  // current tag ##
30
- $_version = '2.2.5',
31
 
32
  // debugging control ##
33
  $_debug = \WP_DEBUG
@@ -43,8 +43,6 @@ final class plugin {
43
 
44
  $_q_eud_exports = '', // export settings ##
45
  $_usermeta_saved_fields = [],
46
- // $_bp_fields_saved_fields = [],
47
- // $_bp_fields_update_time_saved_fields = [],
48
  $_role = '',
49
  $_roles = '0',
50
  $_user_fields = '1',
@@ -54,9 +52,7 @@ final class plugin {
54
  $_limit_offset = '',
55
  $_limit_total = '',
56
  $_updated_since_date = '',
57
- $_field_updated_since = '',
58
  $_format = '',
59
- // $_bp_data_available = false,
60
  $_allowed_tags = '',
61
 
62
  // api ##
@@ -154,8 +150,6 @@ final class plugin {
154
 
155
  }
156
 
157
- // w__log( 'prop->set: '.$key.' -> '.$value );
158
-
159
  // set new value ##
160
  return $this->{$key} = $value;
161
 
@@ -219,8 +213,6 @@ final class plugin {
219
  */
220
  public static function deactivation_hook(){
221
 
222
- // Log::write( 'Plugin De-activated..' );
223
-
224
  // check user caps ##
225
  if ( ! \current_user_can( 'activate_plugins' ) ) {
226
 
@@ -234,9 +226,6 @@ final class plugin {
234
  // de-configure plugin ##
235
  \delete_option('plugin_export_user_data');
236
 
237
- // clear rewrite rules ##
238
- // \flush_rewrite_rules();
239
-
240
  }
241
 
242
  /**
@@ -255,11 +244,6 @@ final class plugin {
255
  true :
256
  $this->_debug;
257
 
258
- // test ##
259
- // w__log( 'Q exists: '.json_encode( class_exists( 'Q' ) ) );
260
- // w__log( 'Q debug: '.json_encode( \Q::$debug ) );
261
- // w__log( json_encode( self::$debug ) );
262
-
263
  return $this->_debug;
264
 
265
  }
27
  public static
28
 
29
  // current tag ##
30
+ $_version = '2.2.6',
31
 
32
  // debugging control ##
33
  $_debug = \WP_DEBUG
43
 
44
  $_q_eud_exports = '', // export settings ##
45
  $_usermeta_saved_fields = [],
 
 
46
  $_role = '',
47
  $_roles = '0',
48
  $_user_fields = '1',
52
  $_limit_offset = '',
53
  $_limit_total = '',
54
  $_updated_since_date = '',
 
55
  $_format = '',
 
56
  $_allowed_tags = '',
57
 
58
  // api ##
150
 
151
  }
152
 
 
 
153
  // set new value ##
154
  return $this->{$key} = $value;
155
 
213
  */
214
  public static function deactivation_hook(){
215
 
 
 
216
  // check user caps ##
217
  if ( ! \current_user_can( 'activate_plugins' ) ) {
218
 
226
  // de-configure plugin ##
227
  \delete_option('plugin_export_user_data');
228
 
 
 
 
229
  }
230
 
231
  /**
244
  true :
245
  $this->_debug;
246
 
 
 
 
 
 
247
  return $this->_debug;
248
 
249
  }
readme.md CHANGED
@@ -5,7 +5,7 @@
5
  **Requires PHP:** 6.0
6
  **Requires at least:** 5.0
7
  **Tested up to:** 5.8.2
8
- **Stable tag:** 2.2.5
9
  **License:** GPLv2
10
 
11
  Export users data and metadata to a csv or Excel file
5
  **Requires PHP:** 6.0
6
  **Requires at least:** 5.0
7
  **Tested up to:** 5.8.2
8
+ **Stable tag:** 2.2.6
9
  **License:** GPLv2
10
 
11
  Export users data and metadata to a csv or Excel file
readme.txt CHANGED
@@ -4,7 +4,7 @@ Tags: users, export, usermeta, excel
4
  Requires PHP: 7.0
5
  Requires at least: 4.8
6
  Tested up to: 5.8.2
7
- Stable tag: 2.2.5
8
  License: GPLv2
9
 
10
  Export users data and metadata to a csv or Excel file
4
  Requires PHP: 7.0
5
  Requires at least: 4.8
6
  Tested up to: 5.8.2
7
+ Stable tag: 2.2.6
8
  License: GPLv2
9
 
10
  Export users data and metadata to a csv or Excel file