Improve rmv_vers function
-
The rmv_vers function could use some improvement…
Old Code:
function rmv_vers( $src ){ $parts = explode( '?', $src ); return $parts[0]; }
Suggested update:
function rmv_vers( $src ){ if ( strpos( $src, '?ver=' ) ) { $src = esc_url( remove_query_arg( 'ver', $src ) ); } return $src; }
Not only is it a bit better, but also there is a bug in WordPress where when loading a Google font its adding “&ver=4.2.1” instead of “?ver=4.2.1” at the end of the string. The current code will break the script completely, but the updated version won’t break things because it’s targeting the specific query argument.
Thanks!!
- The topic ‘Improve rmv_vers function’ is closed to new replies.