Export User Data - Version 1.2.0

Version Description

  • Data stored in recursive and serialized arrays is now exported in a flat string format with safe delimiters ( ||, ||| - etc. )
Download this release

Release Info

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

Code changes from version 1.1.1 to 1.2.0

Files changed (3) hide show
  1. export-user-data.php +119 -45
  2. readme.md +14 -1
  3. readme.txt +10 -3
export-user-data.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Export User Data
5
  Plugin URI: http://qstudio.us/plugins/
6
  Description: Export User data, metadata and BuddyPress X-Profile data.
7
- Version: 1.1.1
8
  Author: Q Studio
9
  Author URI: http://qstudio.us
10
  License: GPL2
@@ -23,7 +23,7 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
23
  {
24
 
25
  // plugin version
26
- define( 'Q_EXPORT_USER_DATA_VERSION', '1.1.1' ); // version ##
27
 
28
  // instatiate class via hook, only if inside admin
29
  if ( is_admin() ) {
@@ -462,6 +462,17 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
462
  public function generate_data()
463
  {
464
 
 
 
 
 
 
 
 
 
 
 
 
465
  // Check if the user clicked on the Save, Load, or Delete Settings buttons ##
466
  if (
467
  ! isset( $_POST['_wpnonce-q-eud-export-user-page_export'] )
@@ -753,9 +764,9 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
753
  #wp_die( $this->pr( $get_user_meta ) );
754
 
755
  // Filter out empty meta data ##
756
- $get_user_meta = array_filter( array_map( function( $a ) {
757
- return $a[0];
758
- }, $get_user_meta ) );
759
 
760
  // loop over each field ##
761
  foreach ( $fields as $field ) {
@@ -870,8 +881,8 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
870
  // the user_meta key isset ##
871
  if ( isset( $get_user_meta[$field] ) ) {
872
 
873
- // take from the bulk get_user_meta call ##
874
- $value = $get_user_meta[$field];
875
 
876
  // standard WP_User value ##
877
  } else {
@@ -882,27 +893,9 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
882
  }
883
 
884
 
885
- // the $value is serialized ##
886
- if ( is_serialized( $value ) ) {
887
-
888
- // unserliaze to new variable ##
889
- $unserialized = @unserialize( $value );
890
-
891
- // test if unserliazing produced errors ##
892
- if ( $unserialized !== false || $value == 'b:0;' ) {
893
-
894
- #$value = 'UNSERIALIZED_'.$value;
895
- $value = $unserialized;
896
-
897
- } else {
898
-
899
- // failed to unserialize - data potentially corrupted in db ##
900
- $value = $value;
901
-
902
- }
903
-
904
- }
905
-
906
  // the value is an array ##
907
  if ( is_array ( $value ) ) {
908
 
@@ -1860,32 +1853,113 @@ if ( ! class_exists( 'Q_Export_User_Data' ) )
1860
  * @param bool $include_keys include keys before their values
1861
  * @param bool $trim_all trim ALL whitespace from string
1862
  * @return string imploded array
1863
- * @link https://gist.github.com/jimmygle/2564610
1864
  */
1865
- public static function recursive_implode( array $array, $glue = '|', $include_keys = true, $trim_all = true )
1866
  {
1867
 
1868
- $glued_string = '';
1869
- $glue_count = 0;
1870
-
1871
- // Recursively iterates array and adds key/value to glued string ##
1872
- array_walk_recursive( $array, function( $value, $key ) use ( $glue, $include_keys, &$glued_string, $glue_count )
1873
- {
1874
- $include_keys and $glued_string .= $key.$glue;
1875
- $glued_string .= $value.$glue; //.'GC_'.$glue_count.$glue;
1876
- $glue_count ++;
1877
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1878
 
1879
- // Removes last $glue from string ##
1880
- strlen( $glue) > 0 and $glued_string = substr( $glued_string, 0, -strlen( $glue ) );
1881
 
 
 
 
 
1882
  // Trim ALL whitespace ##
1883
- $trim_all and $glued_string = preg_replace( "/(\s)/ixsm", '', $glued_string );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1884
 
1885
- return (string) $glued_string;
 
 
 
 
 
1886
 
1887
  }
1888
-
1889
 
1890
  /**
1891
  * Nicer var_dump
4
  Plugin Name: Export User Data
5
  Plugin URI: http://qstudio.us/plugins/
6
  Description: Export User data, metadata and BuddyPress X-Profile data.
7
+ Version: 1.2.0
8
  Author: Q Studio
9
  Author URI: http://qstudio.us
10
  License: GPL2
23
  {
24
 
25
  // plugin version
26
+ define( 'Q_EXPORT_USER_DATA_VERSION', '1.2.0' ); // version ##
27
 
28
  // instatiate class via hook, only if inside admin
29
  if ( is_admin() ) {
462
  public function generate_data()
463
  {
464
 
465
+ #self::pr( 'a:5:{i:0;s:7:"acf_676";i:1;s:15:"wordpress-https";i:2;s:16:"gp-theme-options";i:3;s:10:"postcustom";i:4;s:16:"commentstatusdiv";}' );
466
+ #echo self::recursive_implode( 'a:5:{i:0;s:7:"acf_676";i:1;s:15:"wordpress-https";i:2;s:16:"gp-theme-options";i:3;s:10:"postcustom";i:4;s:16:"commentstatusdiv";}' );
467
+
468
+ #self::pr( '58' );
469
+ #echo self::recursive_implode( '58' );
470
+
471
+ #self::pr( 'a:2:{i:0;s:3:"sub";i:1;a:1:{i:0;s:7:"acf_676";}}' );
472
+ #echo self::recursive_implode( 'a:2:{i:0;s:3:"sub";i:1;a:1:{i:0;s:7:"acf_676";}}' );
473
+
474
+ #wp_die();
475
+
476
  // Check if the user clicked on the Save, Load, or Delete Settings buttons ##
477
  if (
478
  ! isset( $_POST['_wpnonce-q-eud-export-user-page_export'] )
764
  #wp_die( $this->pr( $get_user_meta ) );
765
 
766
  // Filter out empty meta data ##
767
+ #$get_user_meta = array_filter( array_map( function( $a ) {
768
+ # return $a[0];
769
+ #}, $get_user_meta ) );
770
 
771
  // loop over each field ##
772
  foreach ( $fields as $field ) {
881
  // the user_meta key isset ##
882
  if ( isset( $get_user_meta[$field] ) ) {
883
 
884
+ // take from the bulk get_user_meta call - this returns an array in all cases, so we take the first key ##
885
+ $value = $get_user_meta[$field][0];
886
 
887
  // standard WP_User value ##
888
  } else {
893
  }
894
 
895
 
896
+ // the $value might be serialized ##
897
+ $value = self::unserialize( $value );
898
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
899
  // the value is an array ##
900
  if ( is_array ( $value ) ) {
901
 
1853
  * @param bool $include_keys include keys before their values
1854
  * @param bool $trim_all trim ALL whitespace from string
1855
  * @return string imploded array
 
1856
  */
1857
+ public static function recursive_implode( $array, $return = null, $glue = '|' )
1858
  {
1859
 
1860
+ // unserialize ##
1861
+ $array = self::unserialize( $array );
1862
+
1863
+ // kick it back ##
1864
+ if ( is_null ( $return ) && ! is_array( $array ) ) {
1865
+
1866
+ return $array;
1867
+
1868
+ }
1869
+
1870
+ // empty return ##
1871
+ if ( is_null ( $return ) ) {
1872
+
1873
+ $return = '';
1874
+
1875
+ } else {
1876
+
1877
+ if ( "||" == $glue ) {
1878
+
1879
+ $glue = '|||';
1880
+
1881
+ } else if ( "|" == $glue ) {
1882
+
1883
+ $glue = '||';
1884
+
1885
+ }
1886
+
1887
+ }
1888
+
1889
+ // loop ##
1890
+ foreach( $array as $key => $value ) {
1891
+
1892
+ // unserialize ##
1893
+ $value = self::unserialize( $value );
1894
+
1895
+ if( is_array( $value ) ) {
1896
+
1897
+ $return .= $glue . $key . $glue . self::recursive_implode( $value, $return, $glue );
1898
+
1899
+ } else {
1900
+
1901
+ $return .= $glue . $key . $glue . $value;
1902
+
1903
+ }
1904
+
1905
+ }
1906
 
1907
+ // Removes first $glue from string ##
1908
+ if ( $glue && $return && $return[0] == '|' ) {
1909
 
1910
+ $return = ltrim ( $return, '|' );
1911
+
1912
+ }
1913
+
1914
  // Trim ALL whitespace ##
1915
+ if ( $return ) {
1916
+
1917
+ $return = preg_replace( "/(\s)/ixsm", '', $return );
1918
+
1919
+ }
1920
+
1921
+ // kick it back ##
1922
+ return $return;
1923
+
1924
+ }
1925
+
1926
+
1927
+
1928
+ /**
1929
+ * Save Unserializer
1930
+ *
1931
+ * @since 1.1.4
1932
+ */
1933
+ public function unserialize( $value )
1934
+ {
1935
+
1936
+ // the $value is serialized ##
1937
+ if ( is_serialized( $value ) ) {
1938
+
1939
+ // unserliaze to new variable ##
1940
+ $unserialized = @unserialize( $value );
1941
+
1942
+ // test if unserliazing produced errors ##
1943
+ if ( $unserialized !== false || $value == 'b:0;' ) {
1944
+
1945
+ #$value = 'UNSERIALIZED_'.$unserialized;
1946
+ $value = $unserialized;
1947
+
1948
+ } else {
1949
+
1950
+ // failed to unserialize - data potentially corrupted in db ##
1951
+ #$value = 'NOT_SERIALIZED_'.$value;
1952
+ $value = $value;
1953
 
1954
+ }
1955
+
1956
+ }
1957
+
1958
+ // kick it back ##
1959
+ return $value;
1960
 
1961
  }
1962
+
1963
 
1964
  /**
1965
  * Nicer var_dump
readme.md CHANGED
@@ -3,7 +3,7 @@
3
  **Tags:** user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  **Requires at least:** 3.2
5
  **Tested up to:** 4.1.0
6
- **Stable tag:** 1.0.3
7
  **License:** GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
@@ -59,6 +59,19 @@ Click on the 'Export User Data' link in the 'Users' menu, choose the role and th
59
 
60
  ## Changelog ##
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  ### 1.0.3 ###
63
  * Tested as working on WordPress 4.1.0.
64
 
3
  **Tags:** user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  **Requires at least:** 3.2
5
  **Tested up to:** 4.1.0
6
+ **Stable tag:** 1.2.0
7
  **License:** GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
59
 
60
  ## Changelog ##
61
 
62
+ ### 1.2.0 ###
63
+ * Data stored in recursive and serialized arrays is now exported in a flat string format with safe delimiters ( ||, ||| - etc. )
64
+
65
+ ### 1.1.1 ###
66
+ * Removed accidently included .git files
67
+
68
+ ### 1.1.0 ###
69
+ * Version change to sync SVN on wordpress.org
70
+
71
+ ### 1.0.4 ###
72
+ * Added unserialize function with @ fallback
73
+ * Removed anonymous function to allow support for PHP < 5.2
74
+
75
  ### 1.0.3 ###
76
  * Tested as working on WordPress 4.1.0.
77
 
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: qlstudio
3
  Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  Requires at least: 3.2
5
  Tested up to: 4.1.0
6
- Stable tag: 1.1.1
7
  License: GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
@@ -58,12 +58,19 @@ Click on the 'Export User Data' link in the 'Users' menu, choose the role and th
58
 
59
  == Changelog ==
60
 
61
- = 1.1.1 =
 
 
 
62
  * Removed accidently included .git files
63
 
64
- = 1.1.0 =
65
  * Version change to sync SVN on wordpress.org
66
 
 
 
 
 
67
  = 1.0.3 =
68
  * Tested as working on WordPress 4.1.0.
69
 
3
  Tags: user, users, xprofile, usermeta csv, excel, batch, export, save, download
4
  Requires at least: 3.2
5
  Tested up to: 4.1.0
6
+ Stable tag: 1.2.0
7
  License: GPLv2
8
 
9
  Export users data, metadata and buddypress xprofile data to a csv or Excel file
58
 
59
  == Changelog ==
60
 
61
+ = 1.2.0 =
62
+ * Data stored in recursive and serialized arrays is now exported in a flat string format with safe delimiters ( ||, ||| - etc. )
63
+
64
+ = 1.1.1 =
65
  * Removed accidently included .git files
66
 
67
+ = 1.1.0 =
68
  * Version change to sync SVN on wordpress.org
69
 
70
+ = 1.0.4 =
71
+ * Added unserialize function with @ fallback
72
+ * Removed anonymous function to allow support for PHP < 5.2
73
+
74
  = 1.0.3 =
75
  * Tested as working on WordPress 4.1.0.
76