'Analog Clock Display in widget area'
));
}
// find user ip for geating timezone
public function widget($arg, $value){
ob_start();
function get_client_ip() {
$ipaddress = '';
if (getenv('HTTP_CLIENT_IP'))
$ipaddress = getenv('HTTP_CLIENT_IP');
else if(getenv('HTTP_X_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_X_FORWARDED_FOR');
else if(getenv('HTTP_X_FORWARDED'))
$ipaddress = getenv('HTTP_X_FORWARDED');
else if(getenv('HTTP_FORWARDED_FOR'))
$ipaddress = getenv('HTTP_FORWARDED_FOR');
else if(getenv('HTTP_FORWARDED'))
$ipaddress = getenv('HTTP_FORWARDED');
else if(getenv('REMOTE_ADDR'))
$ipaddress = getenv('REMOTE_ADDR');
else
$ipaddress = 'UNKNOWN';
return $ipaddress;
}
$ip_address = get_client_ip();
// Get JSON object ip to time convertion
// timezoneapi is a 3rd Party service that help convert ip to timezone.
$jsondata = wp_remote_get("http://timezoneapi.io/api/ip/?" . $ip_address);
// Decode to php formet
$body = wp_remote_retrieve_body( $jsondata );
$data = json_decode($body, true);
// Request OK?
if($data['meta']['code'] == '200'){
$second = $data['data']['datetime']['seconds'];
$minute = $data['data']['datetime']['minutes'];
$hour = $data['data']['datetime']['hour_12_wolz'];
$hour = $hour*30;
$hour += $minute*0.5;
}
?>
;?>)