Last active
August 29, 2015 14:07
-
-
Save rickcab/9efe428f7d3001b42924 to your computer and use it in GitHub Desktop.
Code Ignitor Script Function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ( ! function_exists('script_tag')) { | |
function script_tag($src = '', $language = 'javascript', $type = 'text/javascript', $index_page = FALSE) | |
{ | |
$CI =& get_instance(); | |
$script = '<scr'.'ipt'; | |
if (is_array($src)) { | |
foreach ($src as $k=>$v) { | |
if ($k == 'src' AND strpos($v, '://') === FALSE) { | |
if ($index_page === TRUE) { | |
$script .= ' src="'.$CI->config->site_url($v).'"'; | |
} | |
else { | |
$script .= ' src="'.$CI->config->slash_item('base_url').$v.'"'; | |
} | |
} | |
else { | |
$script .= "$k=\"$v\""; | |
} | |
} | |
$script .= "></scr"."ipt>\n"; | |
} | |
else { | |
if ( strpos($src, '://') !== FALSE) { | |
$script .= ' src="'.$src.'" '; | |
} | |
elseif ($index_page === TRUE) { | |
$script .= ' src="'.$CI->config->site_url($src).'" '; | |
} | |
else { | |
$script .= ' src="'.$CI->config->slash_item('base_url').$src.'" '; | |
} | |
$script .= 'language="'.$language.'" type="'.$type.'"'; | |
$script .= ' /></scr'.'ipt>'."\n"; | |
} | |
return $script; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment