Make WordPress Core

Changeset 43284


Ignore:
Timestamp:
05/15/2018 08:21:37 PM (7 years ago)
Author:
iandunn
Message:

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.
Fixes #44091.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/file.php

    r43234 r43284  
    20242024
    20252025    // Create the exports folder if needed.
    2026     $upload_dir  = wp_upload_dir();
    2027     $exports_dir = trailingslashit( $upload_dir['basedir'] . '/exports' );
    2028     $exports_url = trailingslashit( $upload_dir['baseurl'] . '/exports' );
     2026    $exports_dir = wp_privacy_exports_dir();
     2027    $exports_url = wp_privacy_exports_url();
    20292028
    20302029    $result = wp_mkdir_p( $exports_dir );
  • trunk/src/wp-includes/functions.php

    r43223 r43284  
    62506250
    62516251/**
     6252 * Returns the directory used to store personal data export files.
     6253 *
     6254 * @since 4.9.6
     6255 *
     6256 * @see wp_privacy_exports_url
     6257 *
     6258 * @return string Exports directory.
     6259 */
     6260function wp_privacy_exports_dir() {
     6261    $upload_dir  = wp_upload_dir();
     6262    $exports_dir = trailingslashit( $upload_dir['basedir'] ) . 'wp-personal-data-exports/';
     6263
     6264    /**
     6265     * Filters the directory used to store personal data export files.
     6266     *
     6267     * @since 4.9.6
     6268     *
     6269     * @param string $exports_dir Exports directory.
     6270     */
     6271    return apply_filters( 'wp_privacy_exports_dir', $exports_dir );
     6272}
     6273
     6274/**
     6275 * Returns the URL of the directory used to store personal data export files.
     6276 *
     6277 * @since 4.9.6
     6278 *
     6279 * @see wp_privacy_exports_dir
     6280 *
     6281 * @return string Exports directory URL.
     6282 */
     6283function wp_privacy_exports_url() {
     6284    $upload_dir  = wp_upload_dir();
     6285    $exports_url = trailingslashit( $upload_dir['baseurl'] ) . 'wp-personal-data-exports/';
     6286
     6287    /**
     6288     * Filters the URL of the directory used to store personal data export files.
     6289     *
     6290     * @since 4.9.6
     6291     *
     6292     * @param string $exports_url Exports directory URL.
     6293     */
     6294    return apply_filters( 'wp_privacy_exports_url', $exports_url );
     6295}
     6296
     6297/**
    62526298 * Schedule a `WP_Cron` job to delete expired export files.
    62536299 *
     
    62786324    require_once( ABSPATH . 'wp-admin/includes/file.php' );
    62796325
    6280     $upload_dir   = wp_upload_dir();
    6281     $exports_dir  = trailingslashit( $upload_dir['basedir'] . '/exports' );
     6326    $exports_dir  = wp_privacy_exports_dir();
    62826327    $export_files = list_files( $exports_dir, 100, array( 'index.html' ) );
    62836328
Note: See TracChangeset for help on using the changeset viewer.