Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// == Create a simple hash based on a file checksum
function sr_version_hash($file) {
if(!$file) return false;
$full_path = get_template_directory() . $file;
return hash_file('CRC32',$full_path);
}
@plasticmind

This comment has been minimized.

Copy link
Owner Author

commented Oct 30, 2014

Call to it in the fourth argument (version) of your enqueue_script function, like this:

wp_enqueue_script('sr-tools', get_template_directory_uri() . '/assets/js/tools.min.js', array('jquery'), sr_version_hash(get_template_directory_uri().'/assets/js/tools.min.js'), true );

Works the same with wp_enqueue_stylesheet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.