diff --git src/wp-admin/includes/file.php src/wp-admin/includes/file.php
index 4535684..696e5bb 100644
|
|
|
function wp_privacy_generate_personal_data_export_file( $request_id ) { |
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | /** |
| 2186 | | * Send an email to the user with a link to the personal data export file |
| | 2186 | * Send an email to the user with a link to the personal data export file. |
| 2187 | 2187 | * |
| 2188 | | * @since 4.9.6 |
| | 2188 | * The link to the export file is only included in the content of the email, |
| | 2189 | * if any personal data is exported. |
| 2189 | 2190 | * |
| 2190 | | * @param int $request_id The request ID for this personal data export. |
| 2191 | | * @return true|WP_Error True on success or `WP_Error` on failure. |
| | 2191 | * @since 4.9.7 |
| | 2192 | * |
| | 2193 | * @param int $request_id The request ID for this personal data export. |
| | 2194 | * @param bool $has_export_data Whether there is any personal data to export. |
| | 2195 | * @return true|WP_Error True on success or `WP_Error` on failure. |
| 2192 | 2196 | */ |
| 2193 | | function wp_privacy_send_personal_data_export_email( $request_id ) { |
| | 2197 | function wp_privacy_send_personal_data_export_email( $request_id, $has_export_data = true ) { |
| 2194 | 2198 | // Get the request data. |
| 2195 | 2199 | $request = wp_get_user_request_data( $request_id ); |
| 2196 | 2200 | |
| … |
… |
function wp_privacy_send_personal_data_export_email( $request_id ) { |
| 2202 | 2206 | $expiration = apply_filters( 'wp_privacy_export_expiration', 3 * DAY_IN_SECONDS ); |
| 2203 | 2207 | $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); |
| 2204 | 2208 | |
| 2205 | | /* translators: Do not translate EXPIRATION, LINK, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| 2206 | | $email_text = __( |
| 2207 | | 'Howdy, |
| | 2209 | if ( $has_export_data ) { |
| | 2210 | |
| | 2211 | /* translators: Do not translate EXPIRATION, LINK, EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| | 2212 | $email_text = __( |
| | 2213 | 'Howdy, |
| 2208 | 2214 | |
| 2209 | 2215 | Your request for an export of personal data has been completed. You may |
| 2210 | 2216 | download your personal data by clicking on the link below. For privacy |
| … |
… |
This email has been sent to ###EMAIL###. |
| 2218 | 2224 | Regards, |
| 2219 | 2225 | All at ###SITENAME### |
| 2220 | 2226 | ###SITEURL###' |
| 2221 | | ); |
| | 2227 | ); |
| | 2228 | |
| | 2229 | } else { |
| | 2230 | |
| | 2231 | /* translators: Do not translate EMAIL, SITENAME, SITEURL: those are placeholders. */ |
| | 2232 | $email_text = __( |
| | 2233 | 'Howdy, |
| | 2234 | |
| | 2235 | Your request for an export of personal data has been completed. |
| | 2236 | |
| | 2237 | No personal data was found. |
| | 2238 | |
| | 2239 | This email has been sent to ###EMAIL###. |
| | 2240 | |
| | 2241 | Regards, |
| | 2242 | All at ###SITENAME### |
| | 2243 | ###SITEURL###' |
| | 2244 | ); |
| | 2245 | } |
| 2222 | 2246 | |
| 2223 | 2247 | /** |
| 2224 | 2248 | * Filters the text of the email sent with a personal data export file. |
| … |
… |
All at ###SITENAME### |
| 2232 | 2256 | * |
| 2233 | 2257 | * @since 4.9.6 |
| 2234 | 2258 | * |
| 2235 | | * @param string $email_text Text in the email. |
| 2236 | | * @param int $request_id The request ID for this personal data export. |
| | 2259 | * @param string $email_text Text in the email. |
| | 2260 | * @param int $request_id The request ID for this personal data export. |
| | 2261 | * @param bool $has_export_data Whether there is any personal data to export. |
| 2237 | 2262 | */ |
| 2238 | | $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id ); |
| | 2263 | $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $has_export_data ); |
| 2239 | 2264 | |
| 2240 | | $email_address = $request->email; |
| | 2265 | $email_address = $request->email; |
| 2241 | 2266 | $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); |
| 2242 | | $site_name = is_multisite() ? get_site_option( 'site_name' ) : get_option( 'blogname' ); |
| 2243 | | $site_url = network_home_url(); |
| | 2267 | $site_name = is_multisite() ? get_site_option( 'site_name' ) : get_option( 'blogname' ); |
| | 2268 | $site_url = network_home_url(); |
| 2244 | 2269 | |
| 2245 | 2270 | $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); |
| 2246 | 2271 | $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); |
| … |
… |
All at ###SITENAME### |
| 2251 | 2276 | $mail_success = wp_mail( |
| 2252 | 2277 | $email_address, |
| 2253 | 2278 | sprintf( |
| | 2279 | /* translators: %s Site name. */ |
| 2254 | 2280 | __( '[%s] Personal Data Export' ), |
| 2255 | 2281 | wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) |
| 2256 | 2282 | ), |
| … |
… |
function wp_privacy_process_personal_data_export_page( $response, $exporter_inde |
| 2356 | 2382 | delete_post_meta( $request_id, '_export_data_raw' ); |
| 2357 | 2383 | update_post_meta( $request_id, '_export_data_grouped', $groups ); |
| 2358 | 2384 | |
| 2359 | | /** |
| 2360 | | * Generate the export file from the collected, grouped personal data. |
| 2361 | | * |
| 2362 | | * @since 4.9.6 |
| 2363 | | * |
| 2364 | | * @param int $request_id The export request ID. |
| 2365 | | */ |
| 2366 | | do_action( 'wp_privacy_personal_data_export_file', $request_id ); |
| | 2385 | $has_export_data = ! empty( $groups ); |
| | 2386 | |
| | 2387 | if ( $has_export_data ) { |
| | 2388 | |
| | 2389 | /** |
| | 2390 | * Generate the export file from the collected, grouped personal data. |
| | 2391 | * |
| | 2392 | * @since 4.9.6 |
| | 2393 | * |
| | 2394 | * @param int $request_id The export request ID. |
| | 2395 | */ |
| | 2396 | do_action( 'wp_privacy_personal_data_export_file', $request_id ); |
| | 2397 | } |
| 2367 | 2398 | |
| 2368 | 2399 | // Clear the grouped data now that it is no longer needed. |
| 2369 | 2400 | delete_post_meta( $request_id, '_export_data_grouped' ); |
| 2370 | 2401 | |
| 2371 | 2402 | // If the destination is email, send it now. |
| 2372 | 2403 | if ( $send_as_email ) { |
| 2373 | | $mail_success = wp_privacy_send_personal_data_export_email( $request_id ); |
| | 2404 | $mail_success = wp_privacy_send_personal_data_export_email( $request_id, $has_export_data ); |
| 2374 | 2405 | if ( is_wp_error( $mail_success ) ) { |
| 2375 | 2406 | wp_send_json_error( $mail_success->get_error_message() ); |
| 2376 | 2407 | } |
| 2377 | | } else { |
| | 2408 | } elseif ( $has_export_data ) { |
| 2378 | 2409 | // Modify the response to include the URL of the export file so the browser can fetch it. |
| 2379 | 2410 | $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); |
| 2380 | 2411 | if ( ! empty( $export_file_url ) ) { |