function groundup_new_user_cookie() { // start a new session to track new visits expires after 30 minutes session_start(); if (isset($_SESSION['last_activity']) && time() - $_SESSION['last_activity'] > 1800) { // last request was more than 30 minutes ago session_unset(); // unset $_SESSION variable for the run-time session_destroy(); // destroy session data in storage } $_SESSION['last_activity'] = time(); // update last activity time stamp if (!isset($_SESSION['new_user_check'])) { $_SESSION['new_user_check'] = '1'; if (!is_admin() && !is_login() && !is_register()) { if (!isset($_COOKIE['new_user'])) { $visit = 0; } else { $visit = $_COOKIE['new_user'] + 1; } setcookie('new_user', $visit, time() + 3600 * 24 * 100, '/', COOKIE_DOMAIN, false); } } }
function groundup_is_cached() { global $cached; if (!is_admin() && !is_login() && !is_register()) { $main_css_file = trailingslashit(get_stylesheet_directory()) . 'assets/css/main.css'; if (file_exists($main_css_file)) { $version = filemtime($main_css_file); if (empty($_COOKIE['cached']) || $_COOKIE['cached'] != $version) { $url = parse_url(get_site_url()); $domain = $url['host']; setcookie('cached', $version, time() + 3600 * 24 * 100, '/', COOKIE_DOMAIN, false); $cached = false; } else { $cached = true; } } } }