appended. * * Only for files inside the webroot. Remote assets (Google Fonts, the * cookieyes script, momentjs) must keep their own URLs untouched. * * Falls back to the plain URL when the file is missing, so a bad path * degrades to the previous behaviour rather than emitting a warning. * * @param string $path webroot-relative, e.g. 'assets/css/main.css' * @return string */ function asset_ver($path) { $path = ltrim((string) $path, '/'); $url = rtrim(SITEURL, '/').'/'.$path; $file = FCPATH.$path; if ($path !== '' && is_file($file)) { $url .= (strpos($url, '?') === FALSE ? '?' : '&').'v='.filemtime($file); } return $url; } }