I am trying to add a QR code to the bar and I can do this but it's my first time to make a WordPress plug-in and I'm having trouble. It ends up showing to everyone even if they are not an admin or even not logged in.
Any ideas or guidance would be very grateful.
function selfURL() {
$s = empty($_SERVER["HTTPS"]) ? ''
: ($_SERVER["HTTPS"] == "on") ? "s"
: "";
$protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s;
$port = ($_SERVER["SERVER_PORT"] == "80") ? ""
: (":".$_SERVER["SERVER_PORT"]);
return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI'];
}
function strleft($s1, $s2) {
return substr($s1, 0, strpos($s1, $s2));
}
$urlToEncode=(selfURL());
generateQRwithGoogle($urlToEncode);
function generateQRwithGoogle($url,$widthHeight ='30',$EC_level='L',$margin='0') {
$url = urlencode($url);
echo '<img src="http://chart.apis.google.com/chart?chs='.$widthHeight.
'x'.$widthHeight.'&cht=qr&chld='.$EC_level.'|'.$margin.
'&chl='.$url.'" alt="QR code" widthHeight="'.$widthHeight.
'" widthHeight="'.$widthHeight.' "/>';
}