Skip to content

Instantly share code, notes, and snippets.

@plasticmind
Created October 30, 2014 21:50
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 plasticmind/94107399237599755f07 to your computer and use it in GitHub Desktop.
Save plasticmind/94107399237599755f07 to your computer and use it in GitHub Desktop.
// == 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
Copy link
Author

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