public function save_settings() {

		if ( isset( $_POST['geot_nonce'] ) && wp_verify_nonce( $_POST['geot_nonce'], 'geot_save_settings' ) ) {
			$settings =  $_POST['geot_settings'] ;
			if ( isset( $_FILES['geot_settings_json'] ) && 'application/json' == $_FILES['geot_settings_json']['type'] ) {
				$file     = file_get_contents( $_FILES['geot_settings_json']['tmp_name'] );
				$settings = json_decode( $file, true );

			}
			// trim fields
			if ( is_array( $settings ) ) {
				$settings = array_filter( $settings, function ( $a ) {
					if ( is_string( $a ) ) {
						return trim( $a );
					}
					return $a;
				} );
			}
			// update license field
			if ( ! empty( $settings['license'] ) ) {
				$license = esc_attr( $settings['license'] );
				$this->is_valid_license( $license );
			}
			// old settings
			$old_settings = geot_settings();
			// checkboxes dirty hack
			$inputs = [
				'maxmind',
				'ip2location',
				'wpengine',
				'kinsta',
				'cache_mode',
				'debug_mode',
				'license',
				'api_secret',
				'fallback_country_ips',
				'bots_country_ips',
			];
			if( ! isset($_GET['view']) || ( isset($_GET['view']) && 'general' == $_GET['view'] ) ){
				foreach ($inputs as $input ) {
					if( ! isset($settings[$input]) || empty($settings[$input]) ) {
						$settings[$input] = '';
					}
				}
			}
			if( isset($_GET['view']) && 'regions' == $_GET['view']){
				foreach ([ 'region', 'city_region'] as $input ) {
					if( ! isset($settings[$input]) || empty($settings[$input]) ) {
						$settings[$input] = null;
					}
				}
			}

			if( ! is_array( $settings ) ) {
				$settings = $old_settings;
			} else if( is_array( $old_settings ) ) {
				$settings = array_merge( $old_settings, $settings );
			}

			
			if( apply_filters('geot/enable_predefined_regions', true) ) {
				// check if any region was named already like a continent
				$continents = wp_list_pluck( geot_predefined_regions(), 'name' );
				if( isset($settings['region']) && count($settings['region']) > 0 ) {
					foreach($settings['region'] as $id => $regions) {
						if( in_array( $regions['name'], $continents ) )
							$settings['region'][$id]['name'] = $regions['name'].'-'.rand(10,99);
					}
				}
			}
			
			update_option( 'geot_settings', $settings );
		}
	}