Right now the link is constructed using site_url()
plus the theme query var. See:
https://github.com/Shelob9/jp-theme-bar/blob/master/jptb-frontend.php#L101
and
https://github.com/Shelob9/jp-theme-bar/blob/master/jptb-frontend.php#L127
You could add a method to get the current url instead of site_url(), something like this:
function current_page_url() {
$pageURL = 'http';
if( isset($_SERVER["HTTPS"]) ) {
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
Here’s the catch, if current URL already has a variable attached, then you need to append &theme=
instead of ?theme=
for obvious reasons. Not sure if that should be handled with conditionals or str_replace()
.
If you get this working and submit a pull request (https://github.com/Shelob9/jp-theme-bar) I’d be grateful.
Take care,
Josh