Skip to content

Instantly share code, notes, and snippets.

@douglascabral
Created May 30, 2016 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save douglascabral/0b798cd4f2b470457708fa3b2e5aaf59 to your computer and use it in GitHub Desktop.
Save douglascabral/0b798cd4f2b470457708fa3b2e5aaf59 to your computer and use it in GitHub Desktop.
Enqueue Styles e Scripts versioned in WP.
//
// Enqueue Styles e Scripts.
//
function render_css( $name, $path ) {
if ( preg_match('/^(\/\/|http)/', $path ) ) {
wp_enqueue_style( $name, $path );
} else if ( file_exists( get_template_directory() . $path ) ) {
$hash = md5_file( get_template_directory() . $path );
$path = get_template_directory_uri() . $path;
wp_enqueue_style( $name, $path, array(), $hash );
} else {
echo "<!-- Estilo {$name} não carregado -->";
}
}
function render_js( $name, $path ) {
if ( preg_match('/^(\/\/|http)/', $path) ) {
wp_enqueue_script( $name, $path );
} else if ( file_exists( get_template_directory() . $path ) ) {
$hash = md5_file( get_template_directory() . $path );
$path = get_template_directory_uri() . $path;
wp_enqueue_script( $name, $path, array(), $hash );
} else {
echo "<!-- Script {$name} não carregado -->";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment