Merge pull request #14566 from woocommerce/fix/14563

Better email handling when invalid
This commit is contained in:
Mike Jolley 2017-04-20 14:48:24 +01:00 committed by GitHub
commit 3ef5ad2565
1 changed files with 3 additions and 2 deletions

View File

@ -626,12 +626,13 @@ class WC_Checkout {
}
}
if ( in_array( 'email', $format ) ) {
if ( in_array( 'email', $format ) && '' !== $data[ $key ] ) {
$data[ $key ] = sanitize_email( $data[ $key ] );
if ( '' !== $data[ $key ] && ! is_email( $data[ $key ] ) ) {
if ( ! is_email( $data[ $key ] ) ) {
/* translators: %s: email address */
$errors->add( 'validation', sprintf( __( '%s is not a valid email address.', 'woocommerce' ), '<strong>' . $field_label . '</strong>' ) );
continue;
}
}