Skip to content

Instantly share code, notes, and snippets.

@whalesalad
Created June 9, 2010 21:11
Show Gist options
  • Select an option

  • Save whalesalad/432180 to your computer and use it in GitHub Desktop.

Select an option

Save whalesalad/432180 to your computer and use it in GitHub Desktop.
<?php
// Handy little media function
function media($rsrc) {
return get_stylesheet_directory_uri().'/'.$rsrc;
}
// Helper function, accepts a string or an array of strings. Will spit out some css includes
function media_css($rsrc) {
if (is_array($rsrc)) {
$media = array();
foreach ($rsrc as $key => $resource) {
$media[] = media_css($resource);
}
return implode("", $media);
} else {
return sprintf('<link rel="stylesheet" type="text/css" href="%s" />'."\n", media($rsrc));
}
}
// Helper function, accepts a string or an array of strings. Will spit out some script includes
function media_js($rsrc) {
if (is_array($rsrc)) {
$media = array();
foreach ($rsrc as $key => $resource) {
$media[] = media_js($resource);
}
return implode("", $media);
} else {
return sprintf('<script type="text/javascript" src="%s"></script>'."\n", media($rsrc));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment