Ticket #44133: 44133.5.diff
File 44133.5.diff, 6.9 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 email content when there 2189 * is personal data to export. 2190 * 2188 2191 * @since 4.9.6 2189 2192 * 2190 * @param int $request_id The request ID for this personal data export. 2193 * @param int $request_id The request ID for this personal data export. 2194 * @param bool $has_export_data Whether personal data exists to export. 2191 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 … … 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, SITENAME, SITEURL: those are placeholders. */ 2206 $email_text = __( 2207 'Howdy,2209 if ( $has_export_data ) { 2210 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 2211 $email_text = __( 'Howdy, 2208 2212 2209 2213 Your request for an export of personal data has been completed. You may 2210 2214 download your personal data by clicking on the link below. For privacy … … 2215 2219 2216 2220 Regards, 2217 2221 All at ###SITENAME### 2218 ###SITEURL###' 2219 ); 2222 ###SITEURL###' ); 2220 2223 2221 /** 2222 * Filters the text of the email sent with a personal data export file. 2223 * 2224 * The following strings have a special meaning and will get replaced dynamically: 2225 * ###EXPIRATION### The date when the URL will be automatically deleted. 2226 * ###LINK### URL of the personal data export file for the user. 2227 * ###SITENAME### The name of the site. 2228 * ###SITEURL### The URL to the site. 2229 * 2230 * @since 4.9.6 2231 * 2232 * @param string $email_text Text in the email. 2233 * @param int $request_id The request ID for this personal data export. 2234 */ 2235 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id ); 2224 /** 2225 * Filters the text of the email sent with a personal data export file. 2226 * 2227 * The following strings have a special meaning and will get replaced dynamically: 2228 * ###EXPIRATION### The date when the URL will be automatically deleted. 2229 * ###LINK### URL of the personal data export file for the user. 2230 * ###SITENAME### The name of the site. 2231 * ###SITEURL### The URL to the site. 2232 * 2233 * @since 4.9.6 2234 * @since 4.9.7 $has_export_data parameter added. 2235 * 2236 * @param string $email_text Text in the email. 2237 * @param int $request_id The request ID for this personal data export. 2238 * @param bool $has_export_data Whether personal data exists to export. 2239 */ 2240 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $has_export_data ); 2241 } else { 2242 /* translators: Do not translate EXPIRATION, SITENAME, SITEURL: those are placeholders. */ 2243 $email_text = __( 'Howdy, 2236 2244 2237 $email_address = $request->email; 2245 Your request for an export of personal data has been completed. 2246 2247 No personal data was found. 2248 2249 Regards, 2250 All at ###SITENAME### 2251 ###SITEURL###' ); 2252 2253 /** 2254 * Filters the text of the email sent when no personal data exists to export. 2255 * 2256 * The following strings have a special meaning and will get replaced dynamically: 2257 * ###EXPIRATION### The date when the URL will be automatically deleted. 2258 * ###SITENAME### The name of the site. 2259 * ###SITEURL### The URL to the site. 2260 * 2261 * @since 4.9.7 2262 * 2263 * @param string $email_text Text in the email. 2264 * @param int $request_id The request ID for this personal data export. 2265 * @param bool $has_export_data Whether personal data exists to export. 2266 */ 2267 $content = apply_filters( 'wp_privacy_personal_data_email_content_no_data', $email_text, $request_id, $has_export_data ); 2268 } 2269 2270 $email_address = $request->email; 2238 2271 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2239 $site_name = is_multisite() ? get_site_option( 'site_name' ) : get_option( 'blogname' );2240 $site_url = network_home_url();2272 $site_name = is_multisite() ? get_site_option( 'site_name' ) : get_option( 'blogname' ); 2273 $site_url = network_home_url(); 2241 2274 2242 2275 $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); 2243 2276 $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); … … 2248 2281 $mail_success = wp_mail( 2249 2282 $email_address, 2250 2283 sprintf( 2284 /* translators: %s Site name. */ 2251 2285 __( '[%s] Personal Data Export' ), 2252 2286 wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ) 2253 2287 ), … … 2353 2387 delete_post_meta( $request_id, '_export_data_raw' ); 2354 2388 update_post_meta( $request_id, '_export_data_grouped', $groups ); 2355 2389 2356 /** 2357 * Generate the export file from the collected, grouped personal data. 2358 * 2359 * @since 4.9.6 2360 * 2361 * @param int $request_id The export request ID. 2362 */ 2363 do_action( 'wp_privacy_personal_data_export_file', $request_id ); 2390 $has_export_data = ! empty( $groups ); 2364 2391 2392 if ( $has_export_data ) { 2393 /** 2394 * Generate the export file from the collected, grouped personal data. 2395 * 2396 * @since 4.9.6 2397 * @since 4.9.7 Added the $request parameter. 2398 * 2399 * @param int $request_id The export request ID. 2400 * @param WP_User_Request $request The export request. 2401 */ 2402 do_action( 'wp_privacy_personal_data_export_file', $request_id, $request ); 2403 } else { 2404 /** 2405 * Fires when no personal data is found for exporting. 2406 * 2407 * @since 4.9.7 2408 * 2409 * @param int $request_id The export request ID. 2410 * @param WP_User_Request $request The export request. 2411 */ 2412 do_action( 'wp_privacy_personal_data_export_no_data', $request_id, $request ); 2413 } 2414 2365 2415 // Clear the grouped data now that it is no longer needed. 2366 2416 delete_post_meta( $request_id, '_export_data_grouped' ); 2367 2417 2368 2418 // If the destination is email, send it now. 2369 2419 if ( $send_as_email ) { 2370 $mail_success = wp_privacy_send_personal_data_export_email( $request_id );2420 $mail_success = wp_privacy_send_personal_data_export_email( $request_id, $has_export_data ); 2371 2421 if ( is_wp_error( $mail_success ) ) { 2372 2422 wp_send_json_error( $mail_success->get_error_message() ); 2373 2423 } 2374 } else {2424 } elseif ( $has_export_data ) { 2375 2425 // Modify the response to include the URL of the export file so the browser can fetch it. 2376 2426 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2377 2427 if ( ! empty( $export_file_url ) ) {