Changeset 43012 for trunk/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 04/27/2018 07:53:37 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r43011 r43012 4328 4328 } 4329 4329 4330 /** 4331 * Ajax handler for exporting a user's personal data. 4332 * 4333 * @since 4.9.6 4334 */ 4330 4335 function wp_ajax_wp_privacy_export_personal_data() { 4331 check_ajax_referer( 'wp-privacy-export-personal-data', 'security' ); 4336 $request_id = (int) $_POST['id']; 4337 4338 if ( empty( $request_id ) ) { 4339 wp_send_json_error( __( 'Error: Invalid request ID.' ) ); 4340 } 4332 4341 4333 4342 if ( ! current_user_can( 'manage_options' ) ) { … … 4335 4344 } 4336 4345 4337 $email_address = sanitize_text_field( $_POST['email'] ); 4346 check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); 4347 4348 // Get the request data. 4349 $request = wp_get_user_request_data( $request_id ); 4350 4351 if ( ! $request || 'export_personal_data' !== $request->action_name ) { 4352 wp_send_json_error( __( 'Error: Invalid request type.' ) ); 4353 } 4354 4355 $email_address = $request->email; 4356 if ( ! is_email( $email_address ) ) { 4357 wp_send_json_error( __( 'Error: A valid email address must be given.' ) ); 4358 } 4359 4338 4360 $exporter_index = (int) $_POST['exporter']; 4339 4361 $page = (int) $_POST['page']; 4362 $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( "true" === $_POST['sendAsEmail'] ) : false; 4340 4363 4341 4364 /** … … 4349 4372 * callback string Callable exporter that accepts an email address and 4350 4373 * a page and returns an array of name => value 4351 * pairs of personal data 4352 * exporter_friendly_name string Translated user facing friendly name for the exporter 4374 * pairs of personal data. 4375 * exporter_friendly_name string Translated user facing friendly name for the exporter. 4353 4376 * ] 4354 4377 * } … … 4376 4399 } 4377 4400 4378 // Surprisingly, email addresses can contain mutli-byte characters now4379 $email_address = trim( mb_strtolower( $email_address ) );4380 4381 if ( ! is_email( $email_address ) ) {4382 wp_send_json_error( 'A valid email address must be given.' );4383 }4384 4385 4401 $exporter = $exporters[ $index ]; 4402 4386 4403 if ( ! is_array( $exporter ) ) { 4387 4404 wp_send_json_error( "Expected an array describing the exporter at index {$exporter_index}." ); 4388 4405 } 4389 if ( ! array_key_exists( 'callback', $exporter ) ) {4390 wp_send_json_error( "Exporter array at index {$exporter_index} does not include a callback." );4391 }4392 if ( ! is_callable( $exporter['callback'] ) ) {4393 wp_send_json_error( "Exporter callback at index {$exporter_index} is not a valid callback." );4394 }4395 4406 if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { 4396 4407 wp_send_json_error( "Exporter array at index {$exporter_index} does not include a friendly name." ); 4408 } 4409 if ( ! array_key_exists( 'callback', $exporter ) ) { 4410 wp_send_json_error( "Exporter does not include a callback: {$exporter['exporter_friendly_name']}." ); 4411 } 4412 if ( ! is_callable( $exporter['callback'] ) ) { 4413 wp_send_json_error( "Exporter callback is not a valid callback: {$exporter['exporter_friendly_name']}." ); 4397 4414 } 4398 4415 … … 4418 4435 } 4419 4436 } else { 4420 // No exporters, so we're done 4437 // No exporters, so we're done. 4421 4438 $response = array( 4422 4439 'data' => array(), … … 4436 4453 * @param string $email_address The email address associated with this personal data. 4437 4454 * @param int $page The zero-based page for this response. 4455 * @param int $request_id The privacy request post ID associated with this request. 4456 * @param bool $send_as_email Whether the final results of the export should be emailed to the user. 4438 4457 */ 4439 $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page ); 4458 $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page, $request_id, $send_as_email ); 4459 4440 4460 if ( is_wp_error( $response ) ) { 4441 4461 wp_send_json_error( $response ); … … 4463 4483 check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); 4464 4484 4465 // Find the request CPT4485 // Get the request data. 4466 4486 $request = wp_get_user_request_data( $request_id ); 4467 4487
Note: See TracChangeset
for help on using the changeset viewer.