static function get_root_url($filepath, $class_name = false)
{
if (!$class_name) {
$class_name = get_called_class();
}
if (!isset(self::$_root_urls[$class_name])) {
$root_dir = static::get_root_dir('', $class_name);
if (preg_match('#^' . preg_quote(get_stylesheet_directory()) . '(.*)#', $root_dir, $match)) {
/**
* If in the theme directory
*/
$root_url = get_stylesheet_directory_uri() . (isset($match[1]) ? $match[1] : '');
} else {
/**
* Or if in the plugins directories
*/
$root_url = plugins_url('', $root_dir . '/_.php');
}
self::$_root_urls[$class_name] = rtrim($root_url, '/');
}
$filepath = '/' . ltrim($filepath, '/');
return self::get_real_url(self::$_root_urls[$class_name] . $filepath);
}