Changeset 43092 for branches/4.9/src/wp-admin/includes/ajax-actions.php
- Timestamp:
- 05/02/2018 02:15:05 AM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
- Property svn:mergeinfo changed
/trunk merged: 43012,43089
- Property svn:mergeinfo changed
-
branches/4.9/src/wp-admin/includes/ajax-actions.php
r43084 r43092 4019 4019 } 4020 4020 4021 /** 4022 * Ajax handler for exporting a user's personal data. 4023 * 4024 * @since 4.9.6 4025 */ 4021 4026 function wp_ajax_wp_privacy_export_personal_data() { 4022 check_ajax_referer( 'wp-privacy-export-personal-data', 'security' ); 4027 $request_id = (int) $_POST['id']; 4028 4029 if ( empty( $request_id ) ) { 4030 wp_send_json_error( __( 'Error: Invalid request ID.' ) ); 4031 } 4023 4032 4024 4033 if ( ! current_user_can( 'manage_options' ) ) { … … 4026 4035 } 4027 4036 4028 $email_address = sanitize_text_field( $_POST['email'] ); 4037 check_ajax_referer( 'wp-privacy-export-personal-data-' . $request_id, 'security' ); 4038 4039 // Get the request data. 4040 $request = wp_get_user_request_data( $request_id ); 4041 4042 if ( ! $request || 'export_personal_data' !== $request->action_name ) { 4043 wp_send_json_error( __( 'Error: Invalid request type.' ) ); 4044 } 4045 4046 $email_address = $request->email; 4047 if ( ! is_email( $email_address ) ) { 4048 wp_send_json_error( __( 'Error: A valid email address must be given.' ) ); 4049 } 4050 4029 4051 $exporter_index = (int) $_POST['exporter']; 4030 4052 $page = (int) $_POST['page']; 4053 $send_as_email = isset( $_POST['sendAsEmail'] ) ? ( "true" === $_POST['sendAsEmail'] ) : false; 4031 4054 4032 4055 /** … … 4040 4063 * callback string Callable exporter that accepts an email address and 4041 4064 * a page and returns an array of name => value 4042 * pairs of personal data 4043 * exporter_friendly_name string Translated user facing friendly name for the exporter 4065 * pairs of personal data. 4066 * exporter_friendly_name string Translated user facing friendly name for the exporter. 4044 4067 * ] 4045 4068 * } … … 4067 4090 } 4068 4091 4069 // Surprisingly, email addresses can contain mutli-byte characters now4070 $email_address = trim( mb_strtolower( $email_address ) );4071 4072 if ( ! is_email( $email_address ) ) {4073 wp_send_json_error( 'A valid email address must be given.' );4074 }4075 4076 4092 $exporter = $exporters[ $index ]; 4093 4077 4094 if ( ! is_array( $exporter ) ) { 4078 4095 wp_send_json_error( "Expected an array describing the exporter at index {$exporter_index}." ); 4079 4096 } 4080 if ( ! array_key_exists( 'callback', $exporter ) ) {4081 wp_send_json_error( "Exporter array at index {$exporter_index} does not include a callback." );4082 }4083 if ( ! is_callable( $exporter['callback'] ) ) {4084 wp_send_json_error( "Exporter callback at index {$exporter_index} is not a valid callback." );4085 }4086 4097 if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { 4087 4098 wp_send_json_error( "Exporter array at index {$exporter_index} does not include a friendly name." ); 4099 } 4100 if ( ! array_key_exists( 'callback', $exporter ) ) { 4101 wp_send_json_error( "Exporter does not include a callback: {$exporter['exporter_friendly_name']}." ); 4102 } 4103 if ( ! is_callable( $exporter['callback'] ) ) { 4104 wp_send_json_error( "Exporter callback is not a valid callback: {$exporter['exporter_friendly_name']}." ); 4088 4105 } 4089 4106 … … 4109 4126 } 4110 4127 } else { 4111 // No exporters, so we're done 4128 // No exporters, so we're done. 4112 4129 $response = array( 4113 4130 'data' => array(), … … 4127 4144 * @param string $email_address The email address associated with this personal data. 4128 4145 * @param int $page The zero-based page for this response. 4146 * @param int $request_id The privacy request post ID associated with this request. 4147 * @param bool $send_as_email Whether the final results of the export should be emailed to the user. 4129 4148 */ 4130 $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page ); 4149 $response = apply_filters( 'wp_privacy_personal_data_export_page', $response, $exporter_index, $email_address, $page, $request_id, $send_as_email ); 4150 4131 4151 if ( is_wp_error( $response ) ) { 4132 4152 wp_send_json_error( $response ); … … 4154 4174 check_ajax_referer( 'wp-privacy-erase-personal-data-' . $request_id, 'security' ); 4155 4175 4156 // Find the request CPT4176 // Get the request data. 4157 4177 $request = wp_get_user_request_data( $request_id ); 4158 4178
Note: See TracChangeset
for help on using the changeset viewer.