wppaste
WordPress

wp_privacy_generate_personal_data_export_file( int $request_id )

Since
4.9.6
Source
wp-admin/includes/privacy-tools.php:310
Generate the personal data export file.

Parameters

$request_idint
The export request ID.

Hooks fired · 1

One hook fires while wp_privacy_generate_personal_data_export_file() runs, in this order:

  1. do_action( wp_privacy_personal_data_export_file_created )actionline 563 (+253 into the body)

    Fires right after all personal data has been written to the export file.

Uses · 26

Show all 26

Source

function wp_privacy_generate_personal_data_export_file( $request_id ) {	if ( ! class_exists( 'ZipArchive' ) ) {		wp_send_json_error( __( 'Unable to generate personal data export file. ZipArchive not available.' ) );	} 	// Get the request.	$request = wp_get_user_request( $request_id ); 	if ( ! $request || 'export_personal_data' !== $request->action_name ) {		wp_send_json_error( __( 'Invalid request ID when generating personal data export file.' ) );	} 	$email_address = $request->email; 	if ( ! is_email( $email_address ) ) {		wp_send_json_error( __( 'Invalid email address when generating personal data export file.' ) );	} 	// Create the exports folder if needed.	$exports_dir = wp_privacy_exports_dir();	$exports_url = wp_privacy_exports_url(); 	if ( ! wp_mkdir_p( $exports_dir ) ) {		wp_send_json_error( __( 'Unable to create personal data export folder.' ) );	} 	// Protect export folder from browsing.	$index_pathname = $exports_dir . 'index.php';	if ( ! file_exists( $index_pathname ) ) {		$file = fopen( $index_pathname, 'w' );		if ( false === $file ) {			wp_send_json_error( __( 'Unable to protect personal data export folder from browsing.' ) );		}		fwrite( $file, "<?php\n// Silence is golden.\n" );		fclose( $file );	} 	$obscura              = wp_generate_password( 32, false, false );	$file_basename        = 'wp-personal-data-file-' . $obscura;	$html_report_filename = wp_unique_filename( $exports_dir, $file_basename . '.html' );	$html_report_pathname = wp_normalize_path( $exports_dir . $html_report_filename );	$json_report_filename = $file_basename . '.json';	$json_report_pathname = wp_normalize_path( $exports_dir . $json_report_filename ); 	/*	 * Gather general data needed.	 */ 	// Title.	$title = sprintf(		/* translators: %s: User's email address. */		__( 'Personal Data Export for %s' ),		$email_address	); 	// First, build an "About" group on the fly for this report.	$about_group = array(		/* translators: Header for the About section in a personal data export. */		'group_label'       => _x( 'About', 'personal data group label' ),		/* translators: Description for the About section in a personal data export. */		'group_description' => _x( 'Overview of export report.', 'personal data group description' ),		'items'             => array(			'about-1' => array(				array(					'name'  => _x( 'Report generated for', 'email address' ),					'value' => $email_address,				),				array(					'name'  => _x( 'For site', 'website name' ),					'value' => get_bloginfo( 'name' ),				),				array(					'name'  => _x( 'At URL', 'website URL' ),					'value' => get_bloginfo( 'url' ),				),				array(					'name'  => _x( 'On', 'date/time' ),					'value' => current_time( 'mysql' ),				),			),

History

Introduced in 4.9.6. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 tag, from src/wp-admin/includes/privacy-tools.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.