WC_Integration_MaxMind_Geolocation::validate_license_key_field()publicWC 1.0

Checks to make sure that the license key is valid.

Метод класса: WC_Integration_MaxMind_Geolocation{}

Хуков нет.

Возвращает

Разное.

Использование

$WC_Integration_MaxMind_Geolocation = new WC_Integration_MaxMind_Geolocation();
$WC_Integration_MaxMind_Geolocation->validate_license_key_field( $key, $value );
$key(строка) (обязательный)
The key of the field.
$value(разное) (обязательный)
The value of the field.

Код WC_Integration_MaxMind_Geolocation::validate_license_key_field() WC 9.3.3

public function validate_license_key_field( $key, $value ) {
	// 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;
	}

	// 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 ) ) {
		WC_Admin_Settings::add_error( $tmp_database_path->get_error_message() );

		// Throw an exception to keep from changing this value. This will prevent
		// users from accidentally losing their license key, which cannot
		// be viewed again after generating.
		throw new Exception( $tmp_database_path->get_error_message() );
	}

	// We may as well put this archive to good use, now that we've downloaded one.
	self::update_database( $tmp_database_path );

	// Remove missing license key notice.
	$this->remove_missing_license_key_notice();

	return $value;
}