| @@ 638-640 (lines=3) @@ | ||
| 635 | return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_too_long', sprintf( __( 'Slug "%s" is too long (28 characters max).', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); |
|
| 636 | } elseif ( wc_check_if_attribute_name_is_reserved( $slug ) ) { |
|
| 637 | return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_reserved_name', sprintf( __( 'Slug "%s" is not allowed because it is a reserved term.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); |
|
| 638 | } elseif ( $new_data && taxonomy_exists( wc_attribute_taxonomy_name( $slug ) ) ) { |
|
| 639 | return new WP_Error( 'woocommerce_rest_invalid_product_attribute_slug_already_exists', sprintf( __( 'Slug "%s" is already in use.', 'woocommerce' ), $slug ), array( 'status' => 400 ) ); |
|
| 640 | } |
|
| 641 | ||
| 642 | return true; |
|
| 643 | } |
|
| @@ 84-86 (lines=3) @@ | ||
| 81 | ||
| 82 | if ( is_wp_error( $response ) ) { |
|
| 83 | return new WP_Error( 'woocommerce_rest_invalid_remote_image_url', sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ) . ' ' . sprintf( __( 'Error: %s.', 'woocommerce' ), $response->get_error_message() ), array( 'status' => 400 ) ); |
|
| 84 | } elseif ( 200 !== wp_remote_retrieve_response_code( $response ) ) { |
|
| 85 | return new WP_Error( 'woocommerce_rest_invalid_remote_image_url', sprintf( __( 'Error getting remote image %s.', 'woocommerce' ), $image_url ), array( 'status' => 400 ) ); |
|
| 86 | } |
|
| 87 | ||
| 88 | // Ensure we have a file name and type. |
|
| 89 | $wp_filetype = wp_check_filetype( $file_name, wc_rest_allowed_image_mime_types() ); |
|
| @@ 211-215 (lines=5) @@ | ||
| 208 | * @return string|WP_Error |
|
| 209 | */ |
|
| 210 | public function validate_setting_select_field( $value, $setting ) { |
|
| 211 | if ( array_key_exists( $value, $setting['options'] ) ) { |
|
| 212 | return $value; |
|
| 213 | } else { |
|
| 214 | return new WP_Error( 'rest_setting_value_invalid', __( 'An invalid setting value was passed.', 'woocommerce' ), array( 'status' => 400 ) ); |
|
| 215 | } |
|
| 216 | } |
|
| 217 | ||
| 218 | /** |
|