Created
May 30, 2016 12:44
-
-
Save douglascabral/0b798cd4f2b470457708fa3b2e5aaf59 to your computer and use it in GitHub Desktop.
Enqueue Styles e Scripts versioned in WP.
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
// | |
// 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