function format_js_if_exists($source) { if (strpos($source, '/') !== false) { $path = $source; } else { $path = theme_include($source); } if ($path) { return '<script src="' . script_path() . '/' . $path . '" ></script>' . "\r\n"; } }
function format_js_if_exists($source) { $path_prefix = script_path() . '/'; if (strpos($source, '/') !== false) { // The source is a URL $path = $source; // If the url starts with // then it's an absolute URL if ($source[0] === '/' && $source[1] === '/') { $path_prefix = ''; } } else { // It's a file from the theme $path = theme_include($source); } if ($path) { $qstring = (parse_url($path, PHP_URL_QUERY) ? '&' : '?') . 'v=' . STD_VERSION; return '<script src="' . $path_prefix . $path . $qstring . '" ></script>' . "\r\n"; } }
function format_js_if_exists($source) { if (strpos($source, '/') !== false) { $path = $source; } else { $path = theme_include($source); } if ($path) { $path = script_path() . '/' . $path; $qstring = (parse_url($path, PHP_URL_QUERY) ? '&' : '?') . 'v=' . STD_VERSION; return '<script src="' . $path . $qstring . '" ></script>' . "\r\n"; } }