Move validation to the top

This commit is contained in:
Claudio Sanches 2020-01-22 12:39:19 -03:00
parent d9cc0910ef
commit 8ee6337aea
1 changed files with 4 additions and 4 deletions

View File

@ -132,14 +132,14 @@ class WC_Integration_MaxMind_Geolocation extends WC_Integration {
* @throws Exception When the license key is invalid.
*/
public function validate_license_key_field( $key, $value ) {
// Empty license keys have no need to validate the data.
// Trim whitespaces and strip slashes.
$value = $this->validate_password_field( $key, $value );
// Empty license keys have no need test downloading a database.
if ( empty( $value ) ) {
return $value;
}
// Trim whitespaces and strip slashes.
$value = $this->validate_password_field( $key, $value );
// Check the license key by attempting to download the Geolocation database.
$tmp_database_path = $this->database_service->download_database( $value );
if ( is_wp_error( $tmp_database_path ) ) {