mirror of
git://develop.git.wordpress.org/
synced 2025-01-17 21:08:44 +01:00
Privacy: Rename exports folder to avoid deleting other files.
Previously, personal data exports were stored in `wp-content/uploads/exports`, which is generic enough that it's likely there are existing folders with that name, either created by plugins or manually by administrators. If that folder were reused by Core, then `wp_privacy_delete_old_export_files()` would delete all of the existing files inside it, which is almost certainly not what the site owner wants or expects. To avoid that, the folder is being renamed to include a specific reference to Core, and a more verbose description of its purpose. With those factored in, it's very unlikely that there will be any conflicts with existing folders. The `wp_privacy_exports_dir()` and `wp_privacy_exports_url()` functions were introduced to provide a canonical source for the location, and the `wp_privacy_exports_dir` and `wp_privacy_exports_url` filters were introduced to allow plugins to customize it. Props johnjamesjacoby, allendav. Merges [43284] to the 4.9 branch. Fixes #44091. git-svn-id: https://develop.svn.wordpress.org/branches/4.9@43285 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
5a35e11560
commit
2750118c45
@ -1886,9 +1886,8 @@ function wp_privacy_generate_personal_data_export_file( $request_id ) {
|
||||
}
|
||||
|
||||
// Create the exports folder if needed.
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
|
||||
$exports_url = trailingslashit( $upload_dir['baseurl'] . '/exports' );
|
||||
$exports_dir = wp_privacy_exports_dir();
|
||||
$exports_url = wp_privacy_exports_url();
|
||||
|
||||
$result = wp_mkdir_p( $exports_dir );
|
||||
if ( is_wp_error( $result ) ) {
|
||||
|
@ -5936,6 +5936,52 @@ function wp_privacy_anonymize_data( $type, $data = '' ) {
|
||||
return apply_filters( 'wp_privacy_anonymize_data', $anonymous, $type, $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @see wp_privacy_exports_url
|
||||
*
|
||||
* @return string Exports directory.
|
||||
*/
|
||||
function wp_privacy_exports_dir() {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
|
||||
|
||||
/**
|
||||
* Filters the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @param string $exports_dir Exports directory.
|
||||
*/
|
||||
return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the URL of the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @see wp_privacy_exports_dir
|
||||
*
|
||||
* @return string Exports directory URL.
|
||||
*/
|
||||
function wp_privacy_exports_url() {
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
|
||||
|
||||
/**
|
||||
* Filters the URL of the directory used to store personal data export files.
|
||||
*
|
||||
* @since 4.9.6
|
||||
*
|
||||
* @param string $exports_url Exports directory URL.
|
||||
*/
|
||||
return apply_filters( 'wp_privacy_exports_url', $exports_url );
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule a `WP_Cron` job to delete expired export files.
|
||||
*
|
||||
@ -5965,8 +6011,7 @@ function wp_schedule_delete_old_privacy_export_files() {
|
||||
function wp_privacy_delete_old_export_files() {
|
||||
require_once( ABSPATH . 'wp-admin/includes/file.php' );
|
||||
|
||||
$upload_dir = wp_upload_dir();
|
||||
$exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
|
||||
$exports_dir = wp_privacy_exports_dir();
|
||||
$export_files = list_files( $exports_dir, 100, array( 'index.html' ) );
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user