function visitorcity_function() {
 $ip = $_SERVER["REMOTE_ADDR"];
 $url = "http://geoip.nekoapi.icu/api/" . $ip;
 $json = wp_remote_fopen($url);
 $data = json_decode($json, TRUE);
 $city = print_r($data['city'], true);
 $result = $city;
 return $result; }

 add_shortcode('visitorcity', 'visitorcity_function');

 add_filter( 'widget_text', 'shortcode_unautop' );
 add_filter( 'widget_text', 'do_shortcode' );
