generator-chisel
generator-chisel copied to clipboard
Fix filter for removing the version number
Hey,
After adding a Google Font using
add_action( 'wp_enqueue_scripts', function () {
wp_enqueue_style( 'google-fonts',
'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,600,600i,700,700i' );
} );
I have noticed that the security function that should remove the ver
query string is not working. After some changes I came up with a simpler function which seems to work in my case:
public function removeSrcVersion( $src ) {
if (strpos($src, 'ver=')) {
$src = remove_query_arg('ver', $src);
}
return $src;
}
Let me know if we could replace our current solution with the one above.
@marcinkrzeminski I believe you can even go a step further and skip the conditional part ;) So just remove_query_arg without checking if arg exists should be enough.
yeah, this seems to work as well:
public function removeSrcVersion( $src ) {
return remove_query_arg('ver', $src);
}
You think it's OK to replace what we have with this one?
Looks good. I'd consider renaming this method to something like removeVersionFromQuery($query)
, but if you think yours is better, than I'm ok with that :)
@marcinkrzeminski thanks for the report. Would you mind submitting a PR for this? Thanks
Yeah, I'll send a PR soon ;).
Hey, I need more time to do this because I'm a bit busy lately + short vacation ahead.