Ticket #44133: 44133.8.diff
File 44133.8.diff, 6.6 KB (added by , 6 years ago) |
---|
-
wp-admin/includes/file.php
2174 2174 /** 2175 2175 * Send an email to the user with a link to the personal data export file 2176 2176 * 2177 * The link to the export file is only included in the email content when there 2178 * is personal data to export. 2179 * 2177 2180 * @since 4.9.6 2181 * @since 5.2 Added the $has_export_data parameter. 2178 2182 * 2179 * @param int $request_id The request ID for this personal data export. 2183 * @param int $request_id The request ID for this personal data export. 2184 * @param bool $has_export_data Whether personal data exists to export. 2185 * 2180 2186 * @return true|WP_Error True on success or `WP_Error` on failure. 2181 2187 */ 2182 function wp_privacy_send_personal_data_export_email( $request_id ) {2188 function wp_privacy_send_personal_data_export_email( $request_id, $has_export_data = true ) { 2183 2189 // Get the request data. 2184 2190 $request = wp_get_user_request_data( $request_id ); 2185 2191 … … 2192 2198 $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 2193 2199 2194 2200 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 2195 $email_text = __(2196 'Howdy,2201 if ( $has_export_data ) { 2202 $email_text = __( 'Howdy, 2197 2203 2198 2204 Your request for an export of personal data has been completed. You may 2199 2205 download your personal data by clicking on the link below. For privacy … … 2204 2210 2205 2211 Regards, 2206 2212 All at ###SITENAME### 2207 ###SITEURL###' 2208 ); 2213 ###SITEURL###' ); 2209 2214 2210 /** 2211 * Filters the text of the email sent with a personal data export file. 2212 * 2213 * The following strings have a special meaning and will get replaced dynamically: 2214 * ###EXPIRATION### The date when the URL will be automatically deleted. 2215 * ###LINK### URL of the personal data export file for the user. 2216 * ###SITENAME### The name of the site. 2217 * ###SITEURL### The URL to the site. 2218 * 2219 * @since 4.9.6 2220 * 2221 * @param string $email_text Text in the email. 2222 * @param int $request_id The request ID for this personal data export. 2223 */ 2224 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id ); 2215 /** 2216 * Filters the text of the email sent with a personal data export file. 2217 * 2218 * The following strings have a special meaning and will get replaced dynamically: 2219 * ###EXPIRATION### The date when the URL will be automatically deleted. 2220 * ###LINK### URL of the personal data export file for the user. 2221 * ###SITENAME### The name of the site. 2222 * ###SITEURL### The URL to the site. 2223 * 2224 * @since 4.9.6 2225 * @since 5.2 $has_export_data argument added. 2226 * 2227 * @param string $email_text Text in the email. 2228 * @param int $request_id The request ID for this personal data export. 2229 * @param bool $has_export_data Whether personal data exists to export. 2230 */ 2231 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $has_export_data ); 2232 } else { 2233 /* translators: Do not translate SITENAME, SITEURL: those are placeholders. */ 2234 $email_text = __( 'Howdy, 2235 Your request for an export of personal data has been completed. 2225 2236 2237 ###SITENAME### has identified no personal data associated with this email address. 2238 2239 Regards, 2240 All at ###SITENAME### 2241 ###SITEURL###' ); 2242 2243 /** 2244 * Filters the text of the email sent when no personal data exists to export. 2245 * 2246 * The following strings have a special meaning and will get replaced dynamically: 2247 * ###EXPIRATION### The date when the URL will be automatically deleted. 2248 * ###SITENAME### The name of the site. 2249 * ###SITEURL### The URL to the site. 2250 * 2251 * @since 5.2 2252 * 2253 * @param string $email_text Text in the email. 2254 * @param int $request_id The request ID for this personal data export. 2255 * @param bool $has_export_data Whether personal data exists to export. 2256 */ 2257 $content = apply_filters( 'wp_privacy_personal_data_email_content_no_data', $email_text, $request_id, $has_export_data ); 2258 } 2259 2226 2260 $email_address = $request->email; 2227 2261 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2228 2262 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); … … 2230 2264 2231 2265 $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); 2232 2266 $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); 2233 $content = str_replace( '###EMAIL###', $email_address, $content );2234 2267 $content = str_replace( '###SITENAME###', $site_name, $content ); 2235 2268 $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content ); 2236 2269 … … 2342 2375 delete_post_meta( $request_id, '_export_data_raw' ); 2343 2376 update_post_meta( $request_id, '_export_data_grouped', $groups ); 2344 2377 2345 /** 2346 * Generate the export file from the collected, grouped personal data. 2347 * 2348 * @since 4.9.6 2349 * 2350 * @param int $request_id The export request ID. 2351 */ 2352 do_action( 'wp_privacy_personal_data_export_file', $request_id ); 2378 $has_export_data = ! empty( $groups ); 2353 2379 2380 if ( $has_export_data ) { 2381 /** 2382 * Generate the export file from the collected, grouped personal data. 2383 * 2384 * @since 4.9.6 2385 * @since 5.2 Added the $request parameter. 2386 * 2387 * @param int $request_id The export request ID. 2388 * @param WP_User_Request $request The export request. 2389 */ 2390 do_action( 'wp_privacy_personal_data_export_file', $request_id, $request ); 2391 } else { 2392 /** 2393 * Fires when no personal data is found for exporting. 2394 * 2395 * @since 5.2 2396 * 2397 * @param int $request_id The export request ID. 2398 * @param WP_User_Request $request The export request. 2399 */ 2400 do_action( 'wp_privacy_personal_data_export_no_data', $request_id, $request ); 2401 } 2402 2354 2403 // Clear the grouped data now that it is no longer needed. 2355 2404 delete_post_meta( $request_id, '_export_data_grouped' ); 2356 2405 2357 2406 // If the destination is email, send it now. 2358 2407 if ( $send_as_email ) { 2359 $mail_success = wp_privacy_send_personal_data_export_email( $request_id );2408 $mail_success = wp_privacy_send_personal_data_export_email( $request_id, $has_export_data ); 2360 2409 if ( is_wp_error( $mail_success ) ) { 2361 2410 wp_send_json_error( $mail_success->get_error_message() ); 2362 2411 } 2363 } else {2412 } elseif ( $has_export_data ) { 2364 2413 // Modify the response to include the URL of the export file so the browser can fetch it. 2365 2414 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2366 2415 if ( ! empty( $export_file_url ) ) {