From 346f505a75b335baed9be4f38d72db14e3ff8570 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 10 Feb 2020 05:32:06 +0000 Subject: [PATCH] Privacy: Include `community-events-location` user meta value in Personal Data Export. The value is used by the WordPress Events and News widget to show relevant WP community events. The location information may include an IP address, location description, and latitude/longitude coordinates. Props garrett-eclipse, coreymckrill, xkon. Fixes #43921. Built from https://develop.svn.wordpress.org/trunk@47236 git-svn-id: http://core.svn.wordpress.org/trunk@47036 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/user.php | 40 ++++++++++++++++++++++++++++++++++++++-- wp-includes/version.php | 2 +- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/wp-includes/user.php b/wp-includes/user.php index 3d6e63630b..ac0f6a62e0 100644 --- a/wp-includes/user.php +++ b/wp-includes/user.php @@ -2959,7 +2959,7 @@ function wp_user_personal_data_exporter( $email_address ) { $user_meta = get_user_meta( $user->ID ); - $user_prop_to_export = array( + $user_props_to_export = array( 'ID' => __( 'User ID' ), 'user_login' => __( 'User Login Name' ), 'user_nicename' => __( 'User Nice Name' ), @@ -2975,7 +2975,7 @@ function wp_user_personal_data_exporter( $email_address ) { $user_data_to_export = array(); - foreach ( $user_prop_to_export as $key => $name ) { + foreach ( $user_props_to_export as $key => $name ) { $value = ''; switch ( $key ) { @@ -3012,6 +3012,42 @@ function wp_user_personal_data_exporter( $email_address ) { 'data' => $user_data_to_export, ); + /** + * Introduce any Community Events Location data that is available. + * + * @since 5.4.0 + */ + if ( isset( $user_meta['community-events-location'] ) ) { + $location = maybe_unserialize( $user_meta['community-events-location'][0] ); + + $location_props_to_export = array( + 'description' => __( 'City' ), + 'country' => __( 'Country' ), + 'latitude' => __( 'Latitude' ), + 'longitude' => __( 'Longitude' ), + 'ip' => __( 'IP' ), + ); + + $location_data_to_export = array(); + + foreach ( $location_props_to_export as $key => $name ) { + if ( ! empty( $location[ $key ] ) ) { + $location_data_to_export[] = array( + 'name' => $name, + 'value' => $location[ $key ], + ); + } + } + + $data_to_export[] = array( + 'group_id' => 'community-events-location', + 'group_label' => __( 'Community Events Location' ), + 'group_description' => __( 'User’s location data used for the Community Events in the WordPress Events and News dashboard widget.' ), + 'item_id' => "community-events-location-{$user->ID}", + 'data' => $location_data_to_export, + ); + } + return array( 'data' => $data_to_export, 'done' => true, diff --git a/wp-includes/version.php b/wp-includes/version.php index 9282d12581..727fac2fbf 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-alpha-47235'; +$wp_version = '5.4-alpha-47236'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.