Ticket #43438: 43438.7.diff
File 43438.7.diff, 5.4 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/ajax-actions.php
4353 4353 } 4354 4354 4355 4355 $email_address = $request->email; 4356 if ( ! is_email( $email_address) ) {4356 if ( ! is_email( strtolower( $email_address ) ) ) { 4357 4357 wp_send_json_error( __( 'Error: A valid email address must be given.' ) ); 4358 4358 } 4359 4359 … … 4368 4368 * 4369 4369 * @param array $args { 4370 4370 * An array of callable exporters of personal data. Default empty array. 4371 * [ 4372 * callback string Callable exporter that accepts an email address and 4373 * a page and returns an array of name => value 4374 * pairs of personal data. 4375 * exporter_friendly_name string Translated user facing friendly name for the exporter. 4376 * ] 4371 * 4372 * @type array { 4373 * Array of personal data exporters. 4374 * 4375 * @type string $callback Callable exporter function that accepts an 4376 * email address and a page and returns an array 4377 * of name => value pairs of personal data. 4378 * @type string $exporter_friendly_name Translated user facing friendly name for the 4379 * exporter. 4380 * } 4377 4381 * } 4378 4382 */ 4379 4383 $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); 4380 4384 4381 4385 if ( ! is_array( $exporters ) ) { 4382 wp_send_json_error( 'An exporter has improperly used the registration filter.');4386 wp_send_json_error( __( 'An exporter has improperly used the registration filter.' ) ); 4383 4387 } 4384 4388 4385 4389 // Do we have any registered exporters? 4386 4390 if ( 0 < count( $exporters ) ) { 4387 4391 if ( $exporter_index < 1 ) { 4388 wp_send_json_error( 'Exporter index cannot be negative.');4392 wp_send_json_error( __( 'Exporter index cannot be negative.' ) ); 4389 4393 } 4390 4394 4391 4395 if ( $exporter_index > count( $exporters ) ) { 4392 wp_send_json_error( 'Exporter index out of range.');4396 wp_send_json_error( __( 'Exporter index out of range.' ) ); 4393 4397 } 4394 4398 4395 4399 $index = $exporter_index - 1; 4396 4400 4397 4401 if ( $page < 1 ) { 4398 wp_send_json_error( 'Page index cannot be less than one.');4402 wp_send_json_error( __( 'Page index cannot be less than one.' ) ); 4399 4403 } 4400 4404 4401 4405 $exporter = $exporters[ $index ]; 4402 4406 4403 4407 if ( ! is_array( $exporter ) ) { 4404 wp_send_json_error( "Expected an array describing the exporter at index {$exporter_index}." ); 4408 wp_send_json_error( 4409 sprintf( 4410 /* translators: %s: array index */ 4411 __( 'Expected an array describing the exporter at index %s.' ), 4412 $exporter_index 4413 ) 4414 ); 4405 4415 } 4406 4416 if ( ! array_key_exists( 'exporter_friendly_name', $exporter ) ) { 4407 wp_send_json_error( "Exporter array at index {$exporter_index} does not include a friendly name." ); 4417 wp_send_json_error( 4418 sprintf( 4419 /* translators: %s: array index */ 4420 __( 'Exporter array at index %s does not include a friendly name.' ), 4421 $exporter_index 4422 ) 4423 ); 4408 4424 } 4409 4425 if ( ! array_key_exists( 'callback', $exporter ) ) { 4410 wp_send_json_error( "Exporter does not include a callback: {$exporter['exporter_friendly_name']}." ); 4426 wp_send_json_error( 4427 sprintf( 4428 /* translators: %s: exporter friendly name */ 4429 __( 'Exporter does not include a callback: %s.' ), 4430 $exporter['exporter_friendly_name'] 4431 ) 4432 ); 4411 4433 } 4412 4434 if ( ! is_callable( $exporter['callback'] ) ) { 4413 wp_send_json_error( "Exporter callback is not a valid callback: {$exporter['exporter_friendly_name']}." ); 4435 wp_send_json_error( 4436 sprintf( 4437 /* translators: %s: exporter friendly name */ 4438 __( 'Exporter callback is not a valid callback: %s.' ), 4439 $exporter['exporter_friendly_name'] 4440 ) 4441 ); 4414 4442 } 4415 4443 4416 4444 $callback = $exporters[ $index ]['callback']; … … 4422 4450 } 4423 4451 4424 4452 if ( ! is_array( $response ) ) { 4425 wp_send_json_error( "Expected response as an array from exporter: {$exporter_friendly_name}." ); 4453 wp_send_json_error( 4454 sprintf( 4455 /* translators: %s: exporter friendly name */ 4456 __( 'Expected response as an array from exporter: %s.' ), 4457 $exporter_friendly_name 4458 ) 4459 ); 4426 4460 } 4427 4461 if ( ! array_key_exists( 'data', $response ) ) { 4428 wp_send_json_error( "Expected data in response array from exporter: {$exporter_friendly_name}." ); 4462 wp_send_json_error( 4463 sprintf( 4464 /* translators: %s: exporter friendly name */ 4465 __( 'Expected data in response array from exporter: %s.' ), 4466 $exporter_friendly_name 4467 ) 4468 ); 4429 4469 } 4430 4470 if ( ! is_array( $response['data'] ) ) { 4431 wp_send_json_error( "Expected data array in response array from exporter: {$exporter_friendly_name}." ); 4471 wp_send_json_error( 4472 sprintf( 4473 /* translators: %s: exporter friendly name */ 4474 __( 'Expected data array in response array from exporter: %s.' ), 4475 $exporter_friendly_name 4476 ) 4477 ); 4432 4478 } 4433 4479 if ( ! array_key_exists( 'done', $response ) ) { 4434 wp_send_json_error( "Expected done (boolean) in response array from exporter: {$exporter_friendly_name}." ); 4480 wp_send_json_error( 4481 sprintf( 4482 /* translators: %s: exporter friendly name */ 4483 __( 'Expected done (boolean) in response array from exporter: %s.' ), 4484 $exporter_friendly_name 4485 ) 4486 ); 4435 4487 } 4436 4488 } else { 4437 4489 // No exporters, so we're done.