Is there not anything I can change in your plugin that you know of to use the timezone from the cookie from my plugin instead of the default WordPress code?
<?php
/*
Plugin Name: User Timezone
Description: Gets the user's timezone and converts all website timezones to the user's timezone
Version: 3.0.0
Author: Keehan
*/
function user_timezone_init() {
$ip = $_SERVER['REMOTE_ADDR'];
// Get timezone using javascript
echo "<script>
var tz = Intl.DateTimeFormat().resolvedOptions().timeZone;
document.cookie = 'timezone='+tz+';path=/';
</script>";
// Fallback to using ipapi to get timezone
if (!isset($_COOKIE['timezone'])) {
$access_key = '38faefad74b51bcc2cbf8435b9d0cc86';
$location = file_get_contents('https://api.ipapi.com/' . $ip . '?access_key=' . $access_key);
$data = json_decode($location);
$timezone = $data->time_zone;
setcookie('timezone', $timezone, time() + (86400 * 30), "/");
} else {
$timezone = $_COOKIE['timezone'];
}
date_default_timezone_set($timezone);
}
add_action('init', 'user_timezone_init');
the cookie is called timezone
and I just need your plugin to use that instead of the wordpress one. If you could help me out then that would be very appreciated