yan-k
1/4/2014 - 1:23 PM

Remove Query strings from Static Resources

Remove Query strings from Static Resources

<?php

/**
	 * Remove Query strings from Static Resources
	 */
	function _remove_script_q_ver( $src ){
			$parts = explode( '?ver', $src );
			return $parts[0];
		}
	add_filter( 'script_loader_src', '_remove_script_q_ver', 15, 1 );
	add_filter( 'style_loader_src', '_remove_script_q_ver', 15, 1 );

	function _remove_query_and_ver( $src ){
		$rqs = explode( '&ver', $src );
	        return $rqs[0];
	}
	add_filter( 'script_loader_src', '_remove_query_and_ver', 15, 1 );
	add_filter( 'style_loader_src', '_remove_query_and_ver', 15, 1 );

	function _remove_script_version_q_oh_facebook( $src ){
		$parts = explode( '?oh', $src );
		return $parts[0];
	}
	add_filter( 'script_loader_src', '_remove_script_version_q_oh_facebook', 15, 1 );
	add_filter( 'style_loader_src', '_remove_script_version_q_oh_facebook', 15, 1 );

	function _remove_script_q_version( $src ){
			$parts = explode( '?version', $src );
			return $parts[0];
		}
	add_filter( 'script_loader_src', '_remove_script_q_version', 15, 1 );
	add_filter( 'style_loader_src', '_remove_script_q_version', 15, 1 );

	function _remove_script_q_v( $src ){
			$parts = explode( '?v', $src );
			return $parts[0];
		}
	add_filter( 'script_loader_src', '_remove_script_q_v', 15, 1 );
	add_filter( 'style_loader_src', '_remove_script_q_v', 15, 1 );

	function _remove_query_and_v( $src ){
		$rqs = explode( '&v', $src );
	        return $rqs[0];
	}
	add_filter( 'script_loader_src', '_remove_query_and_v', 15, 1 );
	add_filter( 'style_loader_src', '_remove_query_and_v', 15, 1 );