From 95c36ce5ba83585efccc4005a0c1dd5b823de799 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 18 Aug 2019 02:07:00 +0000 Subject: [PATCH] Privacy: Add descriptions for sections in a personal data export file. Props garrett-eclipse, Venutius, karmatosed. Fixes #45491. git-svn-id: https://develop.svn.wordpress.org/trunk@45825 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/privacy-tools.php | 24 +++++++++++++++---- src/wp-includes/comment.php | 9 +++---- src/wp-includes/media.php | 9 +++---- src/wp-includes/user.php | 9 +++---- ...wpPrivacyProcessPersonalDataExportPage.php | 9 +++---- 5 files changed, 39 insertions(+), 21 deletions(-) diff --git a/src/wp-admin/includes/privacy-tools.php b/src/wp-admin/includes/privacy-tools.php index e3a942a6d2..a8a115bab0 100644 --- a/src/wp-admin/includes/privacy-tools.php +++ b/src/wp-admin/includes/privacy-tools.php @@ -234,7 +234,12 @@ function _wp_personal_data_cleanup_requests() { * @return string The HTML for this group and its items. */ function wp_privacy_generate_personal_data_export_group_html( $group_data ) { - $group_html = '

' . esc_html( $group_data['group_label'] ) . '

'; + $group_html = '

' . esc_html( $group_data['group_label'] ) . '

'; + + if ( ! empty( $group_data['group_description'] ) ) { + $group_html .= '

' . esc_html( $group_data['group_description'] ) . '

'; + } + $group_html .= '
'; foreach ( (array) $group_data['items'] as $group_item_id => $group_item_data ) { @@ -355,8 +360,10 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) { // First, build an "About" group on the fly for this report. $about_group = array( /* translators: Header for the About section in a personal data export. */ - 'group_label' => _x( 'About', 'personal data group label' ), - 'items' => array( + 'group_label' => _x( 'About', 'personal data group label' ), + /* translators: Description for the About section in a personal data export. */ + 'group_description' => _x( 'Overview of export report.', 'personal data group description' ), + 'items' => array( 'about-1' => array( array( 'name' => _x( 'Report generated for', 'email address' ), @@ -613,10 +620,17 @@ function wp_privacy_process_personal_data_export_page( $response, $exporter_inde foreach ( (array) $export_data as $export_datum ) { $group_id = $export_datum['group_id']; $group_label = $export_datum['group_label']; + + $group_description = ''; + if ( ! empty( $export_datum['group_description'] ) ) { + $group_description = $export_datum['group_description']; + } + if ( ! array_key_exists( $group_id, $groups ) ) { $groups[ $group_id ] = array( - 'group_label' => $group_label, - 'items' => array(), + 'group_label' => $group_label, + 'group_description' => $group_description, + 'items' => array(), ); } diff --git a/src/wp-includes/comment.php b/src/wp-includes/comment.php index 1ae94451d8..841bb9b141 100644 --- a/src/wp-includes/comment.php +++ b/src/wp-includes/comment.php @@ -3434,10 +3434,11 @@ function wp_comments_personal_data_exporter( $email_address, $page = 1 ) { } $data_to_export[] = array( - 'group_id' => 'comments', - 'group_label' => __( 'Comments' ), - 'item_id' => "comment-{$comment->comment_ID}", - 'data' => $comment_data_to_export, + 'group_id' => 'comments', + 'group_label' => __( 'Comments' ), + 'group_description' => __( 'User’s comment data.' ), + 'item_id' => "comment-{$comment->comment_ID}", + 'data' => $comment_data_to_export, ); } diff --git a/src/wp-includes/media.php b/src/wp-includes/media.php index c5404d5383..27b1eb8f6e 100644 --- a/src/wp-includes/media.php +++ b/src/wp-includes/media.php @@ -4307,10 +4307,11 @@ function wp_media_personal_data_exporter( $email_address, $page = 1 ) { ); $data_to_export[] = array( - 'group_id' => 'media', - 'group_label' => __( 'Media' ), - 'item_id' => "post-{$post->ID}", - 'data' => $post_data_to_export, + 'group_id' => 'media', + 'group_label' => __( 'Media' ), + 'group_description' => __( 'User’s media data.' ), + 'item_id' => "post-{$post->ID}", + 'data' => $post_data_to_export, ); } } diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index a97f0fada8..9c8d789768 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -2994,10 +2994,11 @@ function wp_user_personal_data_exporter( $email_address ) { } $data_to_export[] = array( - 'group_id' => 'user', - 'group_label' => __( 'User' ), - 'item_id' => "user-{$user->ID}", - 'data' => $user_data_to_export, + 'group_id' => 'user', + 'group_label' => __( 'User' ), + 'group_description' => __( 'User’s profile data.' ), + 'item_id' => "user-{$user->ID}", + 'data' => $user_data_to_export, ); return array( diff --git a/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php b/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php index c7d62990df..baf0db89cc 100755 --- a/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php +++ b/tests/phpunit/tests/privacy/wpPrivacyProcessPersonalDataExportPage.php @@ -142,10 +142,11 @@ class Tests_Privacy_WpPrivacyProcessPersonalDataExportPage extends WP_UnitTestCa $data = array( array( - 'group_id' => 'custom-exporter-group-id', - 'group_label' => 'custom-exporter-group-label', - 'item_id' => 'custom-exporter-item-id', - 'data' => array( + 'group_id' => 'custom-exporter-group-id', + 'group_label' => 'Custom Exporter Group Label', + 'group_description' => 'Custom Exporter Group Description', + 'item_id' => 'custom-exporter-item-id', + 'data' => array( array( 'name' => 'Email', 'value' => self::$requester_email,