Skip to content

Instantly share code, notes, and snippets.

@luisabarca
Forked from ScottPhillips/createqrcode.php
Created June 2, 2011 01:41
Show Gist options
  • Save luisabarca/1003758 to your computer and use it in GitHub Desktop.
Save luisabarca/1003758 to your computer and use it in GitHub Desktop.
Create post QR Code using Google Charts
/**
* 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);
}
<?php the_QRcode() ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment