Merge branch 'image-upload-error-messages'
This commit is contained in:
commit
7263ec126e
|
@ -1797,7 +1797,9 @@ class WC_API_Products extends WC_API_Resource {
|
|||
'timeout' => 10
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) ) {
|
||||
throw new WC_API_Exception( 'woocommerce_api_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url . ': ' . $response->get_error_message() ), 400 );
|
||||
} elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
throw new WC_API_Exception( 'woocommerce_api_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url ), 400 );
|
||||
}
|
||||
|
||||
|
|
|
@ -2353,7 +2353,9 @@ class WC_API_Products extends WC_API_Resource {
|
|||
'timeout' => 10
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) ) {
|
||||
throw new WC_API_Exception( 'woocommerce_api_invalid_remote_' . $upload_for, sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url . ': ' . $response->get_error_message() ), 400 );
|
||||
} elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
throw new WC_API_Exception( 'woocommerce_api_invalid_remote_' . $upload_for, sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url ), 400 );
|
||||
}
|
||||
|
||||
|
|
|
@ -2018,7 +2018,9 @@ class WC_CLI_Product extends WC_CLI_Command {
|
|||
'timeout' => 10
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
if ( is_wp_error( $response ) ) {
|
||||
throw new WC_CLI_Exception( 'woocommerce_cli_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url . ': ' . $response->get_error_message() ) );
|
||||
} elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
throw new WC_CLI_Exception( 'woocommerce_cli_invalid_remote_product_image', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url ) );
|
||||
}
|
||||
|
||||
|
|
|
@ -64,8 +64,10 @@ function wc_rest_upload_image_from_url( $image_url ) {
|
|||
'timeout' => 10
|
||||
) );
|
||||
|
||||
if ( is_wp_error( $response ) || 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_remote_image_url', sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ), array( 'status' => 400 ) );
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_remote_image_url', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url . ': ' . $response->get_error_message() ), array( 'status' => 400 ) );
|
||||
} elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) {
|
||||
return new WP_Error( 'woocommerce_rest_invalid_remote_image_url', sprintf( __( 'Error getting remote image %s', 'woocommerce' ), $image_url ), array( 'status' => 400 ) );
|
||||
}
|
||||
|
||||
// Ensure we have a file name and type.
|
||||
|
|
Loading…
Reference in New Issue