Ticket #44133: 44133.9.diff
File 44133.9.diff, 7.8 KB (added by , 6 years ago) |
---|
-
src/wp-admin/includes/admin-filters.php
133 133 // Privacy hooks 134 134 add_filter( 'wp_privacy_personal_data_erasure_page', 'wp_privacy_process_personal_data_erasure_page', 10, 5 ); 135 135 add_filter( 'wp_privacy_personal_data_export_page', 'wp_privacy_process_personal_data_export_page', 10, 7 ); 136 add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10 );136 add_action( 'wp_privacy_personal_data_export_file', 'wp_privacy_generate_personal_data_export_file', 10, 3 ); 137 137 add_action( 'wp_privacy_personal_data_erased', '_wp_privacy_send_erasure_fulfillment_notification', 10 ); 138 138 139 139 // Privacy policy text changes check. -
src/wp-admin/includes/file.php
1992 1992 * 1993 1993 * @param int $request_id The export request ID. 1994 1994 */ 1995 function wp_privacy_generate_personal_data_export_file( $request_id ) {1995 function wp_privacy_generate_personal_data_export_file( $request_id, $request, $has_export_data ) { 1996 1996 if ( ! class_exists( 'ZipArchive' ) ) { 1997 1997 wp_send_json_error( __( 'Unable to generate export file. ZipArchive not available.' ) ); 1998 1998 } … … 2108 2108 fwrite( $file, wp_privacy_generate_personal_data_export_group_html( $group_data ) ); 2109 2109 } 2110 2110 2111 if ( ! $has_export_data ) { 2112 fwrite( $file, '<strong>' . esc_html__( 'No personal data found.' ) . '</strong>' ); 2113 } 2114 2111 2115 fwrite( $file, "</body>\n" ); 2112 2116 2113 2117 // Close HTML. … … 2174 2178 /** 2175 2179 * Send an email to the user with a link to the personal data export file 2176 2180 * 2181 * The link to the export file is only included in the email content when there 2182 * is personal data to export. 2183 * 2177 2184 * @since 4.9.6 2185 * @since 5.2 Added the $has_export_data parameter. 2178 2186 * 2179 * @param int $request_id The request ID for this personal data export. 2187 * @param int $request_id The request ID for this personal data export. 2188 * @param bool $has_export_data Whether personal data exists to export. 2189 * 2180 2190 * @return true|WP_Error True on success or `WP_Error` on failure. 2181 2191 */ 2182 function wp_privacy_send_personal_data_export_email( $request_id ) {2192 function wp_privacy_send_personal_data_export_email( $request_id, $has_export_data = true ) { 2183 2193 // Get the request data. 2184 2194 $request = wp_get_user_request_data( $request_id ); 2185 2195 … … 2192 2202 $expiration_date = date_i18n( get_option( 'date_format' ), time() + $expiration ); 2193 2203 2194 2204 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 2195 $email_text = __(2196 'Howdy,2205 if ( $has_export_data ) { 2206 $email_text = __( 'Howdy, 2197 2207 2198 2208 Your request for an export of personal data has been completed. You may 2199 2209 download your personal data by clicking on the link below. For privacy … … 2204 2214 2205 2215 Regards, 2206 2216 All at ###SITENAME### 2207 ###SITEURL###' 2208 ); 2217 ###SITEURL###' ); 2209 2218 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 ); 2219 /** 2220 * Filters the text of the email sent with a personal data export file. 2221 * 2222 * The following strings have a special meaning and will get replaced dynamically: 2223 * ###EXPIRATION### The date when the URL will be automatically deleted. 2224 * ###LINK### URL of the personal data export file for the user. 2225 * ###SITENAME### The name of the site. 2226 * ###SITEURL### The URL to the site. 2227 * 2228 * @since 4.9.6 2229 * @since 5.2 $has_export_data argument added. 2230 * 2231 * @param string $email_text Text in the email. 2232 * @param int $request_id The request ID for this personal data export. 2233 * @param bool $has_export_data Whether personal data exists to export. 2234 */ 2235 $content = apply_filters( 'wp_privacy_personal_data_email_content', $email_text, $request_id, $has_export_data ); 2236 } else { 2237 /* translators: Do not translate EXPIRATION, LINK, SITENAME, SITEURL: those are placeholders. */ 2238 $email_text = __( 'Howdy, 2239 Your request for an export of personal data has been completed. 2225 2240 2241 ###SITENAME### has identified no personal data associated with this email address. 2242 2243 You may download your personal data by clicking on the link below. For privacy 2244 and security, we will automatically delete the file on ###EXPIRATION###, 2245 so please download it before then. 2246 2247 ###LINK### 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 5.2 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 2226 2270 $email_address = $request->email; 2227 2271 $export_file_url = get_post_meta( $request_id, '_export_file_url', true ); 2228 2272 $site_name = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); … … 2230 2274 2231 2275 $content = str_replace( '###EXPIRATION###', $expiration_date, $content ); 2232 2276 $content = str_replace( '###LINK###', esc_url_raw( $export_file_url ), $content ); 2233 $content = str_replace( '###EMAIL###', $email_address, $content );2234 2277 $content = str_replace( '###SITENAME###', $site_name, $content ); 2235 2278 $content = str_replace( '###SITEURL###', esc_url_raw( $site_url ), $content ); 2236 2279 … … 2342 2385 delete_post_meta( $request_id, '_export_data_raw' ); 2343 2386 update_post_meta( $request_id, '_export_data_grouped', $groups ); 2344 2387 2388 $has_export_data = ! empty( $groups ); 2389 2345 2390 /** 2346 2391 * Generate the export file from the collected, grouped personal data. 2347 2392 * 2348 2393 * @since 4.9.6 2394 * @since 5.2 Added the $request parameter. 2395 * @since 5.2 Added the $has_export_data parameter. 2349 2396 * 2350 * @param int $request_id The export request ID. 2397 * @param int $request_id The export request ID. 2398 * @param WP_User_Request $request The export request. 2399 * @param bool $has_export_data Wether there are personal data to export. 2351 2400 */ 2352 do_action( 'wp_privacy_personal_data_export_file', $request_id );2401 do_action( 'wp_privacy_personal_data_export_file', $request_id, $request, $has_export_data ); 2353 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 }