WordPress.org

Make WordPress Core

Changeset 43096


Ignore:
Timestamp:
05/02/2018 02:34:57 AM (2 years ago)
Author:
SergeyBiryukov
Message:

Privacy: Add wp_privacy_personal_data_export_file_created filter.

This runs immediately after the data export file has been successfully created, allowing plugins to introduce some workflow customizations. For example, a plugin could password-protect the export file, for peace of mind, even though the CSPRN in the filename makes brute force attacks nearly impossible.

Props iandunn.
Merges [43047] to the 4.9 branch.
See #43546.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/includes/file.php

    r43095 r43096  
    19861986
    19871987    // Now, generate the ZIP.
     1988    $error            = false;
    19881989    $archive_filename = $file_basename . '.zip';
    19891990    $archive_pathname = $exports_dir . $archive_filename;
     
    19911992
    19921993    $zip = new ZipArchive;
    1993 
    1994     if ( TRUE === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
    1995         $zip->addFile( $html_report_pathname, 'index.html' );
     1994    if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
     1995        if ( ! $zip->addFile( $html_report_pathname, 'index.html' ) ) {
     1996            $error = __( 'Unable to add data to export file.' );
     1997        }
     1998
    19961999        $zip->close();
     2000
     2001        if ( ! $error ) {
     2002            /**
     2003             * Fires right after all personal data has been written to the export file.
     2004             *
     2005             * @since 4.9.6
     2006             *
     2007             * @param string $archive_pathname     The full path to the export file on the filesystem.
     2008             * @param string $archive_url          The URL of the archive file.
     2009             * @param string $html_report_pathname The full path to the personal data report on the filesystem.
     2010             */
     2011            do_action( 'wp_privacy_personal_data_export_file_created', $archive_pathname, $archive_url, $html_report_pathname );
     2012        }
    19972013    } else {
    1998         wp_send_json_error( __( 'Unable to open export file (archive) for writing' ) );
     2014        $error = __( 'Unable to open export file (archive) for writing.' );
    19992015    }
    20002016
    20012017    // And remove the HTML file.
    20022018    unlink( $html_report_pathname );
     2019
     2020    if ( $error ) {
     2021        wp_send_json_error( $error );
     2022    }
    20032023
    20042024    // Save the export file in the request.
Note: See TracChangeset for help on using the changeset viewer.