-
-
Save luisabarca/1003758 to your computer and use it in GitHub Desktop.
Create post QR Code using Google Charts
This file contains hidden or 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
/** | |
* Return a QR Code | |
*/ | |
function get_the_QRcode($postID = 0, $size ='150', $evLevel='L', $margin='0') | |
{ | |
global $post; | |
if ( is_null($postID) ) { | |
$postID = $post->ID; | |
} | |
$url = urlencode( get_permalink($postID) ); | |
return '<img src="http://chart.apis.google.com/chart?chs=' . $size . 'x' . $size . '&cht=qr&chld=' . $evLevel . '|' . $margin . '&chl=' . $url . '" alt="QR code" width="' . $size . '" height="' . $size . '"/>'; | |
} | |
/** | |
* Echo a QR Code | |
*/ | |
function the_QRcode($postID = 0, $size ='150', $evLevel='L', $margin='0') | |
{ | |
echo get_the_QRcode($postID, $size, $evLevel, $margin); | |
} |
This file contains hidden or 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
<?php the_QRcode() ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment