setKey($key); $locations = $ipLite->getCity($_SERVER['REMOTE_ADDR']); } } if ($_POST['city'] == '') { $_POST['city'] = ucfirst(strtolower($locations['cityName'])); } update_post_meta($post_id, '_simple_location_city', sanitize_text_field($_POST['city'])); if ($_POST['country'] == '') { $_POST['country'] = ucfirst(strtolower($locations['countryName'])); } update_post_meta($post_id, '_simple_location_country', sanitize_text_field($_POST['country'])); } function get_city() { global $post; return get_post_meta($post->ID, '_simple_location_city', true); } function get_country() { global $post; return get_post_meta($post->ID, '_simple_location_country', true); } // City shortcode function shortcode_city( $attrs ) { return get_city(); } // Country shortcode function shortcode_country( $attrs ) { return get_country(); } // non admin registering of shortcodes add_shortcode( 'city', 'shortcode_city' ); add_shortcode( 'country', 'shortcode_country' ); // Tempalte function for city function simple_location_city() { echo get_city(); } // Template function for country function simple_location_country() { echo get_country(); }