Ticket #44133: 44133.7.diff
File 44133.7.diff, 7.2 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 2192 * @since 4.9.8 Added the $has_export_data parameter. 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 personal data exists 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, SITENAME, SITEURL: those are placeholders. */ 2206 $email_text = __( 2207 'Howdy,2210 if ( $has_export_data ) { 2211 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 2212 $email_text = __( 'Howdy, 2208 2213 2209 2214 Your request for an export of personal data has been completed. You may 2210 2215 download your personal data by clicking on the link below. For privacy … … 2215 2220 2216 2221 Regards, 2217 2222 All at ###SITENAME### 2218 ###SITEURL###' 2219 ); 2223 ###SITEURL###' ); 2220 2224 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 ); 2225 /** 2226 * Filters the text of the email sent with a personal data export file. 2227 * 2228 * The following strings have a special meaning and will get replaced dynamically: 2229 * ###EXPIRATION### The date when the URL will be automatically deleted. 2230 * ###LINK### URL of the personal data export file for the user. 2231 * ###SITENAME### The name of the site. 2232 * ###SITEURL### The URL to the site. 2233 * 2234 * @since 4.9.6 2235 * @since 4.9.8 $has_export_data argument added. 2236 * 2237 * @param string $email_text Text in the email. 2238 * @param int $request_id The request ID for this personal data export. 2239 * @param bool $has_export_data Whether personal data exists to export. 2240 */ 2241 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $has_export_data ); 2242 } else { 2243 /* translators: Do not translate SITENAME, SITEURL: those are placeholders. */ 2244 $email_text = __( 'Howdy, 2236 2245 2237 $email_address = $request->email; 2246 Your request for an export of personal data has been completed. 2247 2248 ###SITENAME### has identified no personal data associated with this email address. 2249 2250 Regards, 2251 All at ###SITENAME### 2252 ###SITEURL###' ); 2253 2254 /** 2255 * Filters the text of the email sent when no personal data exists to export. 2256 * 2257 * The following strings have a special meaning and will get replaced dynamically: 2258 * ###EXPIRATION### The date when the URL will be automatically deleted. 2259 * ###SITENAME### The name of the site. 2260 * ###SITEURL### The URL to the site. 2261 * 2262 * @since 4.9.8 2263 * 2264 * @param string $email_text Text in the email. 2265 * @param int $request_id The request ID for this personal data export. 2266 * @param bool $has_export_data Whether personal data exists to export. 2267 */ 2268 $content = apply_filters( 'wp_privacy_personal_data_email_content_no_data', $email_text, $request_id, $has_export_data ); 2269 } 2270 2271 $email_address = $request->email; 2238 2272 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2239 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );2240 $site_url = home_url();2273 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); 2274 $site_url = home_url(); 2241 2275 2242 2276 $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); 2243 2277 $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); 2244 $content = str_replace( '###EMAIL###', $email_address, $content );2245 2278 $content = str_replace( '###SITENAME###', $site_name, $content ); 2246 2279 $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content ); 2247 2280 … … 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 $site_name 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.8 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 ) ) {