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