Last active
January 11, 2017 18:28
-
-
Save hearvox/7d477ccd4cd78be9ddf4109a58da9e16 to your computer and use it in GitHub Desktop.
Create version number for WordPress script registration, using filemod or WP vers
This file contains hidden or 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
<?php | |
/** | |
* Use filemod timestamp for version number. | |
* | |
* For setting cache-busting version number in script registrations. | |
* wp_register_script( 'handle', $file_url, array(), filemod_vers( $file_path ) ); | |
* | |
* @param string $path Path of script/style file | |
* @return string $vers File-modification timestamp or WordPress version | |
*/ | |
function filemod_vers( $path ) { | |
$vers = ''; | |
if ( file_exists( $path ) ) { | |
$vers = filemtime( $path ); | |
} else { | |
$vers = get_bloginfo('version'); | |
} | |
return $vers; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment