diff --git a/wp-admin/includes/file.php b/wp-admin/includes/file.php
index 200f581da8..b090ed717f 100644
--- a/wp-admin/includes/file.php
+++ b/wp-admin/includes/file.php
@@ -1976,9 +1976,15 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
$group_html .= '
';
foreach ( (array) $group_item_data as $group_item_datum ) {
+ $value = $group_item_datum['value'];
+ // If it looks like a link, make it a link
+ if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
+ $value = '' . esc_html( $value ) . '';
+ }
+
$group_html .= '';
$group_html .= '' . esc_html( $group_item_datum['name'] ) . ' | ';
- $group_html .= '' . wp_kses( $group_item_datum['value'], $allowed_tags, $allowed_protocols ) . ' | ';
+ $group_html .= '' . wp_kses( $value, $allowed_tags, $allowed_protocols ) . ' | ';
$group_html .= '
';
}
diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index a3c68eed86..797353b961 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -351,6 +351,7 @@ add_action( 'welcome_panel', 'wp_welcome_panel' );
add_action( 'user_request_action_confirmed', '_wp_privacy_account_request_confirmed' );
add_filter( 'user_request_action_confirmed_message', '_wp_privacy_account_request_confirmed_message', 10, 2 );
add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_comment_personal_data_exporter' );
+add_filter( 'wp_privacy_personal_data_exporters', 'wp_register_media_personal_data_exporter' );
add_filter( 'wp_privacy_personal_data_erasers', 'wp_register_comment_personal_data_eraser' );
add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
diff --git a/wp-includes/media.php b/wp-includes/media.php
index a52048f475..87321fe945 100644
--- a/wp-includes/media.php
+++ b/wp-includes/media.php
@@ -4093,3 +4093,79 @@ function wpview_media_sandbox_styles() {
return array( $mediaelement, $wpmediaelement );
}
+
+/**
+ * Registers the personal data exporter for media
+ *
+ * @param array $exporters An array of personal data exporters.
+ * @return array An array of personal data exporters.
+ */
+function wp_register_media_personal_data_exporter( $exporters ) {
+ $exporters[] = array(
+ 'exporter_friendly_name' => __( 'WordPress Media' ),
+ 'callback' => 'wp_media_personal_data_exporter',
+ );
+
+ return $exporters;
+}
+
+/**
+ * Finds and exports attachments associated with an email address.
+ *
+ * @since 4.9.6
+ *
+ * @param string $email_address The attachment owner email address.
+ * @param int $page Attachment page.
+ * @return array $return An array of personal data.
+ */
+function wp_media_personal_data_exporter( $email_address, $page = 1 ) {
+ // Limit us to 50 attachments at a time to avoid timing out.
+ $number = 50;
+ $page = (int) $page;
+
+ $data_to_export = array();
+
+ $user = get_user_by( 'email' , $email_address );
+ if ( false === $user ) {
+ return array(
+ 'data' => $data_to_export,
+ 'done' => true,
+ );
+ }
+
+ $post_query = new WP_Query(
+ array(
+ 'author' => $user->ID,
+ 'posts_per_page' => $number,
+ 'paged' => $page,
+ 'post_type' => 'attachment',
+ 'post_status' => 'any',
+ 'orderby' => 'ID',
+ 'order' => 'ASC',
+ )
+ );
+
+ foreach ( (array) $post_query->posts as $post ) {
+ $attachment_url = wp_get_attachment_url( $post->ID );
+
+ if ( $attachment_url ) {
+ $post_data_to_export = array(
+ array( 'name' => __( 'URL' ), 'value' => $attachment_url ),
+ );
+
+ $data_to_export[] = array(
+ 'group_id' => 'media',
+ 'group_label' => __( 'Media' ),
+ 'item_id' => "post-{$post->ID}",
+ 'data' => $post_data_to_export,
+ );
+ }
+ }
+
+ $done = $post_query->max_num_pages <= $page;
+
+ return array(
+ 'data' => $data_to_export,
+ 'done' => $done,
+ );
+}
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 57d41393c8..8c93abd62a 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
-$wp_version = '5.0-alpha-43053';
+$wp_version = '5.0-alpha-43054';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.