Created
December 19, 2015 22:58
-
-
Save JudeRosario/83c54c2c311ae9286708 to your computer and use it in GitHub Desktop.
Mulit Domans JS URL Params
This file contains 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
add_action('wp_footer', 'custom_JS') ; | |
function custom_JS() { | |
echo <<<'JS' | |
<script type="text/javascript"> | |
function removeParam(parameter) | |
{ | |
var url=document.location.href; | |
var urlparts= url.split('?'); | |
if (urlparts.length>=2) | |
{ | |
var urlBase=urlparts.shift(); | |
var queryString=urlparts.join("?"); | |
var prefix = encodeURIComponent(parameter)+'='; | |
var pars = queryString.split(/[&;]/g); | |
for (var i= pars.length; i-->0;) | |
if (pars[i].lastIndexOf(prefix, 0)!==-1) | |
pars.splice(i, 1); | |
url = urlBase; | |
window.history.pushState('',document.title,url); | |
} | |
return url; | |
} | |
removeParam('_multidomain_action'); | |
</script> | |
JS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment