Privacy: add attachments to the personal data export file.
Props allendav. See #43883. Built from https://develop.svn.wordpress.org/trunk@43054 git-svn-id: http://core.svn.wordpress.org/trunk@42883 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5133e5131b
commit
c77a8ed2fc
|
@ -1976,9 +1976,15 @@ function wp_privacy_generate_personal_data_export_group_html( $group_data ) {
|
||||||
$group_html .= '<tbody>';
|
$group_html .= '<tbody>';
|
||||||
|
|
||||||
foreach ( (array) $group_item_data as $group_item_datum ) {
|
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 = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
|
||||||
|
}
|
||||||
|
|
||||||
$group_html .= '<tr>';
|
$group_html .= '<tr>';
|
||||||
$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
|
$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
|
||||||
$group_html .= '<td>' . wp_kses( $group_item_datum['value'], $allowed_tags, $allowed_protocols ) . '</td>';
|
$group_html .= '<td>' . wp_kses( $value, $allowed_tags, $allowed_protocols ) . '</td>';
|
||||||
$group_html .= '</tr>';
|
$group_html .= '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -351,6 +351,7 @@ add_action( 'welcome_panel', 'wp_welcome_panel' );
|
||||||
add_action( 'user_request_action_confirmed', '_wp_privacy_account_request_confirmed' );
|
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( '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_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_filter( 'wp_privacy_personal_data_erasers', 'wp_register_comment_personal_data_eraser' );
|
||||||
add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
|
add_action( 'init', 'wp_schedule_delete_old_privacy_export_files' );
|
||||||
add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
|
add_action( 'wp_privacy_delete_old_export_files', 'wp_privacy_delete_old_export_files' );
|
||||||
|
|
|
@ -4093,3 +4093,79 @@ function wpview_media_sandbox_styles() {
|
||||||
|
|
||||||
return array( $mediaelement, $wpmediaelement );
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue