wp/wp-admin/includes/privacy-tools.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
   273 		$group_html .= '<tbody>';
   273 		$group_html .= '<tbody>';
   274 
   274 
   275 		foreach ( (array) $group_item_data as $group_item_datum ) {
   275 		foreach ( (array) $group_item_data as $group_item_datum ) {
   276 			$value = $group_item_datum['value'];
   276 			$value = $group_item_datum['value'];
   277 			// If it looks like a link, make it a link.
   277 			// If it looks like a link, make it a link.
   278 			if ( false === strpos( $value, ' ' ) && ( 0 === strpos( $value, 'http://' ) || 0 === strpos( $value, 'https://' ) ) ) {
   278 			if ( ! str_contains( $value, ' ' ) && ( str_starts_with( $value, 'http://' ) || str_starts_with( $value, 'https://' ) ) ) {
   279 				$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
   279 				$value = '<a href="' . esc_url( $value ) . '">' . esc_html( $value ) . '</a>';
   280 			}
   280 			}
   281 
   281 
   282 			$group_html .= '<tr>';
   282 			$group_html .= '<tr>';
   283 			$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
   283 			$group_html .= '<th>' . esc_html( $group_item_datum['name'] ) . '</th>';
   533 
   533 
   534 	if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
   534 	if ( ! empty( $archive_pathname ) && file_exists( $archive_pathname ) ) {
   535 		wp_delete_file( $archive_pathname );
   535 		wp_delete_file( $archive_pathname );
   536 	}
   536 	}
   537 
   537 
   538 	$zip = new ZipArchive;
   538 	$zip = new ZipArchive();
   539 	if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
   539 	if ( true === $zip->open( $archive_pathname, ZipArchive::CREATE ) ) {
   540 		if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
   540 		if ( ! $zip->addFile( $json_report_pathname, 'export.json' ) ) {
   541 			$error = __( 'Unable to archive the personal data export file (JSON format).' );
   541 			$error = __( 'Unable to archive the personal data export file (JSON format).' );
   542 		}
   542 		}
   543 
   543 
   593 		return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
   593 		return new WP_Error( 'invalid_request', __( 'Invalid request ID when sending personal data export email.' ) );
   594 	}
   594 	}
   595 
   595 
   596 	// Localize message content for user; fallback to site default for visitors.
   596 	// Localize message content for user; fallback to site default for visitors.
   597 	if ( ! empty( $request->user_id ) ) {
   597 	if ( ! empty( $request->user_id ) ) {
   598 		$locale = get_user_locale( $request->user_id );
   598 		$switched_locale = switch_to_user_locale( $request->user_id );
   599 	} else {
   599 	} else {
   600 		$locale = get_locale();
   600 		$switched_locale = switch_to_locale( get_locale() );
   601 	}
   601 	}
   602 
       
   603 	$switched_locale = switch_to_locale( $locale );
       
   604 
   602 
   605 	/** This filter is documented in wp-includes/functions.php */
   603 	/** This filter is documented in wp-includes/functions.php */
   606 	$expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
   604 	$expiration      = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS );
   607 	$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
   605 	$expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration );
   608 
   606 
   704 	 *     @type string          $siteurl           The site URL sending the mail.
   702 	 *     @type string          $siteurl           The site URL sending the mail.
   705 	 */
   703 	 */
   706 	$content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
   704 	$content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $email_data );
   707 
   705 
   708 	$content = str_replace( '###EXPIRATION###', $expiration_date, $content );
   706 	$content = str_replace( '###EXPIRATION###', $expiration_date, $content );
   709 	$content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content );
   707 	$content = str_replace( '###LINK###', sanitize_url( $export_file_url ), $content );
   710 	$content = str_replace( '###EMAIL###', $request_email, $content );
   708 	$content = str_replace( '###EMAIL###', $request_email, $content );
   711 	$content = str_replace( '###SITENAME###', $site_name, $content );
   709 	$content = str_replace( '###SITENAME###', $site_name, $content );
   712 	$content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content );
   710 	$content = str_replace( '###SITEURL###', sanitize_url( $site_url ), $content );
   713 
   711 
   714 	$headers = '';
   712 	$headers = '';
   715 
   713 
   716 	/**
   714 	/**
   717 	 * Filters the headers of the email sent with a personal data export file.
   715 	 * Filters the headers of the email sent with a personal data export file.