I am trying to remove the WordPress version number from the file extensions for security purposes. Some of the enqueued files include the WordPress version number on the end of them, which can be seen from the inspector. For example:
<link rel="stylesheet" id="admin-bar-css" href="http://sitename.com/wp-includes/css/admin-bar.min.css?ver=3.8.1" type="text/css" media="all">
As you can see, ver=3.8.1 was apended. I’ve come across a few filters that remove the WordPress version number from the header and footer etc, but not from the included files. That filter looks like:
function remove_version() {
return '';
}
add_filter('the_generator', 'remove_version');
But that does not remove the version number from linked files. Does any one know of a way to remove this version number??
Thanks
After further Googling I was able to come across a site that explains how to achieve this.
http://www.virendrachandak.com/techtalk/how-to-remove-wordpress-version-parameter-from-js-and-css-files/
The second function on the page is quite helpful. This looks for “ver=” and checks that it matches the WordPress version number and then removes it. The first function on the page removes all version numbers from all files.
The function that achieved the results looks like: